← Back to labs

Linux Kernel Tuning for High-Throughput

LinuxPerformanceKernel

Summary

A database server started dropping connections during peak hours (~5000 concurrent connections), suspected to be default kernel limits (somaxconn, file descriptors) rather than the application, so sysctl and kernel parameter tuning were carried out.

System Context

  • Server: Ubuntu 22.04, 16 core / 64GB RAM, running PostgreSQL + connection pooler
  • Symptom: connection refused above ~4500 concurrent connections during peak hours
  • Benchmarked before/after with pgbench using the same load scenario

Checklist

  • Ran a pgbench baseline before changing any sysctl values
  • Applied one change at a time and re-measured to isolate what actually helped
  • Confirmed no more connection refused errors at 5000 concurrent load
  • Persisted every changed sysctl value to config (survives reboot)

Commands

Step 1
sysctl -w net.core.somaxconn=65535
Step 2
sysctl -w net.ipv4.tcp_max_syn_backlog=65535
Step 3
sysctl -w vm.swappiness=10
Step 4
sysctl -w fs.file-max=2097152
Step 5
echo 'net.core.default_qdisc=fq' >> /etc/sysctl.conf

Conclusion

Kernel tuning provides measurable improvements for network-intensive workloads. Always benchmark before and after changes. Document all modifications — kernel updates can reset sysctl values.