The project asks whether a laptop with 16 GB of RAM and a 1 GbE network card can hold one billion real TCP connections, motivated by replacing wasteful polling with persistent connections that deliver weather alerts on demand. Ordinary Linux sockets consume roughly 4 KB per idle connection, far beyond the available memory, so the design bypasses the kernel’s TCP connection management and builds a specialized server for one-way county alert subscriptions. It avoids storing full client addresses by using a reversible keyed shuffle and a hash table whose bucket positions encode part of each address. SYN cookies eliminate stored handshake state; periodic table sweeps replace per-connection timers, and messages fit in single packets. The system uses plain HTTP, with no TLS or per-connection data buffers.
Each connection’s record stores about 101 bits for the client address, TCP sequence numbers, county subscription, and age; actual table occupancy averages 13.4 bytes per connection. A localhost simulation reached one billion connections using 12.51 GiB, with none lost, filling the table in 62 minutes. It could look up a connection in 482 nanoseconds, while delivering an alert to 312,500 subscribers took 9.7 seconds. Network capacity, rather than memory, limits real-world delivery: a keepalive for every connection every 30 minutes uses about 37% of the gigabit link, and an alert to a million clients takes roughly six seconds. The experiment demonstrates a narrow, highly optimized possibility - not a general-purpose or secure web server - and its real-network test was constrained by the load generator.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.