How to Troubleshoot a Slow Linux Server: Separate the Six Kinds of Slow First, Then Add Capacity
2026-10-29 09:07:07
On a Linux server, when an operations engineer gets a report that the server is slow, investigating straight away is the wrong move. The reason is simple: there is nothing in that sentence to investigate.
At least three more sentences are needed first: who finds it slow, which stretch is slow, and under what conditions it is slow. With those three answered, most cases jump straight to one or two of the forms below instead of trying add more memory and working down a list.
This article separates six kinds of slow: the signal of each, how to gather evidence, which way to fix it, and the most common misjudgment. Of the six, only the first is the CPU actually computing; the other five should not be solved by adding capacity.

1. First Break Slow into Three Sentences
The first sentence: who finds it slow. Is the operator waiting three seconds after a click in the browser? Did a batch export of reports run for half an hour? Does it jam at 8:30 every morning when the whole plant creates work orders at once? These three kinds of slow are not the same problem at all. Slow front-end interaction may not spend a single second on the server: browser rendering, image loading and serial API calls all count.
The second sentence: which stretch is slow. A single request on Linux passes through at least four stretches: browser and network, web server and application code, database, and disk. Without locating the stretch, everything that follows is guesswork.
The third sentence: under what conditions it is slow. Always slow, slow at peak, slow on a particular operation, slow for a while and then suddenly fine on its own: different time shapes point to causes that barely overlap. This is the most easily overlooked point, and it often halves the scope in one step.
2. Form One: the CPU Really Is Computing
Signal: in top, %us (user mode) is high, load average clearly exceeds the core count, and %wa is low.
What it means: something is genuinely consuming CPU cycles. Common sources are compute-intensive tasks (exports, statistics, image processing), infinite loops or regex backtracking, encryption and compression, serializing large objects, and newly deployed code.
top -H -p # see which thread is eating CPU
perf top -p # see hot functions (when symbols are available)
pidstat -u 1 5 # sample by process to confirm it is the one
How to fix: first check whether it should be busy. A batch job running or a report exporting is normal load, and the right response is staggering or rate limiting; sustained saturation with no business activity is abnormal, and the search goes toward infinite loops, regex backtracking and cache stampedes.
The most common misjudgment: looking only at load average. On a single-core machine a load of 2 is already overloaded; on a 32-core machine a load of 8 is still idle. Load must be read together with the core count, and because load includes processes waiting on IO, high load does not necessarily mean the CPU is busy.
3. Form Two: the CPU Is Not Busy, It Is Waiting for Disk
Signal: %wa (iowait) stays high, %us is not high, and load average is also high. The machine looks busy, but the CPU spends much of its time spinning while waiting.
vmstat 1 5 # look at the wa column
iostat -x 1 5 # per-disk await, r/s, w/s, %util
iotop -o # see which process is reading or writing
One easily missed connection: huge numbers of small files make IO noticeably slower. When a directory holds hundreds of thousands of files, reading the metadata of one file may trigger several seeks, showing up in iostat as many small IOs and a higher await. The root cause of this kind of slow is the number of files, not disk performance, and cutting the file count helps far more than buying a faster disk.
How to fix: first separate read-heavy from write-heavy, sequential from random. Synchronous log writes, frequent database fsync and backup jobs competing with business IO are the three most common scenarios. Rate limit and stagger backups; make logging asynchronous or reduce flush frequency, provided a small loss is acceptable.
4. Form Three: Not Enough Memory, Paging Begins
Signal: si and so in vmstat are non-zero (real swapping in and out), available in free is very low, and OOM records appear in dmesg.
Once paging starts, the latency is not a little slower but an order of magnitude worse: a page fault turns a microsecond memory access into a millisecond disk access.
free -m # look at available, not free
vmstat 1 5 # whether si/so stay non-zero
dmesg | grep -i oom # whether any process was killed by the OOM killer
The most common misjudgment: treating buff/cache as occupied memory. Linux deliberately uses free memory for file cache and reclaims it when needed, so a low free column is normal. The measure is available, which is how much can still be given to new processes.
How to fix: first find what is growing (ps aux --sort=-rss), then check whether it is an unbounded cache, an oversized connection pool, or a genuine rise in traffic. Adding memory eases it, but if the root cause is a leak or an unbounded cache, any amount will be eaten.
5. Form Four: the Disk Itself Is Slow, or a Quota Is Exhausted
Signal: in iostat, await (average wait) is clearly high and %util is close to 100, while CPU and memory are not tight.
A hidden cause is especially common in the cloud: cloud disk IOPS and bandwidth are provisioned by specification, and once the burst allowance is used up they drop back to the baseline. The symptom is fast in the morning, suddenly slow in the afternoon, fine again the next day, which looks mysterious but is a quota.
iostat -x 1 5
# check whether r_await / w_await are tens of milliseconds or more; whether %util sits at 100
A note on %util: on SSDs, NVMe and multi-queue devices this metric lies. A single disk at %util 100 does not mean bandwidth is saturated; it only means the device queue was non-empty that proportion of the time. Throughput and await are more reliable than %util.
How to fix: first confirm whether it is a specification or quota issue (the cloud console's monitoring curves show the ceiling directly), then whether it is write amplification (small random writes, overly frequent log flushes, database page size not matching block size). The first calls for a larger specification or sharding, the second for parameter or write-pattern changes: two diseases, two medicines.
6. Form Five: Not Slow, Queuing
Signal: CPU is not high, IO is not high, memory is sufficient, yet requests are slow, and at the same time the database or application shows a lot of waiting.
Resources are all sufficient, but requests are waiting on locks, connections or threads. Slow really means what is ahead has not been processed yet. Three common queuing points:
Database lock waits: a long transaction holds row locks and everything behind it blocks. In MySQL, look at information_schema.innodb_trx and the lock-wait section of SHOW ENGINE INNODB STATUS; in PostgreSQL, look at sessions in pg_stat_activity with wait_event_type = 'Lock', and pg_blocking_pids() identifies the blocker directly.
Connection pool exhausted: the application's maximum connection count is a hard ceiling, and once reached new requests queue for a connection. The symptom is API latency settling at an odd magnitude, such as exactly 3 seconds or 5 seconds, because that is the pool's wait timeout.
Application thread pool serialized: one slow endpoint occupies all worker threads and every other request queues. The logs show many requests starting and finishing at the same time.
How to fix: find the longest transaction or the request holding a connection, rather than adding machines. Adding machines does almost nothing for lock waits, since the lock is on the same database instance.
7. Form Six: the Link and Upstream
Signal: the server's own metrics are all green but users are slow, or outbound requests from the server are slow. The problem is outside the server.
Bandwidth saturated: outbound bandwidth is filled by backups, log shipping or large downloads, which iftop shows at a glance. Packet loss and retransmission: ping looks fine but the TCP retransmission rate is high; use ss -s or netstat -s | grep -i retrans. Slow DNS resolution: every external request carries a DNS timeout, and it accumulates. TLS handshake overhead: short connections handshake afresh each time, doubling the cost on high-RTT links. Slow upstream dependency: a third-party API or another internal service is slow and drags the whole chain, the case most easily mistaken for our server is slow.
How to fix: instrument every external dependency with timing and record our time and the time waiting for others separately. Without that split you are always guessing.
8. A Decision Table
| Form | Signal at a glance | First command | Typical misjudgment |
|---|---|---|---|
| CPU truly busy | %us high, %wa low | top / pidstat -u 1 | Reading load without core count |
| Waiting on disk | %wa high, %us low | vmstat 1 / iostat -x 1 | Buying a faster disk |
| Memory paging | si/so non-zero, available low | free -m / vmstat 1 | Taking cache as used |
| Disk / quota | await high, %util at the ceiling | iostat -x 1 / cloud monitoring | Taking %util as bandwidth |
| Queuing | Resources idle, requests slow | Lock-wait views, pool metrics | Adding machines |
| Link / upstream | Host all green, users slow | iftop / ss -s / dependency timing | Taking waiting as our problem |
How to use the table: first route by which resource is tight, then check whether the tight one is the culprit. Watch the resources idle but requests slow cell, since it most easily pushes people toward adding capacity when the real cause is usually queuing.
9. The Time Shape of Slow Says More Than an Instantaneous Value
Always slow: slow from go-live, mostly a design problem such as N+1 queries, missing indexes, serial calls or single-threaded processing. More resources only ease it for a while.
Slow at peak: 8:30 in the morning, the first of the month, scheduled job windows. This is capacity and staggering: either rate limit and queue, or move the batch jobs.
Slowly degrading: slower every day, fine after a restart, typically a memory leak, unreleased connections, accumulating temporary files, or table growth invalidating indexes.
Suddenly slow then fine: cloud disk burst allowance, backup jobs, noisy neighbours, upstream jitter. This needs evidence that lines up with a time point, not parameter tuning.
Slow on a specific operation: only this report or this batch of data is slow. Search along that specific path, not the whole machine.
Asking which shape it is often beats looking at ten monitoring charts.
10. Five Common Misjudgments
One, adding memory straight away. A high memory curve does not mean insufficient memory; available is the measure. Adding memory does nothing for lock waits, slow queries or saturated bandwidth, yet it is the most common first reaction.
Two, replacing the machine with a stronger one. Queuing problems usually do not improve with a new machine, since the lock is on the same database and the pool is upstream; design problems only go from 3 seconds to 2.
Three, judging load by load average. It mixes CPU and IO waiting and must be read against the core count.
Four, taking %util as the disk performance ceiling. It misreports on multi-queue devices; await and throughput are more reliable.
Five, tuning kernel parameters first. The network and memory parameters in sysctl are not the bottleneck in the overwhelming majority of cases, and tuning before locating turns the problem into one you no longer know the original shape of.
11. Order of Response: Stop the Bleeding, Then Optimize, Then Prevent Recurrence
The first layer, stop the bleeding. The only goal is to make the business usable again. The usual means are rate limiting, degradation, staggering, temporary scaling and switching off non-core batch jobs. This step does not aim to find the root cause.
The second layer, optimize. With the time bought by stopping the bleeding, locate the problem with the decision table. Before optimizing, do one thing: keep a baseline. Record the current QPS, P95 latency, resource levels and top 10 slow queries. Without a baseline, all you can say afterwards is that it feels faster, and the next slowdown cannot be judged as regression or a new problem.
The third layer, prevent recurrence. Turn the signal that failed this time into an alert. The great feature of slow faults is that they can be seen in advance: CPU climbing, memory ramping, disk await rising, slow-query count growing, all before users report. What is usually missing is not data but someone watching it.
There is no need for a full monitoring stack from day one. Four items are enough to begin: load and CPU distribution, available memory and swap activity, per-disk await, and the P95 of key endpoints. These four cover the routing of most slow cases, and finer metrics can follow once a concrete problem appears. Moges builds this basic observability into environment setup deliveries, because it decides whether the next slow incident can be investigated or only guessed at.