In short
When a server slows down, the cause is almost always CPU, RAM, disk I/O or slow database queries. While the slowdown is happening, use vmstat to see which resource is under pressure, htop to find the process eating it, iostat and iotop to spot disk wait, and the MySQL slow query log to catch unindexed queries. Fix caching and queries first; if resources are still maxed out under normal traffic, move to more RAM or a faster CPU.
In this guide
- What is a bottleneck, and why measure first?
- Step 1: Get the big picture with uptime and load average
- Step 2: Use vmstat to tell CPU, memory and disk apart
- Step 3: Find the process using CPU and RAM with htop
- Step 4: Confirm a disk bottleneck with iostat and iotop
- Step 5: Check network and connection counts
- Step 6: Catch slow queries with the MySQL slow query log
- Optimize or upgrade to a more powerful server?
- Quick wins before you upgrade
- Next step: Measure, optimize, upgrade if needed
When a server slows down, the problem is almost always in one of four places: CPU, RAM, disk I/O or database queries. You don't need to guess. A few minutes of htop, vmstat, iostat/iotop output plus the MySQL slow query log is enough for an accurate diagnosis. This guide shows which value to read in each tool and how to decide, based on the results, whether you need optimization or a more powerful server.
What is a bottleneck, and why measure first?
A bottleneck is the weakest resource that caps the performance of the whole system. Adding RAM while the CPU is pinned at 100%, or adding cores while processes wait on disk, won't fix anything; it only makes the bill bigger. So the first job is to take measurements while the server is slow. Snapshots taken after the problem has passed are usually misleading.
The commands below are for Ubuntu and Debian; on AlmaLinux/Rocky Linux, just use dnf as the package manager.
sudo apt update
sudo apt install -y htop iotop sysstat
Step 1: Get the big picture with uptime and load average
For a first look, uptime is enough. The three numbers at the end of the output are the load average for the last 1, 5 and 15 minutes.
uptime
nproc
Load average is the average number of processes waiting in line to run plus those waiting on disk. As a rule of thumb, if it consistently exceeds the vCPU count shown by nproc, the server can't keep up. On a 4 vCPU server, a load average sitting around 8–10 points to a persistent backlog. Load average alone doesn't tell you whether the problem is CPU or disk, though; for that, move on to the next step.
Step 2: Use vmstat to tell CPU, memory and disk apart
vmstat is the fastest diagnostic tool because it shows all three resources on one screen. To take five readings, one per second:
vmstat 1 5
These are the columns to read:
| Column | Meaning | Warning sign |
|---|---|---|
r | Processes waiting for CPU time | Consistently above the vCPU count: CPU bottleneck |
b | Processes blocked waiting on I/O | Consistently above 0: disk bottleneck |
si / so | Memory swapped in / swapped out | Anything other than zero: not enough RAM |
us / sy | User / kernel CPU percentage | Combined above 90: CPU is saturated |
wa | CPU idle time spent waiting on disk I/O | High: the problem is disk or queries |
st | Steal time: CPU time the hypervisor gives to other virtual machines | Consistently high: resource contention on the host |
This table points you in the right direction: high us means CPU, non-zero si/so means RAM, and high wa and b mean you should focus on disk or the database.
Step 3: Find the process using CPU and RAM with htop
htop shows live which process is consuming resources. Once it's open, press F6 to sort by PERCENT_CPU or PERCENT_MEM, and press F5 for tree view to see which parent process is spawning children.
- A single
php-fpmornodeprocess constantly at 100%: Usually an infinite loop, a heavy report, or an expensive page being hammered by bots. - Dozens of
php-fpmworkers, each using moderate CPU: A real traffic increase or uncached pages. mysqldat the top: Unindexed queries; skip to step 6.- A process you don't recognize (e.g. a randomly named binary): Possibly a crypto miner; deal with security first.
To check the memory side and see whether the OOM killer has been killing processes:
free -h
sudo dmesg -T | grep -i -E "out of memory|killed process"
In the free -h output, look at the available column. A low free value is normal because Linux uses spare memory for disk cache. If available drops below 10% of total RAM and swap usage keeps climbing, you have a real memory bottleneck.
Step 4: Confirm a disk bottleneck with iostat and iotop
If wa is high, measure how busy the disk is with iostat:
iostat -x 1 5
The key columns are %util (the share of time the disk is busy) and r_await/w_await (average wait per request in milliseconds). On NVMe drives, %util on its own can be misleading because these drives handle many requests in parallel; a clear rise in wait time compared to normal is a more reliable signal.
To see who is keeping the disk busy:
sudo iotop -o -P
-o shows only processes doing I/O, and -P shows totals per process. Common culprits: backup scripts running at midnight, bloated log files, applications that have fallen into swap, and MySQL queries that create temporary tables. A full disk can also cause slowness; in that case, follow the cleanup steps in the guide to a full disk on a Linux server.
Step 5: Check network and connection counts
If CPU, RAM and disk look normal but the site is still slow, the problem may be the number of connections:
ss -s
ss -tan state established | wc -l
sudo tail -n 200 /var/log/nginx/access.log | awk '{print $1}' | sort | uniq -c | sort -rn | head
The last command lists the IP addresses that appear most often in recent requests. If a single IP is sending hundreds of requests, the issue isn't a lack of resources but a malicious or runaway bot. That calls for rate limiting and firewall rules; details are in the DDoS attack and protection guide.
Step 6: Catch slow queries with the MySQL slow query log
In web applications, the most common cause of slowness is unindexed database queries. The slow query log writes queries that take longer than a threshold you set to a file. To turn it on without a restart, run this in the MySQL/MariaDB console:
SET GLOBAL slow_query_log = 'ON';
SET GLOBAL long_query_time = 1;
SET GLOBAL slow_query_log_file = '/var/log/mysql/mysql-slow.log';
To make it permanent, add the same settings to the [mysqld] section of /etc/mysql/mysql.conf.d/mysqld.cnf (on MariaDB, /etc/mysql/mariadb.conf.d/50-server.cnf). After the server has handled traffic for a while, summarize the queries by total time:
sudo mysqldumpslow -s t -t 10 /var/log/mysql/mysql-slow.log
Inspect the query at the top of the list with EXPLAIN. If you see ALL in the type column and a large number in the rows column, the table is being scanned end to end; adding indexes on the columns used in WHERE and ORDER BY often makes a bigger difference than a server upgrade. Also make sure innodb_buffer_pool_size is large enough to keep the frequently used part of your database in memory.
Optimize or upgrade to a more powerful server?
Match your measurements against this decision table:
| Finding | Try first | If an upgrade is needed |
|---|---|---|
| A single query or page maxes out the CPU | Indexes, caching, code fix | Usually not needed |
| Caching is on, all cores constantly full | Remove unnecessary cron jobs and plugins | More vCPUs or faster cores |
| PHP/Node slow per request, CPU bottlenecked on a single core | OPcache, version update | A CPU with high single-core performance |
| Swap usage, OOM entries | Lower worker counts and buffers | More RAM |
High wa, long await | Move backups to night hours, optimize queries | Larger NVMe and more RAM (for caching) |
Consistently high st | Repeat the measurement at different times | Open a support ticket and report it |
The rule is simple: if a single query or process is generating all the load, fix it first. If resources stay maxed out under normal traffic even after you've improved the code and the database, your server is starting to be too small for your workload.
If RAM is the only shortfall, moving up one plan in the same CPU family is usually enough; Ryzen Premium VDS plans based on the AMD Ryzen 9 5900X offer tiered RAM options from 2 GB to 32 GB. If the issue is per-request CPU speed, for example in workloads sensitive to single-core performance such as PHP, Node.js or game servers, moving to a newer-generation CPU makes a difference. VDS plans with the AMD Ryzen 9 9950X and DDR5 RAM are built for these CPU-intensive workloads. For a more detailed look at which CPU fits you, see the Ryzen 9 9950X server guide.
Quick wins before you upgrade
- Set up page caching: Nginx FastCGI cache, LiteSpeed Cache or application-level caching keeps repeat requests from ever reaching PHP.
- Enable PHP OPcache: It stops PHP scripts from being recompiled on every request.
- Size PHP-FPM workers to your RAM:
pm.max_childrenshould not exceed available RAM divided by the average memory of a single worker; otherwise the server falls into swap. - Limit bot traffic: Slow down IPs sending excessive requests with Nginx
limit_reqand Fail2ban. - Spread out scheduled tasks: Keep backups, reports and cron jobs from landing in the same minute.
Next step: Measure, optimize, upgrade if needed
Run these steps while the server is slow and write down the values you find. If things improve after optimization, stay on your current server. If values are still at the limit, choose a plan based on the resource you need: Ryzen Premium VDS for tiered RAM and vCPU, or Ryzen 9 9950X VDS for high single-core speed and DDR5 memory. All Sunucu Atlas VDS plans run in our Istanbul data center with KVM virtualization and root access; if you get stuck during the migration, open a support ticket for help.
Frequently asked questions
What load average means a server is overloaded?
As a general rule, if load average stays above your vCPU count for a long time, the server can't keep up. You can tell whether it's coming from CPU or disk wait by checking the us and wa columns in vmstat output.
The free command shows very little free RAM. Is something wrong?
No. Linux uses spare memory as disk cache, so a low free value is normal. What you really need to watch is the available column and swap usage.
Why does steal time (st) matter on a VDS?
Steal time shows that your virtual machine wanted CPU but the hypervisor gave that time to something else. If it stays high, the problem isn't your application but resource sharing on the host, and you should report it to your provider.
Does the MySQL slow query log hurt performance?
With a reasonable long_query_time (for example, 1 second), the overhead is usually negligible. If you set it to 0, every query gets logged and disk usage goes up, so use that setting only for short analysis sessions.
Should I get more RAM or a faster CPU?
If you see swap usage and OOM entries, you need RAM; if the CPU is constantly full and requests bottleneck on a single core, you need a faster CPU. Always take measurements while the server is slow before you decide.