hn.today

Solving the 1B Concurrent Connections (C1B) Problem on My Laptop

kyle.cascade.family6 points1 comments
Screenshot of Solving the 1B Concurrent Connections (C1B) Problem on My Laptop

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.

Read on kyle.cascade.family1 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Web

Are EU Kidding Me?

Are EU Kidding Me?

A legal scholar argues that the EU’s proposed Kids Act is poorly drafted, with conflicting rules and broad language that could sweep in unrelated services and restrict products such as voice assistants. He urges the European Commission to withdraw the proposal and rewrite it with clearer, workable requirements. (michae.lv)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.