
Core takeaway
- Measure first: find the one thing limiting performance, fix that, then measure again.
- Work through it in order: measure the slowness, check the server’s vital signs, then CPU, memory, disk, the host, the application, and finally what is outside the server.
- A bigger plan is not a diagnosis: a plugin that runs 200 database queries on every page just runs them faster on a bigger server, at a higher monthly price.
- Change one thing at a time.
Disclosure: con1ainer.com participates in affiliate programs. This article contains no affiliate links. See the Affiliate & Commercial Disclosure.
The 15-second version: measure first, then fix the one bottleneck.
“My VPS is slow” is a complaint, not a diagnosis.
A website can feel slow because the server is overloaded, because PHP is waiting on a badly written database query, because images are 4 MB each, because a visitor is on the other side of the planet, or because a script from a third-party service is taking five seconds to answer. Only some of those are the VPS’s fault, and only some of those are fixed by paying for a bigger plan.
The usual reaction is to upgrade. It feels like action, and sometimes it even helps for a week. But if the real cause is a plugin that runs 200 database queries on every page, a bigger server just runs the same 200 queries a little faster, at a higher monthly price.
This guide takes a different approach: measure first, find the one thing limiting performance, fix that, and measure again. Every term is explained as it appears, and every command can be run on a normal Linux VPS.
What a Bottleneck Is
A bottleneck is the single resource that limits how fast everything else can go. Picture a highway that narrows from four lanes to one. It does not matter how fast the cars are or how wide the road is on either side. Traffic moves at the speed of the narrow point.
A server has a handful of places where that narrow point can sit:
| Resource | What it does | What it looks like when it is the bottleneck |
|---|---|---|
| CPU | Runs programs | Everything slows during busy periods. Load stays high |
| Memory (RAM) | Holds running programs and their data | The server starts using swap, and processes get killed |
| Disk | Reads and writes files and database data | Programs spend time waiting, not working |
| Network | Moves data to and from visitors | Large downloads crawl while the CPU sits idle |
| Application | Your code, such as WordPress, plugins, and database queries | The server looks calm, yet pages are still slow |
| Outside the server | Distance, DNS, third-party scripts, and heavy images | The server answers fast, but the page loads slowly in the browser |
The last two rows are why “the VPS is slow” is often wrong. The rest of this guide helps you work through the list in order.
Step 1: Measure the Slowness
Without a number, you cannot tell whether a change helped. Start by measuring how long the server takes to respond.
Run this on your own computer, not on the server, so that the result includes the network trip a visitor would make:
curl -o /dev/null -s -w 'DNS lookup: %{time_namelookup}s\nConnect: %{time_connect}s\nTLS: %{time_appconnect}s\nFirst byte: %{time_starttransfer}s\nTotal: %{time_total}s\n' https://example.com/
The command requests your homepage, throws the content away, and prints a timing breakdown. Each line is cumulative, meaning it includes the time before it:
| Line | What it measures |
|---|---|
| DNS lookup | Finding your server’s IP address from your domain name |
| Connect | Opening a network connection to the server. Grows with distance |
| TLS | Setting up the HTTPS encryption |
| First byte | When the first piece of the page arrives. This is the server’s thinking time, known as Time To First Byte (TTFB) |
| Total | When the whole page has been received |
TTFB is the number that tells you about your server. Web performance guidance commonly treats a TTFB under about 800 milliseconds as good and over 1.8 seconds as poor. Because this number is the time between your request and the server starting to answer, it reflects the server and the application, not the weight of your images.
Run the command five times and write down the results. Then run it once more at your busiest time of day. A server that responds in 300 ms at 3 a.m. and 4 seconds at 2 p.m. has a load problem. A server that is slow at every hour has an efficiency problem.
Now interpret the result:
| What you see | What it suggests |
|---|---|
| TTFB is low (under 800 ms) but the page feels slow in the browser | The VPS is not the problem. Look at images, scripts, and third-party services (Step 8) |
| Connect time is high (over 150 ms) and everything else is proportionally slow | Distance between visitor and server. Consider a content delivery network (Step 7) |
| TTFB is high on every request, at every hour | The application is doing too much work per page (Steps 5 and 6) |
| TTFB is fine most of the time but terrible during busy periods | A resource limit is hit under load (Steps 3 and 4) |
Step 2: Check the Server’s Vital Signs
Connect over SSH while the slowness is happening, because a calm server will show you nothing. Run these four commands:
uptime
free -h
df -h
vmstat 1 5
The first three are explained in detail in How to Monitor a VPS: Uptime, Resources, and Alerts, including what counts as healthy. The fourth is new. vmstat 1 5 prints one line of statistics every second, five times. Ignore the first line, because it is an average since boot. The columns that matter:
| Column | Meaning | Worrying when |
|---|---|---|
r | Programs running or waiting for a CPU core | Consistently higher than your number of cores |
si and so | Memory moved from swap to RAM, and from RAM to swap, per second | Both repeatedly above zero. The server is short of memory |
wa | Percentage of time the CPU waits for the disk | Above about 10 to 20 percent for long periods |
st | Percentage of CPU time taken by the host for other customers | Above about 5 percent for long periods |
us and sy | Percentage of CPU time running programs and the system itself | Combined near 100 percent |
Now use this table to pick where to look next:
| Pattern | Likely bottleneck | Go to |
|---|---|---|
us and sy high, load above core count | CPU | Step 3 |
Available memory low, swap in use, si or so above zero | Memory | Step 4 |
wa high, CPU otherwise idle | Disk | Step 5 |
st high | The host is overloaded | Step 6 |
| Everything above looks calm, yet TTFB is high | Application | Step 7 |
Step 3: If the CPU Is the Problem
Find out which program is using it:
ps aux --sort=-%cpu | head -n 6
The first column is the user, and the last is the command. On a WordPress server, the usual culprits are:
- PHP-FPM workers. Each visitor request runs PHP code on a CPU core. Pages that are not cached recompute everything on every visit.
- Bots and crawlers. Automated visitors can generate more requests than your real readers.
- Scheduled jobs. Backups that compress files, or search indexing, can use a full core for minutes.
- Compromised software. A hacked site running a hidden mining or spamming program shows up as an unfamiliar process using constant CPU.
Check whether bots are behind it by counting requests by address and by browser label in the Nginx access log:
sudo awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head
sudo awk -F'"' '{print $6}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head
The first command counts requests per IP address. The second counts them per user agent, which is the label a browser or bot gives itself. If one address or one bot name accounts for a huge share, you have found a candidate. If your site sits behind a service such as Cloudflare, the first column shows that service’s addresses instead of the visitors’.
Fixes, in order from cheapest:
- Turn on page caching. Caching saves a finished copy of each page and serves it without running PHP. This is the single biggest improvement for most WordPress sites, often cutting CPU use by a large factor.
- Block or rate-limit abusive bots. Limit how many requests per second one address may make, or block it.
- Remove what you do not need. Deactivate and delete unused plugins.
- Move heavy scheduled jobs to hours when nobody is visiting.
- Add CPU cores, only after the steps above, and only if the measurements still show a CPU limit.
If a process you do not recognize is eating the CPU, treat it as a security incident, not a performance problem. Read How to Secure a VPS: Essential Setup Checklist.
Step 4: If Memory Is the Problem
When RAM runs out, the system first pushes data to swap, which is thousands of times slower than memory. If swap fills too, Linux kills a program to survive, and that program is often your database.
Check whether it has already happened:
sudo journalctl -k | grep -i "out of memory"
Any result means the server ran out of RAM at least once.
Size PHP to your memory
The most common cause on WordPress servers is PHP-FPM, the program that runs PHP, being allowed to start more workers than the RAM can hold. Each worker is a separate process, and the setting pm.max_children caps how many exist at once. Too high, and a traffic spike starts more workers than memory exists. Too low, and visitors wait in line.
Measure how much memory one worker uses on average. Replace 8.3 with your PHP version:
ps --no-headers -o rss -C php-fpm8.3 | awk '{sum+=$1; n++} END {printf "%d MB average\n", sum/n/1024}'
rss is the memory a process currently holds in RAM, in kilobytes. The command averages it across all workers and prints megabytes.
Now do the arithmetic. As an example, take a 2 GB server. Reserve about 700 MB for the operating system, Nginx, and MariaDB. That leaves roughly 1,300 MB for PHP. If the average worker is 60 MB, then 1,300 ÷ 60 is about 21, so set the limit slightly lower, at 18 to 20, to leave headroom. Edit the pool file:
sudo nano /etc/php/8.3/fpm/pool.d/www.conf
Find the line beginning pm.max_children and set your number, then restart PHP:
sudo systemctl restart php8.3-fpm
These figures are an example. Use your own measured averages. For the reasoning behind how much memory different workloads need, read How Much RAM Does a Web Server Need?
Add a swap file as a safety net
If your server has no swap at all, a short memory spike goes straight to a killed program. A small swap file gives a cushion. It is a cushion, not a cure, because a server that lives in swap is a slow server.
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
The commands create a 2 GB file, restrict access to the owner, format it as swap, switch it on, and register it so it returns after a reboot. Confirm with free -h.
If measurements show you still run out of memory after tuning PHP and caching pages, the answer is more RAM.
Step 5: If the Disk Is the Problem
Disk trouble shows up as a high wa value while the CPU itself is idle. The processor is ready to work, but the data it needs has not arrived yet.
Install the tool that measures it:
sudo apt install sysstat
iostat -x 1 5
Two columns matter. %util is how busy the disk is, where values near 100 mean it is saturated. await is the average wait, in milliseconds, for a read or write to complete. A busy database disk with waits of tens or hundreds of milliseconds is a real problem.
To see which program is causing it:
sudo apt install iotop
sudo iotop -o
The -o option shows only programs actually reading or writing right now.
Common causes and fixes:
- Swapping. If
siandsoare active, the disk activity is memory pressure in disguise. Fix the memory first. - A busy database. Add page caching, an object cache such as Redis, and indexes on slow queries (Step 7).
- Backups running during peak hours. Move them to the night.
- Slow storage. Some plans use ordinary SSDs, others use NVMe (a faster type of solid-state storage). If every other fix leaves disk waits high, ask your provider about faster storage.
Step 6: If the Host Is the Problem
A high st value, CPU steal, means your VPS wanted to run but the host gave the processor to another customer. Nothing you change inside your server fixes this, because it is happening outside it.
A small amount is normal. If steal stays above roughly 5 percent during the very hours your site is slow, collect a few days of evidence, such as vmstat output with timestamps, and send it to your provider’s support. Ask them to move your VPS to a less loaded host. If they cannot and the problem continues, a different provider or a different type of plan is the answer. Read VPS vs Dedicated Server: Which One Is Right for Your Workload? for what changes when no one shares the hardware.
Step 7: If the Application Is the Problem
The vital signs look fine, the server is not busy, and yet TTFB is slow. The time is going inside the application: PHP code or database queries.
Turn on page caching
If you do only one thing in this guide, do this. Caching means the server builds a page once, stores the result, and serves the stored copy to the next visitors without running PHP or touching the database. Pages that normally take 800 ms can be served in a few milliseconds. Use a caching plugin, or configure Nginx’s own FastCGI cache. Cache only pages that are the same for everyone, and never cache the admin area, the cart, or checkout pages.
Check that OPcache is on
PHP normally reads and compiles your code to machine instructions on every request. OPcache stores the compiled result so that work happens once. Confirm it is active for PHP-FPM:
php-fpm8.3 -i | grep -i 'opcache.enable'
You want to see On. If it shows Off, enable it in your PHP configuration.
Find slow database queries
A slow query log records every database query that takes longer than a limit you choose. Turn it on, with a limit of one second:
sudo mariadb -e "SET GLOBAL slow_query_log = 1; SET GLOBAL long_query_time = 1;"
sudo mariadb -e "SHOW VARIABLES LIKE 'slow_query_log_file';"
The second command tells you where the log file is. Leave it for a day, then read it. These settings last until the database restarts. The same query appearing again and again is your culprit. It is often caused by a plugin, and the fix is to remove that plugin, replace it, or add an index (a lookup structure that helps the database find rows quickly).
For WordPress, the free Query Monitor plugin shows how many queries a page runs, which plugin ran each, and how long each took. A page that runs hundreds of queries is a plugin problem, not a server problem.
Use an object cache for busy dynamic sites
An object cache such as Redis keeps frequently needed database results in memory, so WordPress does not repeat the same queries. It helps most on sites with logged-in users or stores, where page caching cannot be used on every page.
Step 8: If the Problem Is Outside the Server
If TTFB is good but visitors say the site is slow, the cause is in what the browser has to download and run.
Open the site in your browser, press F12, and open the Network tab. Reload the page. The tab lists every file the page requested, with its size and time. Look for:
- Large images. A single uncompressed photo can be several megabytes. Resize images to the size they are displayed at and convert them to a modern format such as WebP.
- Too many requests. Dozens of separate scripts and style files each add a delay.
- Slow third-party scripts. Fonts, chat widgets, analytics, and ad scripts load from other companies’ servers, which you do not control. One slow third-party script can delay a whole page.
If visitors are mainly far from your server, a content delivery network (CDN) helps. A CDN stores copies of your images, scripts, and style files on servers around the world, so a visitor downloads them from nearby. Distance cannot be fixed on the VPS itself. It can be reduced with a CDN, or by choosing a server location closer to your readers.
Free testing tools that load your page from different places and report what is slow include Google’s PageSpeed Insights and WebPageTest.
Fix Things in This Order
Spend effort where it is cheapest and most effective first.
| Order | Action | Cost |
|---|---|---|
| 1 | Page caching and OPcache | Free |
| 2 | Remove unused plugins and block abusive bots | Free |
| 3 | Compress and resize images, use a CDN | Free to low |
| 4 | Tune PHP workers and database queries | Free, takes time |
| 5 | Add a swap file as a safety net | Free |
| 6 | Upgrade RAM or CPU | Higher monthly cost |
| 7 | Change plan type or provider | Highest cost and effort |
Upgrading is correct when, after steps 1 to 5, the measurements still show a resource above about 80 percent most of the day. At that point, the site has outgrown the server, and paying for more is justified. Read next: When to Upgrade From VPS to a Dedicated Server
Change One Thing at a Time
The most common mistake after finding a bottleneck is changing five things at once. Then the site is faster, and you do not know which change worked, or whether one of them made things worse.
Keep a small log:
| Date | Change | TTFB before | TTFB after |
|---|---|---|---|
| Oct 19 | Enabled page caching | 1.4 s | 0.2 s |
| Oct 19 | Reduced pm.max_children from 40 to 20 | 0.9 s under load | 0.5 s under load |
The numbers above are examples. Use the same curl command from Step 1 each time, at a comparable time of day, and keep only changes that measurably helped.
Common Symptoms and Likely Causes
| Symptom | Likely cause | First thing to check |
|---|---|---|
| Site is fast at night, slow in the afternoon | Resource limit hit under load | vmstat 1 5 during the slow period |
| Site is slow everywhere, all the time | Application doing too much work per page | Page caching and the slow query log |
| Database keeps stopping | The server ran out of memory | sudo journalctl -k | grep -i "out of memory" |
| Admin area slow, public pages fast | Heavy plugin or admin background requests | Query Monitor plugin |
| Fast in one country, slow in another | Distance | CDN, or a closer server location |
| Server calm but browser shows a long loading bar | Heavy images or third-party scripts | Browser Network tab |
| Sudden slowdown with a spike in requests | Bots or an attack | Access log counts from Step 3 |
Frequently Asked Questions
Is my VPS too small?
Only the measurements can say. If CPU, memory, and disk all sit comfortably below 70 percent through your busiest hours and TTFB is still poor, the server is not too small. The application is inefficient. If one resource is pinned near 100 percent while the rest idle, that resource is too small.
Will adding more RAM make my site faster?
Only if memory is the bottleneck. Extra RAM helps a server that is swapping or killing programs. On a server with plenty of free memory, more RAM changes nothing you can measure.
Is my hosting provider the problem?
Possibly, and the evidence is the st value in vmstat and top, and very slow disk waits in iostat. If those are high during your slow periods, send the numbers to support. If they are low, the cause is on your side, and changing provider would bring the same site and the same problem to a new server.
Does server location really matter?
It affects the connection time on every request. A visitor on another continent can add 150 to 300 ms before any content is sent. For a mostly local audience, choose a data center near them. For a worldwide audience, add a CDN.
Do I need a CDN?
If your visitors are spread across regions, or your pages carry many large images, yes. For a small site with local readers, page caching and optimized images come first.
How do I know if bots are the cause?
Count requests per address and per user agent in the access log, as shown in Step 3. A small number of addresses producing most of the requests, or a bot name you do not recognize, points to automated traffic. Also compare against your real visitor numbers: a server doing ten times the work of your analytics count is serving bots.
Measure, Then Fix the Narrow Part
A slow VPS is rarely a mystery. It has one limit that is tighter than the others, and the tools to find it are already installed on the server.
Measure the response time. Check the four vital signs. Follow the pattern to the right step. Change one thing, measure again, and keep what works. Upgrade when the numbers prove you have outgrown the machine, not when the page merely feels slow.
Measure first. Then change one thing.