1 Billion Connections on a Laptop: C1B Solved

One developer has held 1 billion connections open on a single laptop with 16 GB of RAM and a 1 GbE network card. The project, nicknamed C1B, got there by bypassing the kernel’s TCP stack and storing each connection in about 13.4 bytes. It’s an experiment, not a production server, but the numbers are real.

Why try a billion

The idea started with a hobby project: pulling emergency alerts from the National Weather Service API onto an e-ink wall display. Polling that free service felt wasteful, so the developer asked why clients can’t just keep a connection open and get a push when bad weather hits.

The usual answer is that open connections are expensive. The history backs that up. In 1999 the C10k problem asked how a server could handle ten thousand clients. Event APIs like epoll and kqueue solved it. WhatsApp pushed one box past 2 million TCP connections in 2012 with Erlang on FreeBSD, and the Phoenix team reached 2 million websockets in 2015. In 2013 Robert Graham argued that getting to 10 million meant taking the network stack out of the kernel, and MigratoryData later reported 10 million on one commodity server, with Linux using about 32 GB just to hold the sockets. The developer couldn’t find anyone who had tried a billion.

Grafana graphs of the run: open TCP connections climbing in a straight line to 1 billion over about an hour and then holding flat, and server memory rising in doubling steps to 12.5 GiB
Image: kyle.cascade.family

The memory problem

Reaching 1 billion connections is mostly a memory puzzle. The constraints were strict: a laptop, 16 GB of RAM, a gigabit NIC, real TCP connections, a real HTTP server that can push, and IPv4 only.

Napkin math looked bad. With 50,000 idle connections on Linux kernel 6.8, each cost about 4 KB on the server side. A billion would need around 4 TB, 250 times the laptop’s memory. Dividing 16 GB by a billion leaves 16 bytes per connection, and the minimum TCP state already eats most of that.

Grafana graphs of the networked run: open TCP connections climbing to just over 1 billion in three hours and then holding flat for 17 hours, packets per second on the wire, and keepalives per second rising and falling in waves
Image: kyle.cascade.family

Squeezing the address

The savings come from the client address. An IP and port take 48 bits, but a giant hash table doesn’t have to store all of them. If you split the table into buckets by the leading bits, the bucket position already tells you those bits.

Real addresses are clumpy, so the code first scrambles the address with a reversible, keyed shuffle and uses the top bits of the result to choose a bucket. For an address like 203.0.113.42:51201, the top 26 bits never touch memory because the bucket implies them. The record keeps only the low 22 bits. To recover the client, the code joins the two halves and runs the shuffle backwards.

The full record for one idle connection is 12.6 bytes. Ten records fit in a 128-byte bucket, which works out to 12.8 bytes per slot. In the real run, with buckets not quite full, it averaged 13.4 bytes per connection.

What the server skips

A normal server tracks much more. This one drops most of it.

  • Handshake state is replaced by SYN cookies, which pack what the server needs into its initial sequence number.
  • There are no per-connection timers. A background sweep walks the table, and a record’s position decides when it gets a TCP keepalive.
  • There are no per-connection buffers, because every message fits in one 536-byte packet.
  • There is no TLS. The keys alone would dwarf the record.

Clients subscribe with a plain HTTP request, such as a county code like OKC109 for Oklahoma County, and receive a server-sent event stream. When a warning lands, every subscriber gets the same push, for example a tornado warning until 6:15 PM.

Does the network keep up

Bandwidth is the other limit on 1 billion connections. A gigabit link divided by a billion connections gives about 1 bit per second per connection. An alert to a county with a million subscribers takes roughly 6 seconds. An alert to all billion takes more than an hour and a half.

A simulated run on localhost reached 1 billion connections in about an hour, with server memory reaching 12.5 GiB. A second run used a real gigabit link and a separate load generator that spoofed client addresses. It climbed to just over 1 billion in three hours and held steady for 17 hours. The link was only about 20% full while ramping up, since a single load generator couldn’t produce more packets.

Limits and next steps

The server uses a raw socket rather than true kernel bypass, and it’s single-threaded. It isn’t a production TCP stack, and adding encryption would likely exhaust the CPU and the memory budget. The developer’s future work is to explore XDP and other bypass techniques, and says it’s unclear whether the design applies in the real world beyond tools like Pushpin. The source code is public.

Source: kyle.cascade.family

Written by

Saksham Bhargava

Saksham Bhargava runs Alteroid and has been writing about consumer technology for over five years, covering iPhone, Android, Windows, AI tools and gaming. With an MCA and six years of hands-on web development experience, he tests the features he writes about on his own devices and focuses on clear, practical guides that solve real problems. Away from the screen, he enjoys travelling to places most tourists skip.