Hosting
Servers
Pricing
Resources
Get started → Log in
Home/Blog/Improve VPS performance

How to improve VPS performance
and speed up a slow server.

24 November 20267 min readBy the RapidServer team

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.

CommandLook atIt means trouble when
top or htopLoad average, %CPU per processLoad stays above your number of vCPUs
topst (steal time)It stays above a few percent: the host's CPU is oversold
free -mThe available column, swap usedAvailable memory is near zero and swap keeps growing
vmstat 1si/so, wa, rConstant swapping, high I/O wait, or a long run queue
iostat -x 1%util, r_await, w_awaitThe disk is near 100% busy or each request waits long
df -hUse%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 -k for 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. Set vm.swappiness=10 so 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_children to 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_consumption of 128 MB or more and opcache.max_accelerated_files above 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 maxmemory and maxmemory-policy allkeys-lru so Redis cannot eat all the RAM.
  • Browser cache. Send long Cache-Control headers for images, CSS and JavaScript.

Database tuning basics

  • Find slow queries. In MySQL or MariaDB set slow_query_log = 1 and long_query_time = 1; in PostgreSQL set log_min_duration_statement = 1000.
  • Add indexes. Run EXPLAIN on each slow query and index the columns it filters, joins or sorts on.
  • Size the buffer pool. innodb_buffer_pool_size should 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's shared_buffers usually 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.

Hardware that is worth tuning.

Dedicated vCPU, 100% NVMe and a 10 Gbps uplink in Mumbai or Delhi, with resizing from the client area.

See VPS hosting plans

Updates and data center location

  • Update. Run apt upgrade or dnf upgrade regularly. 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?+
Usually for one of four reasons: too little RAM so the server swaps, busy CPU (or steal time on an oversold host), a slow or full disk, or the app itself, such as no caching or missing database indexes. Check top, free -m and iostat to see which.
What is CPU steal time on a VPS?+
Steal time is the share of time your virtual CPU waited because the physical CPU was busy with other virtual machines. It shows as st in top. If it stays high, the host is overselling CPU. Dedicated vCPU keeps it near zero.
Does more RAM make a VPS faster?+
Only when RAM is the bottleneck: the server is swapping, or the database cannot keep its working data in memory. If the CPU is the limit, more RAM will not help.
Is swap bad on a VPS?+
No. A small swap file stops crashes during short spikes. Constant swapping is the problem: the server needs more RAM or smaller worker pools.
Will a CDN make my VPS faster?+
It speeds up images, CSS and JavaScript, especially for visitors far from the server, and it reduces load on the VPS. Slow dynamic pages need server-side fixes: caching, PHP-FPM sizing and database indexes.

Tuned and still at the limit?

Move up to more dedicated vCPU, RAM and NVMe from the client area, in Mumbai or Delhi, with the difference prorated.