Certain features, such as HTTP/2, HTTPS, or compression might not be needed. When Kvarn is deployed to an IOT device controlled from within the network, these features aren’t needed. Disabling them cuts down on compilation time, memory requirements, and space requirements.
To view the dependencies used by each feature, see the Cargo.toml file.
These can be enabled in your Cargo.toml
:
[dependencies]
kvarn = { version = "0.5", default-features = false, features = ["base", "https", "http2", "all-compression"] }
See the official Cargo guide on the matter.
Which Cargo features are required for certain items are also shown in the
docs (e.g. the
Host::new
function).
Please always enable base
(see below for more details).
uring
: Use the io-uring API for network and file system IO on Linux. ~0-15% better performance, depending on use-case. Do your own benchmarks!http3
: Enables HTTP/3. Strongly recommended, since HTTP/3 is faster than both HTTP/1 & HTTP/2, due to the new protocol, QUIC. Enabling HTTP/2 in tandem is also recommended, since the initial connection is done over TCP, so having the fastest TCP protocol (HTTP/2) available is beneficial. Works both with and withouturing
(world first!).https
: Enables HTTPS, the secure HTTP protocol. This is strongly recommended if you’re doing anything that’s not resource constrained and local.http2
: Enables HTTP/2. This is strongly recommended as it’s considerably faster and less resource intensive than HTTP/1.1, which is always supported. This also reduces latency due to implementation details.br
: Brotli compressiongzip
: Gzip compressiongraceful-shutdown
: Enables graceful shutdown and handover. This means you can upgrade the Kvarn server without ANY downtime - using UNIX socket magic we bind the new server on the same sockets, then tell the old instance to shut down. All pending and current requests are waited for.auto-hostname
: Populates the host name and alternative names automatically. This uses the info stored in the certificate.nonce
: enables usage of nonce on inline<script>
and<style>
elements.websocket
: enables thewebsocket
module in Kvarn which allows easy and fast WebSockets from you web application.async-networking
: use Tokio’s async networking primitives instead of the blockingstd::net
variants. Recommended for every application that can enable it. See embedded for more details.
There are additionally several feature sets:
full
: enables all the features above.base
: enablesasync-networking
, a feature considered critical for all platforms except embedded (e.g. ESP32-IDF)all-http
: enables all HTTP standards and versions available -https
&http2
&http3
all-compression
: enables all compression features -br
&gzip
Embedded
Some embedded platforms have std
support (e.g. ESP32-IDF) but don’t support
mio
. Disabling the feature async-networking
causes Kvarn to block on every
request, but removes the dependency on mio
. It’s very useful for IOT devices
which don’t need large throughput nor sub-ms responsiveness (which the embedded
controllers doesn’t have computing power to achieve anyway).