skip to content
arjun nair
projects
completed

HTTP server

HTTP/1.1 · completed

What actually happens between a socket accepting a connection and a response leaving the machine?

why I built it

Every web framework hides the same machinery: sockets, parsing, concurrency, buffers. I wanted to build that machinery myself and then find out where its time goes.

request lifecycle

acceptread bytesparse HTTP/1.1handlewrite response
One request, end to end.

A connection is accepted, bytes are read off the socket, the request line and headers are parsed, a response is built and written back — and for persistent connections, the loop continues.

benchmarking + optimization

Once it could serve requests correctly, I benchmarked it under load and looked for bottlenecks in parsing, concurrency, and memory behavior. I used those measurements to decide what to optimize.

results

The server handled more than 65,000 requests per second in my benchmark, with 179 μs average latency and 232 μs p99 latency. The p99 sat about 50 μs above the average, so few requests were delayed far beyond the typical response time.

arjun nair · stanford