VDS Performance Tuning: Sysctl, I/O Scheduling, and PHP-FPM Optimization
Operating a VDS (Virtual Dedicated Server) provides the freedom of dedicated resources, but those resources must be tuned to handle specific workloads efficiently. This guide explores the technical parameters that govern server performance.
1. Kernel Parameter Tuning (sysctl.conf)
The default Linux kernel settings are designed for general-purpose use. For a high-traffic web server, you should adjust the network stack to handle more concurrent connections.
# Increase the maximum number of open files
fs.file-max = 2097152
# Increase the max number of connections in the queue
net.core.somaxconn = 65535
# Fast recycle of TIME_WAIT sockets
net.ipv4.tcp_tw_reuse = 1
2. I/O Scheduler Selection
Depending on the underlying storage (SSD/NVMe), selecting the right I/O scheduler can reduce latency.
- For NVMe:
noneormq-deadline. - For SSD:
deadline.
You can check your current scheduler with cat /sys/block/sda/queue/scheduler.
3. PHP-FPM Optimization for High Throughput
For PHP-based applications (Laravel, WordPress), the default PHP-FPM configuration is often inadequate.
- pm = static: Recommended for servers with sufficient RAM to avoid the overhead of spawning new processes.
- pm.max_children: Calculate this based on your available RAM divided by the average memory usage per PHP process (~30-50MB).
4. Nginx Worker Processes
Align your Nginx worker processes with your VDS CPU core count.
worker_processes auto;worker_connections 2048;(Increase from the default 768 or 1024).
5. Bytecode Caching (OPcache)
Always ensure OPcache is enabled. It stores precompiled script bytecode in memory, eliminating the need for PHP to load and parse scripts on each request.
Fine-tuning these parameters transforms a standard server into a high-performance VDS environment capable of handling thousands of concurrent users with minimal latency.
Was this insightful?
Don't miss our upcoming deep dives and free tools.