Tuning Linux Kernel Parameters for Better VPS Performance
1 Comment on Tuning Linux Kernel Parameters for Better VPS Performance
When your VPS starts feeling sluggish, the first instinct is often to throw more CPU or RAM at it. Sometimes that is the right call, but very often, you can squeeze out significant performance gains just by tuning how the Linux kernel behaves. Kernel parameters control everything from memory management to networking, and with the right tweaks, your server can feel noticeably faster and more stable under load.

In this guide, we will walk through practical, safe kernel tuning techniques that actually make sense for VPS environments.
Why Kernel Tuning Matters on a VPS
Unlike bare metal, a VPS operates with shared physical resources, fixed CPU and memory limits, and strict I/O constraints.
Kernel defaults are designed to be generic, not optimal for every workload. A web server, mail server, or database-heavy VPS all have very different needs. Kernel tuning helps you:
- Reduce latency.
- Improve throughput.
- Prevent memory exhaustion.
- Handle traffic spikes gracefully.
How to Apply Kernel Changes Safely
Most kernel parameters are adjusted using sysctl.
Temporary change (resets on reboot):
sysctl -w net.core.somaxconn=65535
Persistent change:
Edit /etc/sysctl.conf or create a custom file in /etc/sysctl.d/99-custom.conf.
Apply changes immediately with:
sysctl -p
Memory Management Tuning
1. Swappiness
Controls how aggressively the kernel uses swap.
vm.swappiness = 10
Why it helps: Lower swappiness keeps active processes in RAM, reducing disk I/O latency, which is especially important for web and database servers.
2. File System Cache Pressure
vm.vfs_cache_pressure = 50
Why it helps: Allows inode and dentry caches to stay in memory longer, improving file access speed.
3. Dirty Page Writeback
vm.dirty_background_ratio = 5
vm.dirty_ratio = 15
Why it helps: Prevents sudden I/O spikes by flushing data to disk more gradually.
Networking Performance Tuning
This is where VPS performance tuning really shines, especially for high-traffic sites and APIs.
1. Increase Connection Backlog
net.core.somaxconn = 65535
net.ipv4.tcp_max_syn_backlog = 8192
Why it helps: Handles more simultaneous incoming connections without dropping requests.
2. Enable TCP Fast Open
net.ipv4.tcp_fastopen = 3
Why it helps: Reduces latency for repeat connections by sending data during the initial handshake.
3. Optimize TCP Buffers
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
This improves throughput for high-bandwidth or high-latency connections.
4. Reduce TIME_WAIT Overhead
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_tw_reuse = 1
It prevents socket exhaustion on busy servers handling many short-lived connections.
CPU Scheduling and Process Limits
1. Increase Open File Limits
Kernel:
fs.file-max = 2097152
User limits (/etc/security/limits.conf):
* soft nofile 1048576
* hard nofile 1048576
This is critical for web servers, mail servers, and reverse proxies.
2. Scheduler Migration Cost
kernel.sched_migration_cost_ns = 5000000
This reduces unnecessary task migrations between CPUs, improving cache locality.
Disk I/O Optimization (VPS-Friendly)
1. Reduce I/O Latency
vm.dirty_expire_centisecs = 3000
vm.dirty_writeback_centisecs = 500
Balances write performance without overwhelming shared storage.
2. Choose the Right I/O Scheduler
Check the current scheduler:
cat /sys/block/vda/queue/scheduler
Recommended for VPS:
mq-deadlinenone(for NVMe-backed storage)
Conclusion
Tuning Linux kernel parameters is one of the most overlooked yet impactful ways to improve VPS performance. Without adding a single CPU core or extra gigabyte of RAM, the right adjustments can significantly reduce latency, improve throughput, and make your server far more resilient under real-world load.
That said, kernel tuning is not about blindly maximizing values. Every VPS runs within defined resource limits, and aggressive settings can sometimes do more harm than good. The real gains come from understanding your workload—whether it is a busy web server, a mail system, or a database-driven application—and aligning kernel behavior to support it efficiently.
Start small, apply changes incrementally, and always measure the results. Combined with proper monitoring and sensible application-level optimizations, kernel tuning can help you extract the best possible performance from your VPS and delay costly infrastructure upgrades.
📺 Watch the Video Tutorial on RackNerdTV
If you are optimizing network buffers and connections, setting up a secure VPN is a great next step. Check out our guide on installing WireGuard VPN on Ubuntu via the RackNerdTV YouTube channel:
At RackNerd, you can deploy a Linux VPS with full root access, giving you the complete freedom to modify sysctl parameters and tune your kernel exactly how you want it. If you prefer a managed, out-of-the-box optimized environment, explore our shared web hosting plans.
👉 Visit https://racknerd.com to learn more about our high-performance hosting solutions today.
Leave a comment
Leave a comment