← Back to articles
News· 12 min read· David Carrero Fernández-Baillo

15 million web servers on a single VM: why the kernel can't cope and how a Rust TCP/IP stack pulls it off

An Intel 82574L Gigabit Ethernet network card in PCI Express x1 form factor, with its RJ45 connector and controller chip on the green board
Image: Dsimic / CC BY-SA 3.0 · Wikimedia Commons

How many web servers fit on a virtual machine with 10 GB of RAM and a single core? Developer Artem Yarulin has taken the question seriously on his blog, kapteko, starting from a tongue-in-cheek premise: web servers get attacked so much because there aren’t enough of them, so let’s give one to every person on Earth. First step: 15 million on one VM.

The joke is the excuse. The interesting part is the journey, which forces you down the Linux network stack layer by layer until you find where the memory goes, and ends with the TCP/IP stack pulled out of the kernel and into user space. The outcome: with the kernel network stack, memory runs out at around 2.5 million servers; with smoltcp, a TCP/IP stack written in Rust, it reaches 16 million.

We repeated the part anyone can check on their own machine: how much a TCP socket costs in the kernel, and how to listen on millions of IP addresses without millions of network cards.

First wall: ports

From the operating system’s point of view, a web server is little more than half a dozen system calls: socket, listen, accept, recv, send and close. Yarulin starts with a minimal C server that asks the kernel for any free port and answers OK to everything. It manages about 65,000 requests per second. Then he launches 15 million of them in a shell loop, and number 28,232 fails.

The explanation lies in net.ipv4.ip_local_port_range. When a program doesn’t pick a port, the kernel assigns one from that range, which by default runs from 32768 to 60999: 28,232 ports, exactly where it stopped. Even if you widen it to the full range, a port is a 16-bit number and can’t go past 65,535.

The way out is that a server isn’t identified by its port alone but by the combination of protocol, IP address and port. With many IPs, the same port 80 works for all of them. And having many IPs doesn’t require 450 network cards (the article’s other joke): AnyIP is enough, a route of type local that makes the kernel treat a whole subnet as its own:

ip -6 route add local 2001:db8:1234:5678::/64 dev lo

With an IPv6 /64, which many providers hand out with every server, there are 18 quintillion addresses to listen on. We tried it on IPv4 with a private /16: after adding the route, a server listening on 10.64.3.7, an address not assigned to any interface, simply answers. In fact, Linux already ships such a route for the whole of 127.0.0.0/8, and in our test we opened 200,000 sockets listening on port 8080, each on its own 127.x.y.z address.

Second wall: one process per server

With addressing solved, the loop fails again, this time for lack of memory. Each C server process takes around 1.5 MB, and 15 million processes would need about 20 TB.

Here Yarulin draws on his own earlier work. Instead of processes, he runs every server as a guest inside a single process, with a custom runtime that sandboxes them with LFI (Lightweight Fault Isolation, a software isolation technique from Stanford) and replaces their system calls with its own functions. A user-space scheduler hops from one guest to the next, and since the server only has two pieces of state (the listening descriptor and the client’s), saving each guest costs about 16 bytes: 220 MB for all 15 million.

Third wall: what a socket costs in the kernel

With processes out of the picture, the author did an optimistic sum: a socket that only listens shouldn’t take up anything. He asked an AI assistant, which told him an idle connection costs zero bytes, and the numbers worked out. They didn’t. A program that just calls socket() ten million times exhausts the VM’s 10 GB.

Yarulin owns up to the mistake in the article, and it’s the most useful part: every call to socket() reserves about 3,300 bytes in the kernel, whether the socket is active, listening or unused. His breakdown, with the size of each structure:

Structure Size (author) Measured by us in the slab cache* What it’s for
struct tcp_sock 2,240 B 2,366 B (TCP) TCP state: queues, timers, sequence numbers, congestion control
struct socket_alloc 768 B 796-831 B (sock_inode_cache) The struct socket with its wait queue plus the sockfs inode
struct file 184 B 191 B (filp) The open file pointing to the socket
struct dentry 192 B 192 B (dentry) The name in the sockfs pseudo-filesystem
Total 3,384 B ≈3,550-3,580 B

* Growth of each cache divided by 200,000 sockets, on Linux 7.0.14. The cache rounds each object up for alignment, which is why it comes out slightly above the structure’s sizeof.

We measured it on Linux 7.0

Terminal in a Debian 13 container with kernel 7.0.14: the local port range is 32768-60999; creating 200,000 TCP sockets grows the TCP cache by 2367 bytes per socket, sock_inode_cache by 831, filp by 191 and dentry by 192, 3581 bytes per socket in total; with bind and listen on 200,000 127.x.y.z addresses the total is 3554 bytes; then the local route 10.64.0.0/16 is added and curl gets a 200 from 10.64.3.7
200,000 sockets cost about 710 MB of kernel memory, listening or not · Own screenshot

We repeated the sum in a Debian 13 container: 200,000 sockets, first freshly created and then each one listening on its own address, comparing the size of the kernel caches before and after. Our measurement matches his: about 3.5 KB per socket, and it makes no difference whether it’s listening or not. With 10 GB, that puts the theoretical ceiling below 3 million sockets before counting anything else. In his test, the kernel stack ran out of memory at around 2.55 million servers.

There’s no fat buffer to trim, as Yarulin had hoped to find. These are structures the kernel needs so that any socket behaves like just another file and to keep the full TCP state. Shrinking them would mean rewriting half the network stack.

The way out: take TCP/IP out of the kernel

If the problem sits in the transport layer, the answer is to go one layer lower. Below TCP, neither IP nor Ethernet keeps state: nothing stops a program from building its own IP packets or Ethernet frames as long as it handles TCP itself. Embedded systems have been doing exactly that for decades, and there’s plenty to choose from:

  • lwIP, the C stack found in countless microcontrollers.
  • Seastar, the framework from the makers of ScyllaDB, with its own stack.
  • gVisor, which reimplements much of the kernel, networking included.
  • F-Stack, which brings FreeBSD’s stack to user space.

Yarulin chose smoltcp, a 0BSD-licensed Rust TCP/IP stack designed for bare-metal systems that needs no dynamic memory allocation at all. His test uses version 0.14.0, the latest, released in August. smoltcp speaks TCP but doesn’t move packets: you have to give it a device for them to go in and out through.

Four ways to move the packets

Path Layer Who controls the card? Cost Does SSH keep working?
TUN IP (layer 3) The kernel; virtual interface One system call and one copy per packet Yes
TAP Ethernet (layer 2) The kernel; virtual interface Same as TUN Yes
AF_XDP Ethernet The kernel, which diverts packets with an eBPF program Shared-memory rings, zero copy; optionally a core in busy polling Yes
DPDK Ethernet The program, exclusively A whole core in a busy loop No, if it’s the same card

smoltcp supports TUN and TAP, the kernel’s virtual interfaces, out of the box. They’re the easiest option, but every packet still goes through a system call and a copy between the kernel and the program.

DPDK sits at the other extreme. The program talks directly to the card through shared-memory buffers, with no system calls and no interrupts: one CPU core is dedicated to shuffling data in an endless loop. It’s what people processing hundreds of millions of packets per second use. The price is that the card vanishes from the operating system: not even ip link sees it. Enable it over SSH on the same interface and you lose your session.

AF_XDP is the middle ground Linux has offered for years. The card stays in the kernel’s hands, but a small eBPF program hooked into XDP decides, for each packet, whether to hand it straight to a buffer shared with the program, bypassing the network stack, or let it continue down the normal path. That way the web servers’ traffic can be diverted while SSH keeps working. With the SO_PREFER_BUSY_POLL option it gets closer to DPDK, at the cost of a core as well.

Hooking smoltcp up to these last two only takes implementing its Device trait, or using the xsk-rs crate for AF_XDP and rust-dpdk-net for DPDK, which are the ones the test uses.

The results

Two-column diagram. On the left, the kernel network stack: a C web server of about 1.5 MB per process makes system calls, the kernel allocates file, dentry, socket_alloc and tcp_sock (3.4 to 3.6 KB per socket even when idle) and goes through the TCP/IP stack and the driver to the network card; it runs out of memory at about 2.55 million servers in 10 GB. On the right, the user-space stack: a single process with the runtime and LFI sandboxing (16 bytes of state per guest) intercepts system calls and passes them to smoltcp (about 620 bytes per idle server and 1 KB active), which sends frames through TUN/TAP, AF_XDP or DPDK to the card; it reaches 16 million servers, with DPDK fastest and AF_XDP close behind
From one kernel socket per server to a Rust TCP/IP stack inside a single process · Our own diagram with figures from kapteko.com and our measurement

The final design looks like this: the runtime loads the 15 million guests, each one starts listening on its own address, their system calls go to smoltcp and the scheduler wakes whichever guest has data waiting. The figures come from the author’s benchmark:

Setup Cost per server Servers on the 10 GB VM
One process per server ~1.5 MB ~7,000 (calculated)
Kernel network stack ~3.4 KB per socket + guest state Out of memory at about 2.55 million
smoltcp ~620 B idle, ~1 KB active 16 million

With the kernel stack, requests per second also drop as the number of servers grows. Among the smoltcp paths, DPDK is the fastest and AF_XDP is close behind, with the advantage of not taking the card away from the system. The code is published in the author’s AI10M repository.

What we take from it

Nobody needs 15 million web servers on a VM, and the author admits the proof of concept is the easy part: a runtime compatible with every POSIX call is another story. But the experiment leaves a few useful lessons for anyone running Linux servers:

  • An idle socket isn’t free. Every open connection, every listening socket and every TIME_WAIT costs around 3.5 KB of kernel memory that doesn’t show up in any process’s usage. You can see it with slabtop or in /proc/slabinfo (the TCP, sock_inode_cache, filp and dentry caches), and ss -s gives the count.
  • The ephemeral port range is small. The default 28,232 ports also limit outgoing connections to a single destination, something proxies and load balancers run into.
  • AnyIP exists and is very handy. A local route lets you answer on an entire subnet, which some load balancers and CDNs already use for anycast services.
  • User-space networking isn’t just for trading firms. When density or latency is what matters, pulling TCP/IP out of the kernel gives you full control over memory. AF_XDP makes that accessible without losing normal management of the machine.

And one more, which the author tells without hedging: the AI assistant’s answer about the cost of an idle connection was wrong, and it was measuring that exposed it. Rust, by the way, is also gaining ground inside the kernel itself, as we covered in Linux 7.4, Rust versus C.

How we tested this

On 22 November, with Docker on an Apple Silicon Mac (Docker VM kernel: 7.0.14), in a privileged debian:13 container so we could read /proc/slabinfo and add routes. We compiled with gcc a C program that creates 200,000 TCP sockets (first with socket() alone, then with bind() and listen() on port 8080 of distinct 127.x.y.z addresses) and compares the size of the slab caches before and after. For AnyIP, we added a local route and served HTTP on an unassigned address:

docker run --rm -it --privileged --ulimit nofile=1048576:1048576 debian:13 bash
apt update && apt install -y gcc libc6-dev iproute2 python3 curl
grep -E '^(TCP|sock_inode_cache|filp|dentry) ' /proc/slabinfo   # before and after opening the sockets
ip route add local 10.64.0.0/16 dev lo
python3 -m http.server 8080 --bind 10.64.3.7 &
curl -I http://10.64.3.7:8080/

The drop in MemAvailable varies quite a bit between runs (between 2,150 and 2,900 bytes per socket in our tests), so we took the growth of the slab caches, which was stable, as the reference. We did not repeat the 16-million-server benchmark: the smoltcp, AF_XDP and DPDK figures are the author’s. When we finished we removed the container and the image.

Sources: 15 million web servers on one VM - smoltcp, DPDK, AF_XDP, by Artem Yarulin on kapteko (18 Nov 2026), and his test code; smoltcp and its Device trait documentation; the kernel’s AF_XDP documentation; the DPDK guides; ip_local_port_range in the kernel documentation; LFI: Lightweight Fault Isolation (Stanford); xsk-rs and rust-dpdk-net. Checked on 22 Nov 2026.