Operations 7 min read

How Many TCP Connections Can One Server Really Handle? A Deep Dive into Linux Limits

This article demystifies common misconceptions about server concurrency, explains the theoretical maximum TCP connections based on the four‑tuple, details Linux file‑descriptor and buffer limits, and walks through a practical experiment that achieves over one million simultaneous connections on a single machine.

ITPUB
ITPUB
ITPUB
How Many TCP Connections Can One Server Really Handle? A Deep Dive into Linux Limits

TCP Four‑Tuple Theoretical Limit

TCP connections are identified by a four‑tuple: source IP, source port, destination IP, and destination port. With a fixed server IP and port (e.g., Nginx on port 80), the variable elements are source IP and source port, giving a theoretical maximum of 2³² × 2¹⁶ ≈ 2.8 × 10¹⁴ possible connections.
TCP four‑tuple illustration
TCP four‑tuple illustration

Linux File‑Descriptor Limits

Each opened file (including sockets) consumes kernel memory. Linux enforces limits on the number of open file descriptors at three levels:

System‑wide limit: configurable via fs.file-max User‑level limit: set in /etc/security/limits.conf Process‑level limit: configurable via

fs.nr_open
File descriptor limits
File descriptor limits

Socket Buffer Settings

The receive buffer size can be inspected and tuned with sysctl . The first value in net.ipv4.tcp_rmem is the minimum per‑socket receive buffer (default 4 KB), the third value is the maximum (default 8 MB).
$ sysctl -a | grep rmem
net.ipv4.tcp_rmem = 4096 87380 8388608
net.core.rmem_default = 212992
net.core.rmem_max = 8388608
Receive buffer values
Receive buffer values
The send buffer size is controlled by net.ipv4.tcp_wmem . The first value is the minimum send buffer (default 4 KB), and the third value is the maximum (default 8 MB).
$ sysctl -a | grep wmem
net.ipv4.tcp_wmem = 4096 65536 8388608
net.core.wmem_default = 212992
net.core.wmem_max = 8388608
Send buffer values
Send buffer values

Achieving One Million Concurrent Connections

To reach 1 000 000 connections, the file‑descriptor limits were raised to 1.1 million at system, user, and process levels, leaving enough descriptors for auxiliary commands (e.g., ps , vi ).
$ ss -n | grep ESTAB | wc -l
1000024

The test machine had 3.9 GB RAM; the kernel slab consumed about 3.2 GB, leaving roughly 100 MB for other uses.

$ cat /proc/meminfo
MemTotal:        3922956 kB
MemFree:           96652 kB
MemAvailable:      6448 kB
Buffers:           44396 kB
Slab:           3241244 kB
Using slabtop , the kernel objects densty , flip , sock_inode_cache , and TCP each showed roughly one million entries, confirming the connection count.
slabtop output
slabtop output
slabtop output
slabtop output

Conclusion

Understanding the TCP four‑tuple, Linux file‑descriptor limits, and socket buffer parameters allows a server to sustain well over a million simultaneous TCP connections on modest hardware when the limits are tuned appropriately.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

performanceconcurrencyTCPLinuxsysctlfile-descriptorsserver limits
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.