The short answer
To improve VPS performance, measure before you change anything. Find out whether the server is short of CPU, RAM, disk speed or network, then fix that one bottleneck. Most slow servers are fixed by enough RAM with a small swap file, a correctly sized PHP-FPM or app worker pool, OPcache and a page cache, Redis for object caching, a few database indexes and a CDN for static files. If the VPS is still at its limit after that, resize it.
Measure first
Run these over SSH while the site is slow, and note the numbers.
| Command | Look at | It means trouble when |
|---|---|---|
top or htop | Load average, %CPU per process | Load stays above your number of vCPUs |
top | st (steal time) | It stays above a few percent: the host's CPU is oversold |
free -m | The available column, swap used | Available memory is near zero and swap keeps growing |
vmstat 1 | si/so, wa, r | Constant swapping, high I/O wait, or a long run queue |
iostat -x 1 | %util, r_await, w_await | The disk is near 100% busy or each request waits long |
df -h | Use% | A disk above about 90% full |
iostat is in the sysstat package. Also time the site from outside: curl -o /dev/null -s -w '%{time_starttransfer}\n' https://example.com/ prints the time to first byte. If that number is high while CPU, RAM and disk look calm, the slowness is in the app or the database.
Fix RAM and swap
- Find what uses memory with
ps aux --sort=-rss | head. Usually it is PHP-FPM workers, the database or a Node.js process. - Check
journalctl -kfor Out of memory lines. If the kernel killed MySQL, the server needs more RAM or smaller pools. - Add a 1 to 2 GB swap file as a safety net:
dd if=/dev/zero of=/swapfile bs=1M count=2048,chmod 600 /swapfile,mkswap /swapfile,swapon /swapfile, then add it to/etc/fstab. Setvm.swappiness=10so it is used only under pressure.
Swap stops crashes during spikes. It is not extra RAM: if the server swaps all day, it needs more memory.
Web server, PHP-FPM and OPcache
- Web server. Nginx and LiteSpeed handle many connections with little memory. On Apache, use the event MPM with PHP-FPM, not prefork with mod_php. Turn on HTTP/2 and gzip or Brotli.
- PHP-FPM. Set
pm.max_childrento the RAM you can give PHP divided by the average size of one PHP process. Too high and the server swaps; too low and requests queue, which the FPM log reports as server reached pm.max_children. - OPcache. Keep it on, with
opcache.memory_consumptionof 128 MB or more andopcache.max_accelerated_filesabove your number of PHP files. Use a current PHP version such as 8.3. - Node.js and Python. Run one worker per vCPU or more: PM2 cluster mode for Node.js, several Gunicorn or Uvicorn workers for Python. Watch memory as you add them.
Caching
- Page cache. A full-page cache serves ready HTML without running PHP or the database. On LiteSpeed use LSCache; on Nginx use FastCGI cache or a cache plugin. Never cache carts, checkout or logged-in pages.
- Object cache. Redis keeps query results and sessions in memory. WordPress uses it through an object cache plugin, and Laravel has a Redis cache driver. Set
maxmemoryandmaxmemory-policy allkeys-lruso Redis cannot eat all the RAM. - Browser cache. Send long
Cache-Controlheaders for images, CSS and JavaScript.
Database tuning basics
- Find slow queries. In MySQL or MariaDB set
slow_query_log = 1andlong_query_time = 1; in PostgreSQL setlog_min_duration_statement = 1000. - Add indexes. Run
EXPLAINon each slow query and index the columns it filters, joins or sorts on. - Size the buffer pool.
innodb_buffer_pool_sizeshould hold your active data. On a server that only runs the database, 50 to 70% of RAM is common; when the web server and PHP share the VPS, give it less. PostgreSQL'sshared_buffersusually starts at about 25% of RAM. Databases also gain most from fast disks; see NVMe vs SSD. - Clean up old WordPress revisions, expired transients and stale sessions. MySQLTuner can suggest settings after a few days of traffic.
Static files and a CDN
Resize and compress images, serve WebP or AVIF, and lazy-load images below the fold. A CDN caches images, CSS and JavaScript near your visitors and takes that load off the VPS. It helps most when visitors are far away or pages are heavy with media. For visitors in India, a server in Mumbai or Delhi is already close, so the CDN mainly saves CPU and bandwidth.
Dedicated vCPU, 100% NVMe and a 10 Gbps uplink in Mumbai or Delhi, with resizing from the client area.
See VPS hosting plansUpdates and data center location
- Update. Run
apt upgradeordnf upgraderegularly. New kernels, PHP, database and Node.js releases bring speed fixes as well as security patches. Take a snapshot first, and reboot after kernel updates. - Check for abuse. An unknown process at 100% CPU can be a crypto miner after a break-in.
- Choose the closer city. Latency is added to every request. Pick Mumbai for western and southern India, where Mumbai and Pune see 1 to 4 ms, or Delhi for the north, with 1 to 8 ms across Delhi NCR. Our team moves a VPS between the two for free.
When to resize instead of tuning
Tuning has limits. Resize when, after caching and the fixes above:
- CPU stays near 100% at normal traffic, not just during a sale.
- Available RAM is still low with PHP-FPM and the database sized sensibly.
- The disk is filling up, or your data no longer fits in the buffer pool.
- Another day of tuning costs more than the next plan.
On a RapidServer VPS you move between plans from the client area, with the difference prorated. CPU and RAM changes apply after a reboot, and the disk grows in place. With dedicated vCPU, extra cores are real extra capacity. You can also move the database to a second VPS in the same region over free private networking. To pick the next size, see how much VPS you need.
Keep monitoring
- The client area shows CPU, memory, disk I/O and bandwidth graphs for every server.
- For history per process, install Netdata, or Prometheus node_exporter with Grafana.
- Use an external monitor for uptime and response time, as explained in uptime meaning.
Questions
Why is my VPS so slow?+
top, free -m and iostat to see which.What is CPU steal time on a VPS?+
st in top. If it stays high, the host is overselling CPU. Dedicated vCPU keeps it near zero.