15M web servers on one VM – smoltcp, DPDK, AF_XDP kapteko.com · 49 points · 9 co...
HN Best 200 @best
15M web servers on one VM – smoltcp, DPDK, AF_XDP kapteko.com · 49 points · 9 comments · HN thread
TL;DR The author, writing as a satirical bootstrapping project, aims to run 15 million web servers on one VM with 10GB RAM and 1 CPU core. The article walks through why the kernel's socket and port limits block this, and proposes AnyIP subnets plus a custom userland runtime with smoltcp, DPDK or AF_XDP to cut per-server memory from about 3.4KB to roughly 620 bytes idle and about 1KB active.
- Port range limits (about 65k per IP, and 1-65535 even with overrides) block 15M listeners on one IP, so the author proposes AnyIP to listen on a whole IPv6 subnet.
- Each Linux socket costs about 3300-3400 bytes in kernel structures (tcp_sock, socket_alloc, file, dentry), so 10M idle sockets exhaust 10GB.
- A guest needs only about 16 bytes of scheduling state (program counter and two file descriptors), so 15M guests need roughly 220MB in a userland runtime.
- smoltcp provides a userland TCP/IP stack but needs an I/O backend: TUN/TAP via the kernel, or DPDK or AF_XDP for kernel bypass.
- DPDK is fastest in the author's benchmark and takes the NIC away from the OS, while AF_XDP keeps the device in the kernel and nearly matches DPDK.
- The kernel stack runs out of RAM at about 2.5M servers, while the smoltcp-based design reaches about 16M in the author's measurements.
Discussion The thread is short and almost entirely praise. Commenters single out the humour, the clear step-by-step technical explanation and the article's refusal to be generic AI-written prose. The only substantive critique is about the title: one commenter says the word 'web' made them expect HTTP parsing and nearly stopped reading. A reply jokes that the author should next worry about the Host header, a small dig at the article's HTTP-free framing.
- Excellent, funny, clearly written and technical (most): Most commenters praise the article's humour, readability and depth, calling it rare in a sea of AI-generated writing. Several say it made them want to read more by the author.
- Title with 'web' is misleading (a few): One commenter suggests dropping 'web' from the title, since it suggested HTTP handling and almost made them stop reading. The article's point is about raw connection and listener scaling rather than web serving.
- Userland networking blurs the line toward microkernels (a few): One commenter observes that moving networking into userland makes Linux look more like a microkernel.
- Reminder that abstractions can be stripped away (a few): One commenter says the piece shows how easy it is to forget the power in a system and how much can be gained by removing abstraction layers.
- Joke that the author has missed the Host header (a few): One commenter notes that serving many virtual hosts would require parsing the HTTP Host header, which the toy server ignores.
#networking #linux #smoltcp #dpdk #afxdp #systemsProgramming