High-Throughput I/O: io_uring, Zero-Copy & XDP/eBPF
Squeeze 10x more throughput from one Linux host using io_uring rings, zero-copy sendfile, XDP/eBPF L4 packet steering, and thread-per-core scheduling.
In this lesson (4 bite-sized sections)
Scale up one box before scaling out
Before adding fifty servers and paying distributed-systems coordination costs, inspect where a busy Linux node actually burns CPU. On high-throughput proxies, brokers, and storage engines (Nginx, Redpanda, ScyllaDB, TigerBeetle), domain logic often uses a sliver of each core while the rest disappears into system-call context switches, copying bytes between kernel and user buffers, cross-core mutex contention, and kernel networking allocations. Modern Linux gives you four concrete levers to push a single host an order of magnitude further before you shard.
epoll vs io_uring and zero-copy DMA
Event loops built on epoll multiplex tens of thousands of sockets, but epoll only signals readiness; every read() and write() still crosses into kernel mode, and regular file I/O does not work asynchronously with epoll. Linux io_uring replaces per-call transitions with two lock-free ring buffers shared between user space and the kernel: a Submission Queue (SQ) and a Completion Queue (CQ). User space enqueues a batch of socket and NVMe operations into the SQ and reaps finished entries from the CQ in one system call (or zero with kernel polling).
Pair asynchronous rings with zero-copy data movement. Serving a Kafka log segment or video chunk via read() then write() copies bytes four times across page cache, user buffers, socket buffers, and NIC memory. Using sendfile(), splice(), or registered io_uring buffers lets DMA hardware stream bytes straight from kernel page cache to the network card, sparing both memory bandwidth and CPU L1/L2 caches.
| Lever | Bottleneck eliminated | Execution layer | Canonical use case |
|---|---|---|---|
| epoll | Thread-per-connection memory and scheduling | Kernel readiness + per-op syscall | High-concurrency HTTP/WebSocket servers |
| io_uring | Syscall storms and blocking disk I/O | Shared user/kernel SQ and CQ rings | NVMe databases, high-IOPS brokers |
| sendfile / DMA | Redundant kernel-to-user memory copies | Kernel page cache direct to NIC | Kafka brokers, static/CDN media serving |
| XDP / eBPF | Per-packet sk_buff allocation under flood | NIC driver hook inside kernel | L4 load balancing (Katran), DDoS drops |
| Thread-per-core | Cross-core lock and cache-line bouncing | Pinned shared-nothing workers + RSS | ScyllaDB, Redpanda, Seastar engines |
XDP and eBPF L4 packet steering
At tens of millions of packets per second during DDoS mitigation or L4 load balancing (Meta's Katran, Cloudflare's edge), merely allocating a kernel sk_buff per incoming packet exhausts CPUs. eBPF runs verifier-checked bytecode inside the Linux kernel safely. Attached at the XDP (eXpress Data Path) hook inside the NIC driver, an eBPF program inspects raw Ethernet frames before sk_buff creation, dropping malicious floods or redirecting L4 flows with Direct Server Return at line rate. Keep the security boundary clear: eBPF executes L3/L4 steering, filtering, and policy checks in the kernel, while TLS handshakes and L7 parsing remain in user space (or tunnel encryption runs via WireGuard or IPsec).
Thread-per-core architectures
Fast I/O still stalls on a 64-core server if worker threads fight over shared locks and bounce cache lines across NUMA nodes. Thread-per-core engines (ScyllaDB, Redpanda, Seastar) pin one asynchronous loop to each physical core, steer NIC receive queues per core via RSS, partition in-memory tables so each core owns its shard exclusively, and exchange cross-core requests over lock-free ring queues. You accept extra care around skewed keys on one core in exchange for predictable tail latency and dramatic vertical headroom. In system design interviews, profiling and exhausting these single-node ceilings first (while keeping a 3-node multi-AZ floor for durability) signals seasoned engineering judgment over reflexively proposing a 40-node cluster for a workload three tuned hosts handle easily.
Sources: Linux io_uring Reference · Cloudflare XDP Packet Drops · Meta Katran L4 Load Balancer
Apply
Your turn
The task this lesson builds to.
Propose a single-node optimization plan for a Linux message-broker and edge-proxy host currently maxing out 32 cores at 120K req/sec due to syscall overhead, buffer copies, and mutex contention before buying more servers.
Think about
- Which Linux I/O interface reduces syscall transitions for both network and NVMe disk traffic?
- How do zero-copy transfers keep high-bandwidth payloads out of user-space memory?
- How do XDP/eBPF and thread-per-core eliminate packet-stack and lock ceilings?
Draft your design answer here Save your draft, compare against the model answer, and track progress.
Practice
Make it stick
A second problem on the same idea, so it survives past today.
Compare scaling a streaming log broker vertically with io_uring, sendfile, and thread-per-core against horizontally scaling across 20 smaller VMs, and specify when adding machines becomes unavoidable.
Think about
- What operational and tail-latency advantages come from running 3 dense tuned hosts instead of 20?
- Which hard limits (fault domains, NIC bandwidth, storage capacity) still force horizontal scale-out?
- How do you preserve high availability when consolidating onto fewer physical nodes?
Draft your design answer here Save your draft, compare against the model answer, and track progress.