Course contentsShow
← Linux
Lesson 1255 of 1,81910. Network Administration and Kernel StacksFree lesson

Scaling Networking to Thousands of Cores

Design network architectures that avoid locking contention at the kernel level.

In this lesson, you will learn how to design network architectures that bypass the global kernel locking mechanisms that cripple performance when scaling to thousands of CPU cores.

The Bottleneck: Global Locks

In a standard Linux kernel, many networking structures—such as the routing table or the connection tracking table—are protected by global spinlocks. When you scale to hundreds or thousands of cores, every core attempts to acquire these same locks simultaneously, leading to "lock contention." Instead of processing packets, your cores spend their cycles waiting for access to memory, causing the system to grind to a halt despite having massive raw compute power.

Designing for Lockless Execution

To scale to thousands of cores, we must move away from shared, global state and toward per-core data structures. By partitioning the workload, we ensure that each CPU core interacts only with its own local memory for networking tasks, eliminating the need for expensive inter-core synchronization.

Implementing Receive Side Scaling (RSS) and Flow Steering

The foundation of this architecture is Receive Side Scaling (RSS) combined with Receive Flow Steering (RFS). By mapping specific network flows to specific cores at the hardware level (NIC queues), we ensure that a single flow is always processed by the same CPU.

If your application architecture respects these boundaries, you can effectively run an independent "mini-stack" on every core. You can achieve this by pinning application threads to specific cores that handle corresponding NIC queues:

# Pinning a process to core 0 and matching it to a NIC queue
# This prevents cross-core cache invalidation
taskset -c 0 ./network_app --queue-id 0

Avoiding Shared State

When designing high-scale services, avoid shared objects. If you must use global configuration, use Read-Copy-Update (RCU) mechanisms. RCU allows your cores to read networking configurations (like routing rules) without ever needing to acquire a lock, as writers create a new version of the structure rather than modifying the existing one in place. This allows thousands of cores to read simultaneously while only incurring a cost during configuration updates.

Key Takeaway: Scaling to thousands of cores requires shifting from global synchronized structures to per-core local data paths, ensuring that no core ever stalls waiting for another to release a lock.