o
odinpkg.dev
packages / library / valkyrie-httpd

valkyrie-httpd

v0.0.1-alpha.10library

A (mostly) Odin native HTTP/2 + TLS server

No license · updated 9 months ago

Valkyrie

A high-performance HTTP/2 + TLS server written in Odin.

Currently achieves ~10 million requests/second on Intel Core Ultra 7 265F.

Quickstart

Using Nix (recommended):

# Enter the development environment
nix develop

# Run the server with TLS
make dev

The server will start on https://localhost:8443.

Building

With Nix (Recommended)

# Build the server
nix develop --command make build

# Run tests
nix develop --command make test

Manual Installation

  1. Install dependencies:

  2. Build:

    make build
  3. Run tests:

    make test

Running

Development Mode

make dev

Runs the server with TLS on port 8443 using the development certificate.

Production Mode

./build/valkyrie --tls --port 8443 --cert /path/to/cert.crt --key /path/to/key.key

Generate Development Certificates

openssl req -x509 -newkey rsa:4096 -keyout dev.key -out dev.crt -days 365 -nodes -subj "/CN=localhost"

Performance

Valkyrie achieves high throughput with minimal memory overhead:

  • ~10 million requests/second on Intel Core Ultra 7 265F (20 cores)
  • Sub-millisecond mean latency under load
  • Zero failures across hundreds of millions of requests

Running Benchmarks

make benchmark-server

Note: This benchmark is configured for a 20-core CPU with 16 workers. Adjust the --workers parameter in the Makefile's benchmark-server target to match your CPU core count for optimal results.

Benchmark Results

valkyrie master  ? ❯ h2load -n 10000000 -c 500 -t 20 https://localhost:8443
starting benchmark...
spawning thread #0: 25 total client(s). 500000 total requests
spawning thread #1: 25 total client(s). 500000 total requests
spawning thread #2: 25 total client(s). 500000 total requests
spawning thread #3: 25 total client(s). 500000 total requests
spawning thread #4: 25 total client(s). 500000 total requests
spawning thread #5: 25 total client(s). 500000 total requests
spawning thread #6: 25 total client(s). 500000 total requests
spawning thread #7: 25 total client(s). 500000 total requests
spawning thread #8: 25 total client(s). 500000 total requests
spawning thread #9: 25 total client(s). 500000 total requests
spawning thread #10: 25 total client(s). 500000 total requests
spawning thread #11: 25 total client(s). 500000 total requests
spawning thread #12: 25 total client(s). 500000 total requests
spawning thread #13: 25 total client(s). 500000 total requests
spawning thread #14: 25 total client(s). 500000 total requests
spawning thread #15: 25 total client(s). 500000 total requests
spawning thread #16: 25 total client(s). 500000 total requests
spawning thread #17: 25 total client(s). 500000 total requests
spawning thread #18: 25 total client(s). 500000 total requests
spawning thread #19: 25 total client(s). 500000 total requests
TLS Protocol: TLSv1.2
Cipher: ECDHE-RSA-AES128-GCM-SHA256
Server Temp Key: ECDH prime256v1 256 bits
Application protocol: h2
progress: 10% done
progress: 20% done
progress: 30% done
progress: 40% done
progress: 50% done
progress: 60% done
progress: 70% done
progress: 80% done
progress: 90% done
progress: 100% done

finished in 6.44s, 1552175.13 req/s, 199.84MB/s
requests: 10000000 total, 10000000 started, 10000000 done, 10000000 succeeded, 0 failed, 0 errored, 0 timeout
status codes: 10000000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 1.26GB (1350034500) total, 28.62MB (30007500) headers (space savings 93.88%), 1.06GB (1140000000) data
                     min         max         mean         sd        +/- sd
time for request:        7us     15.78ms       218us       683us    94.74%
time for connect:    41.86ms     71.20ms     52.63ms      5.10ms    68.20%
time to 1st byte:    42.02ms     72.59ms     53.26ms      5.22ms    66.80%
req/s           :    3111.43     5789.46     3888.19      526.53    67.60%