High server loads can degrade website performance, delay backups, or even lead to service downtime. Diagnosing the root cause quickly is essential. This guide walks you through identifying high loads using common Linux tools, including top
, uptime
, ps
, and vmstat
.
๐ Step 1: Understand What โHigh Loadโ Means
What is Load Average?
The load average represents the number of processes waiting to run on the CPU.
Check current load averages:
uptime
Sample output:
12:05:34 up 5:42, 1 user, load average: 6.08, 4.27, 2.15
- First number = 1 minute average
- Second = 5 minutes
- Third = 15 minutes
๐ Compare load to CPU cores: A load of 6 on a 4-core server is high; a load of 6 on a 16-core server may be fine.
๐ Step 2: Use top
to Find Real-Time Load Sources
top -c
Look for:
- High CPU usage
- High memory usage
- Unusual processes (e.g., spam scripts, PHP loops, MySQL queries)
Press Shift + M
to sort by memory
Press Shift + P
to sort by CPU
๐งช Step 3: Use ps
to Identify Resource-Heavy Processes
ps aux --sort=-%cpu | head -20
Or:
ps aux --sort=-%mem | head -20
This helps isolate processes consuming excessive resources.
๐ Step 4: Analyze System Performance with vmstat
The vmstat
tool provides insight into CPU usage, memory, I/O wait, and system activity.
Run:
vmstat 2 10
This samples system data every 2 seconds for 10 intervals.
Key Columns to Watch:
Column | Meaning |
---|---|
r | Processes waiting for CPU (should be โค # of cores) |
us | % CPU used by user processes |
sy | % CPU used by system processes |
id | % CPU idle (low = busy system) |
wa | % CPU waiting on I/O (high = disk bottleneck) |
si/so | Swap in/out (high = memory exhaustion) |
๐ Tip: If wa
is consistently high (e.g., 20%+), your disk may be the bottleneck.
๐ Step 5: Check Disk I/O with iostat
yum install sysstat -y # if not already installed
iostat -xz 1 10
Check for:
- High %util (over 90% = saturated disk)
- High await time
๐ Step 6: Check for Abuse or Misbehaving Users
Check which users are consuming excessive resources:
ps -eo user,pid,%cpu,%mem,cmd --sort=-%cpu | head
๐ Step 7: Look Into Specific Services
Apache/LiteSpeed:
apachectl fullstatus
or if using LiteSpeed:
/usr/local/lsws/bin/lshttpd -V
MySQL/MariaDB:
mysqladmin processlist
mysqladmin extended-status
โ ๏ธ Step 8: Check for Exhausted Resources
- Memory:
free -m
ortop
- Disk Space:
df -h
- Inodes:
df -i
- Swap:
swapon -s
andfree -m
๐งฐ Optional: Use sar
to Review Historical Stats
Install sysstat
if not already:
yum install sysstat -y
Run:
sar -u 1 10 # CPU usage
sar -r 1 10 # Memory
sar -b 1 10 # I/O
๐งผ Step 9: Mitigate and Optimize
Depending on your findings, you can:
- Restart runaway services (
systemctl restart apache2
,systemctl restart mysql
, etc.) - Limit abusive users or scripts
- Tune Apache/MySQL configuration
- Add swap or upgrade server resources
โ Conclusion
By systematically using tools like uptime
, top
, vmstat
, iostat
, and ps
, you can pinpoint the source of high load and apply targeted solutions. These commands are invaluable for real-time diagnostics and trend analysis on any Linux-based cPanel server