15M web servers on one VM – smoltcp, DPDK, AF_XDP
An engineer explores how to run 15 million web servers on a single 10GB VM by bypassing Linux kernel socket limits using userland stacks like smoltcp, DPDK, and AF_XDP.
read it A brilliantly entertaining yet technically rigorous postmortem on overcoming Linux kernel memory limits using userspace networking.
summary
The author tackles the challenge of running 15 million web servers on a single VM with 10GB of RAM. Standard Linux kernel socket allocation exhausts memory around 2.5 million servers due to structural overheads like tcp_sock. By shifting the network stack to userland with smoltcp and employing kernel-bypassing drivers like DPDK and AF_XDP, the architecture reduces memory consumption per connection. The post provides deep insights into low-level networking, kernel bottlenecks, and high-performance packet processing.
key points
- Standard Linux sockets consume about 3.3KB of kernel memory each, causing out-of-memory errors long before reaching millions of servers.
- Moving the TCP/IP stack to userland via smoltcp reduces memory footprint to around 620 bytes per idle connection.
- Technologies like DPDK and AF_XDP bypass traditional kernel overhead to handle high packet rates without interrupt livelocks.
who should read it
Systems engineers and low-level developers interested in network performance and kernel internals.
discussion warm
consensus
Commenters overwhelmingly praised the article for its rare combination of deep technical exploration and highly entertaining, old-school blog humor.
pushback
A minority of technical commenters noted that smoltcp isn't built for general-purpose web serving at this scale and that the high-frequency trading comparisons oversimplify packet rates.
Cutting through abstraction and getting to the heart of what you actually want the computer to do is evidently the key to high performance programming.
You can go much lower. The goal was set at "15 million web servers" which is dependent on the definition of "a web server" to include some implementation details. From the client perspective it actually means 15 million IP/port combinations that respond to HTTP - which you can do all in one go with an appropriate wildcard selector (such as with iptables transparent proxy)
It notes that from a client perspective, 15 million web servers can simply be achieved via wildcard selectors and transparent proxying.
Generated by an LLM from the article and thread. Check the sources before relying on it.