|
| 1 | +<img src="./logo.png" alt="vanilla_http_server Logo" width="100"> |
| 2 | + |
| 3 | +# vanilla_http_server |
| 4 | + |
| 5 | +- **Fast**: Multi-threaded, non-blocking I/O, lock-free, copy-free, epoll, SO_REUSEPORT. |
| 6 | +- **Thread Affinity**: Work in Progress (W.I.P.). |
| 7 | +- **Modular**: Compatible with any HTTP parser. |
| 8 | +- **Memory Safety**: No race conditions. |
| 9 | +- **No Magic**: Transparent and straightforward. |
| 10 | +- **E2E Testing**: Allows end-to-end testing and scripting without running the server. |
| 11 | + Simply pass the raw request to `handle_request()`. |
| 12 | +- **SSE Friendly**: Server-Sent Events support. |
| 13 | +- **Graceful Shutdown**: Work in Progress (W.I.P.). |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +### From Root Directory |
| 18 | + |
| 19 | +1. Create the required directories: |
| 20 | + |
| 21 | +```bash |
| 22 | +mkdir -p ~/.vmodules/enghitalo/vanilla |
| 23 | +``` |
| 24 | + |
| 25 | +2. Copy the `vanilla_http_server` directory to the target location: |
| 26 | + |
| 27 | +```bash |
| 28 | +cp -r ./ ~/.vmodules/enghitalo/vanilla |
| 29 | +``` |
| 30 | + |
| 31 | +3. Run the example: |
| 32 | + |
| 33 | +```bash |
| 34 | +v -prod crun examples/simple |
| 35 | +``` |
| 36 | + |
| 37 | +This sets up the module in your `~/.vmodules` directory for use. |
| 38 | + |
| 39 | +### From Repository |
| 40 | + |
| 41 | +Install directly from the repository: |
| 42 | + |
| 43 | +```bash |
| 44 | +v install https://github.com/enghitalo/vanilla_http_server |
| 45 | +``` |
| 46 | + |
| 47 | +## Benchmarking |
| 48 | + |
| 49 | +Run the following commands to benchmark the server: |
| 50 | + |
| 51 | +1. Test with `curl`: |
| 52 | + |
| 53 | +```bash |
| 54 | +curl -v http://localhost:3001 |
| 55 | +``` |
| 56 | + |
| 57 | +2. Test with `wrk`: |
| 58 | + |
| 59 | +```bash |
| 60 | +wrk -H 'Connection: "keep-alive"' --connection 512 --threads 16 --duration 60s http://localhost:3001 |
| 61 | +``` |
| 62 | + |
| 63 | +Example output: |
| 64 | + |
| 65 | +```plaintext |
| 66 | +Running 1m test @ http://localhost:3001 |
| 67 | + 16 threads and 512 connections |
| 68 | + Thread Stats Avg Stdev Max +/- Stdev |
| 69 | + Latency 1.25ms 1.46ms 35.70ms 84.67% |
| 70 | + Req/Sec 32.08k 2.47k 57.85k 71.47% |
| 71 | + 30662010 requests in 1.00m, 2.68GB read |
| 72 | +Requests/sec: 510197.97 |
| 73 | +Transfer/sec: 45.74MB |
| 74 | +``` |
0 commit comments