C10k problem

Also known as: C10K

On this page 7

The C10k problem is the engineering challenge of making a single server handle ten thousand concurrent client connections at the same time without running out of memory, CPU time or kernel resources. The name, often written C10K, was coined in 1999 when typical web servers collapsed far below that figure, and it became a landmark question in server performance for the design of network software.

The problem was never about raw bandwidth. It exposed how the one-thread-per-connection model and early operating system interfaces scaled badly as the number of open sockets grew. Its solutions, event-driven I/O and scalable kernel notification, now underpin every major web server, proxy and runtime, and the same reasoning applies to its modern successors such as the C10M challenge.

Why ten thousand connections overwhelmed servers

Early servers broke down at high concurrency because each connection consumed a dedicated thread or process. A thread needs its own stack, often 1 to 8 MB of reserved virtual memory, and the scheduler must switch between thousands of them. With ten thousand mostly idle clients, the server spent more time on context switching and memory management than on useful work.

The kernel interfaces of the time made matters worse. The select() and poll() system calls required the application to pass the entire list of sockets on every call, and the kernel scanned that list each time. Their cost grows linearly with the number of connections, so an O(n) readiness check repeated thousands of times per second consumed the processor even when only a few sockets had data.

Other limits added friction: the per-process file descriptor limit, often 1,024 by default, the fixed size of the select() descriptor set, and accept queue overflows under connection bursts. Solving the C10k problem required changes in both the application architecture and the operating system.

Server architectures and how they scale

Server designs differ mainly in how they map connections to execution units. The table below compares the main models and their behavior with many concurrent connections.

ModelHow it worksBehavior at 10,000 connections
Process per connectionForks a process for each clientHeavy memory use, slow creation
Thread per connectionSpawns or reuses a thread per clientStack memory and context switch overhead
Event loopOne thread multiplexes many socketsEfficient while handlers do not block
Multiple event loopsOne loop per CPU coreScales across cores with low overhead
Asynchronous runtimeCoroutines or green threads on event loopsReadable code with event-loop efficiency
Connection handling models and their scaling behavior

The winning pattern is non-blocking sockets with an event loop. The server keeps all connections open, asks the kernel which ones are ready, and runs a short handler only for those. Idle connections then cost only a small amount of memory for socket buffers and connection state, often a few kilobytes each, instead of a whole thread.

Kernel interfaces that solved the C10k problem

The breakthrough came from readiness notification with constant cost per event. Instead of rescanning every socket, the application registers interest once and the kernel returns only the sockets that changed state. Each major operating system developed its own interface.

InterfacePlatformCost per wait callNotes
selectPortableO(n) in watched socketsDescriptor set usually capped at 1,024
pollPortableO(n) in watched socketsNo fixed cap but still linear
epollLinuxO(ready events)Edge-triggered or level-triggered modes
kqueueFreeBSD, macOSO(ready events)Also covers files, signals and timers
IOCPWindowsO(completed operations)Completion-based rather than readiness-based
io_uringLinux 5.1 and laterBatched submissionsShared rings reduce system calls
I/O notification interfaces by operating system

On Linux, epoll became the standard foundation for servers such as Nginx, HAProxy and the Node.js runtime. The newer io_uring interface goes further by letting applications submit and complete I/O through shared memory rings, which cuts system call overhead at very high request rates.

Tuning a server for many concurrent connections

Event-driven software solves the core of the C10k problem, but operating system limits must also be raised. Default settings are conservative and can silently cap concurrency long before CPU or memory run out.

SettingWhat it limitsTypical adjustment
nofile limitOpen file descriptors per processRaise from 1,024 to 100,000 or more
fs.file-maxFile descriptors system-wideRaise to match expected load
net.core.somaxconnListen backlog lengthIncrease to several thousand
ip_local_port_rangeOutgoing ports for proxiesWiden the ephemeral port range
TCP buffer sizesMemory per connectionBalance throughput against memory use
Linux settings commonly adjusted for high concurrency

Application settings matter just as much. Web servers expose a worker connections limit, reverse proxies need enough upstream connections, and HTTP keep-alive timeouts decide how long idle clients occupy a slot. A load test with tools such as Apache JMeter or k6 should confirm that the server reaches the target number of concurrent connections with stable tail latency.

Common misconceptions and remaining limits

Solving the C10k problem means holding many connections cheaply, not serving unlimited traffic. Several misunderstandings appear repeatedly in capacity planning.

  • Concurrency is not throughput. Ten thousand idle WebSocket clients are easy; ten thousand clients each requesting heavy pages per second are a different problem.
  • One blocking call stalls an event loop. Synchronous disk access or a slow database query inside a handler delays every other connection on that loop.
  • Thread pools still have a role. CPU-heavy work, such as PHP worker pool processing, is usually offloaded from the event loop to a bounded pool.
  • The bottleneck moves. After connection handling is efficient, limits shift to the database, memory bandwidth or the network interface.

Hardware progress has moved the benchmark. Well-tuned servers now hold hundreds of thousands or millions of connections, which led to the informal C10M problem, where kernel bypass techniques and careful memory layout become necessary. The original lesson remains: avoid per-connection overhead and let the operating system report only what is ready.

In simple terms

Imagine a restaurant that assigns one waiter to every table, even when guests are only reading the menu. With ten tables this works, but with ten thousand tables the restaurant would need ten thousand waiters who mostly stand around and get in each other’s way.

The C10k problem was this situation for web servers. The solution was to let a few attentive waiters watch the whole room and walk over only when a guest raises a hand. Servers now work the same way, so one machine can keep thousands of visitors connected without wasting effort on those who are simply waiting.

A practical example

An online news site expects a surge of readers during an election night, with a live results page that keeps a long-lived connection open for each visitor to push updates. The existing setup used a thread-per-connection application server that became unstable at about 3,000 simultaneous visitors, with memory exhausted by thread stacks.

The operations team placed an epoll-based reverse proxy in front of the application, moved the live updates to an event-driven service, raised the file descriptor limit to 200,000 and increased the listen backlog. A load test with k6 simulated 25,000 concurrent clients. On election night the service held about 18,000 concurrent connections on two modest virtual machines, with CPU use below 40 percent and stable response times.