متقدم
البحث فيأدلة «كيف»
طريقة البحث
  • اكتب المهمة بكلماتك (find port، open firewall، disk full) أو الصق رسالة الخطأ بين علامتي تنصيص.
  • اختر «الإجابة السريعة» لترى الأوامر فقط، أو مجالًا لتبقى في مجال واحد.
  • "كلمتان" تجد العبارة بالضبط.
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث
جرّب:

كيف 97System · Performance

How to find out why a server is slow

"The server is slow" is not a problem description — it is the start of a check. A server is slow because one resource is full: CPU, memory, disk or network, or because the app waits on something else (a database, an API). This how-to runs a 60-second checklist that finds the busy resource, then points to the process behind it — before anyone restarts anything.

  • 5 الدروس
  • 11 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

97.1

The quick answer

uptime
dmesg -T | tail -20
vmstat 1 5
mpstat -P ALL 1 3
pidstat 1 3
iostat -xz 1 3
free -h
sar -n DEV 1 3
top

mpstat, pidstat, iostat and sar are in the sysstat package.

97.2

Step by step

  1. Load and kernel messages — how busy, and did something break?
uptime
 10:42:07 up 12 days,  load average: 9.80, 7.10, 3.05
dmesg -T | tail -20

Load rising (1-minute > 15-minute) = it is getting worse now. Look in dmesg for Out of memory, I/O error, link down, blocked for more than 120 seconds.

  1. One overview with vmstat 1 5:
ColumnWatch for
rMore than the CPU count = CPU queue.
bProcesses blocked on I/O (disk/NFS).
si / soSwapping in/out — memory is too small.
us / syCPU used by apps / by the kernel.
waTime waiting for disk.
stStolen by the hypervisor (cloud VM).
  1. CPU — all cores busy, or just one? Which process?
mpstat -P ALL 1 3
pidstat -u 1 3

One core at 100 % and the rest idle = a single-threaded app at its limit.

  1. Disk — %util near 100 and a high await (ms per request) = the disk is the bottleneck:
iostat -xz 1 3
Device   r/s   w/s  rkB/s  wkB/s  r_await w_await aqu-sz %util
sda      12  880    96  52000     4.1   48.3    41.2  99.6
pidstat -d 1 3

pidstat -d shows which process reads/writes. Also check df -h (a full disk makes apps fail or retry).

  1. Memory: free -h (available small?), si/so in vmstat, OOM lines in dmesg.
  2. Network: throughput and errors per interface, TCP retransmits:
sar -n DEV 1 3
sar -n TCP,ETCP 1 3
ip -s link show eth0
  1. If all resources look fine — the app is waiting: on the database (slow queries, locks), an external API, DNS, a full connection pool. Look at the app logs, ss -tn state established (where it connects), and the database's own view (pg_stat_activity).
  2. Keep history — the problem is often gone when you look. sar (sysstat with its timer enabled) and Prometheus/node_exporter record it, so you can look at "yesterday 14:00".

97.3

Check that it worked

You can say which resource was full (or that the app waited on something), and which process caused it — with numbers. After the fix the same commands show normal values.

97.4

Common problems

ProblemCauseFix
iostat: command not foundsysstat not installed.dnf install sysstat / apt install sysstat; systemctl enable --now sysstat for history.
High load, CPU idleProcesses in state D waiting for disk/NFS.iostat, ps -eo state,pid,cmd | grep ^D; check storage.
High st (steal)Noisy neighbours or burst credits used up (cloud).Other instance type/size.
Everything looks fine, users still waitThe app waits on the DB, an API or a lock.App traces/logs, DB views; check connection pools.
Slow only at certain timesBackups, cron jobs, log rotation.Compare with cron/timers; sar history at that time.
Restart "fixed" itA leak or a stuck resource.Find the cause before it comes back: memory trend, open files, connections.

97.5

Go further

1vmstat shows high wa and b, CPU mostly idle. What is the bottleneck?

The disk (or network storage) — processes wait for I/O.

2All resources look normal, but requests are slow. Where do you look next?

At what the app waits on: the database, external APIs, DNS, connection pools.

كل الأوامر في هذا الفصل