relic_native 2.0.1
relic_native: ^2.0.1 copied to clipboard
A Relic adapter backed by a Zig HTTP server on native I/O threads.
2.0.1 #
- fix: The request body takes its type from
relic_core, and a request with no content has no body type - fix: A request with more than one
Content-Typefield gets 400. A filter in front and the server could otherwise read the body as different types, as in CVE-2023-38199 - fix: A handler that waits on its own I/O, such as a database reply or
a timer, gets the event loop at once. The drain no longer waits in
the kernel while an exchange is in flight, and a route that ran
SELECT 1under steady load stalled near one second on 2.0.0 - fix: A graceful
close()waits until every response handed to the native side is written, so a large response is not cut off - perf: An idle drain lingers 100 us, and a drain turn whose requests
all went to
asynchandlers ends without another tick - build: TLS runs on ztls and AWS-LC's libcrypto, in place of tls.zig
- build: zio is updated. On macOS a poll without a wait goes through
kevent64, and the server accepts the next connection after one that failed
2.0.0 #
The first release of relic_native, a
Relic adapter on an HTTP server written in
Zig. It answers about five times the requests per second of relic_io. To
try it, add the package and call app.serveNative() where the program
called app.serve().
Benchmarks #
On a GCP c4d-standard-32 instance, 16 AMD EPYC 9B45 cores, one isolate
answers 295 thousand plaintext requests per second on relic_native and
61 thousand on relic_io. Over HTTPS it is 243 thousand and 25 thousand.
An idle WebSocket over TLS takes 14.8 KiB of the server's memory, and
61.6 KiB on relic_io. The
Relic changelog has the
other routes and how they were measured.
Features #
- Initial release:
NativeAdapter, a Relic adapter on a Zig HTTP server built on zio andstd.http.Server, which each isolate drives from its own thread.NativeExchange,NativeOptions,NativeTlsandserveNativego with it - HTTP/1.0 and HTTP/1.1 with keep-alive, streamed request and response
bodies, WebSockets and hijacked connections.
NativeOptionsholds the limits and timeouts,maxInlineBodyamong them, the body read before the handler runs - Several isolates serve one port: a
bindwith the samegroupjoins the server the first one created, and passes the sametls - HTTPS through
NativeTls, TLS 1.3 only: a certificate chain and a private key. The key is ECDSA, RSA or Ed25519 in PKCS#8 form, or a SEC 1 (EC PRIVATE KEY) or PKCS#1 (RSA PRIVATE KEY) one.passwordopens an encrypted key, a PKCS#8 key under PBES2 with PBKDF2 and AES-128 or AES-256 CBC, or one behind OpenSSL's DEK-Info headers.clientAuthoritiesnames the CAs a client certificate must chain to, and the handshake then requires one. ALPN selectshttp/1.1and refuses a client that offers only other protocols bindtakesv6Only, asIOAdapter.binddoes. Without it an IPv6 listener takes IPv4 clients- Prebuilt for Linux, macOS and Windows on x64 and arm64, so a project needs no Zig toolchain. The libraries use hardware AES for TLS. They need AES-NI, PCLMULQDQ and AVX on x64, and the ARMv8 crypto extensions on Linux and Windows arm64