Skip to main content

relic_native 2.0.1 copy "relic_native: ^2.0.1" to clipboard
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-Type field 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 1 under 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 async handlers 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 and std.http.Server, which each isolate drives from its own thread. NativeExchange, NativeOptions, NativeTls and serveNative go with it
  • HTTP/1.0 and HTTP/1.1 with keep-alive, streamed request and response bodies, WebSockets and hijacked connections. NativeOptions holds the limits and timeouts, maxInlineBody among them, the body read before the handler runs
  • Several isolates serve one port: a bind with the same group joins the server the first one created, and passes the same tls
  • 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. password opens 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. clientAuthorities names the CAs a client certificate must chain to, and the handshake then requires one. ALPN selects http/1.1 and refuses a client that offers only other protocols
  • bind takes v6Only, as IOAdapter.bind does. 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
0
likes
150
points
5.71k
downloads

Documentation

API reference

Publisher

verified publisherserverpod.dev

Weekly Downloads

A Relic adapter backed by a Zig HTTP server on native I/O threads.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#server #web #backend #http

License

BSD-3-Clause (license)

Dependencies

code_assets, ffi, hooks, relic_core, stream_channel, web_socket

More

Packages that depend on relic_native