- Fast: Multi-threaded, non-blocking I/O, lock-free, copy-free, epoll, SO_REUSEPORT.
- Thread Affinity: Work in Progress (W.I.P.).
- Modular: Compatible with any HTTP parser.
- Memory Safety: No race conditions.
- No Magic: Transparent and straightforward.
- E2E Testing: Allows end-to-end testing and scripting without running the server. Simply pass the raw request to
handle_request()
. - SSE Friendly: Server-Sent Events support.
- Graceful Shutdown: Work in Progress (W.I.P.).
- Create the required directories:
mkdir -p ~/.vmodules/enghitalo/vanilla
- Copy the
vanilla_http_server
directory to the target location:
cp -r ./ ~/.vmodules/enghitalo/vanilla
- Run the example:
v -prod crun examples/simple
This sets up the module in your ~/.vmodules
directory for use.
Install directly from the repository:
v install https://github.com/enghitalo/vanilla_http_server
Run the following commands to benchmark the server:
- Test with
curl
:
curl -v http://localhost:3001
- Test with
wrk
:
wrk -H 'Connection: "keep-alive"' --connection 512 --threads 16 --duration 60s http://localhost:3001
Example output:
Running 1m test @ http://localhost:3001
16 threads and 512 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 1.25ms 1.46ms 35.70ms 84.67%
Req/Sec 32.08k 2.47k 57.85k 71.47%
30662010 requests in 1.00m, 2.68GB read
Requests/sec: 510197.97
Transfer/sec: 45.74MB