Docs / Performance Optimization / Linux Kernel Tuning for High-Traffic Servers

Linux Kernel Tuning for High-Traffic Servers

By Admin · Feb 25, 2026 · Updated Apr 25, 2026 · 138 views · 1 min read

Network Stack Tuning

Edit /etc/sysctl.conf:

# Increase connection backlog
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 65535

# TCP buffer sizes
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 87380 16777216

# TCP connection handling
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_keepalive_probes = 5

# Allow more local ports
net.ipv4.ip_local_port_range = 1024 65535
sudo sysctl -p

File Descriptor Limits

Edit /etc/security/limits.conf:

* soft nofile 65535
* hard nofile 65535
root soft nofile 65535
root hard nofile 65535

Systemd Service Limits

# For specific services like Nginx
[Service]
LimitNOFILE=65535

Virtual Memory

# Reduce swappiness for servers
vm.swappiness = 10

# Increase file inotify watches (for apps watching many files)
fs.inotify.max_user_watches = 524288

# Increase maximum open files system-wide
fs.file-max = 2097152

Verify Settings

# Check current limits
ulimit -n
cat /proc/sys/net/core/somaxconn
sysctl net.ipv4.tcp_fin_timeout

When to Tune

  • "Too many open files" errors
  • Connection timeouts under high load
  • SYN flood protection needed
  • High-traffic web servers (10,000+ concurrent connections)

Was this article helpful?