What is loading the server
First open the server page in the control panel and look at the Resources widget. It shows how busy the CPU, memory and disk are right now. If the CPU has been near 100% for a long time, it usually means some program inside the server is taking all of it, and you need to look for it in the system itself.
Connect over SSH and run:
top
The processes that load the CPU the most are at the very top of the list. Press M to sort it by memory, and q closes the program. Many people find htop easier: it shows the same thing, just more clearly. You can install it with apt install htop (Debian, Ubuntu) or dnf install htop (AlmaLinux, Rocky).
The usual suspects are:
- the web server and PHP (
php-fpm,apache2,httpd,nginx) — when the site gets a lot of requests; - the database (
mysqld,mariadbd,postgres) — with heavy queries; - your own applications (
node,python,java), especially if copies of them keep starting again and again; - unfamiliar processes with strange names. That's often what a miner looks like after a break-in. See the last section of this article.
Bots are overloading the site
These days the most common cause is bots. Search engine and AI crawlers, vulnerability scanners, scrapers and so on. Sometimes they send hundreds of requests a minute, and then PHP and the database simply can't keep up.
It's easy to check: look in the log to see which addresses the requests come from and which programs send them. For nginx, that's two commands:
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -20
awk -F'"' '{print $6}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -20
The first one lists the addresses with the most requests. The second shows the program names (User-Agent). For Apache, change the path to /var/log/apache2/access.log or /var/log/httpd/access_log.
If bots are the problem, there are a few ways to deal with them.
- **Limit crawlers in
robots.txt.** Well-behaved bots read this file and follow it. For example, this is how you close the site to the GPTBot AI crawler:
User-agent: GPTBot
Disallow: /
- Block pushy bots on the web server. For those that ignore
robots.txt, add a User-Agent check to theserverblock of the nginx configuration and restart nginx:
if ($http_user_agent ~* (Bytespider|PetalBot|MJ12bot)) { return 403; }
- Block single addresses in the firewall, for example
ufw deny from 203.0.113.10. - Put the site behind Cloudflare or a similar service. It filters out bots before the requests ever reach your server. And if the flood is really heavy, you can turn on Under Attack mode in Cloudflare.
Not enough memory
When memory runs low, the system starts writing to the swap file a lot, and that makes the server noticeably slow. This command shows how much memory is free:
free -h
Almost no free memory left, and top shows your programs are eating it? Then either run fewer of them (for example, fewer PHP-FPM processes) or give the server more memory: Reconfiguring a virtual server.
If memory runs out completely, the system starts stopping programs on its own. You can find out whether that happened with:
dmesg -T | grep -i "killed process"
The disk is full
Another cause is a full disk. Then the database and the site slow down or stop working altogether. Check the disk space like this:
df -h
If there's no space left, you need to find what took it. Usually it's logs, backups or cache:
du -xh / --max-depth=2 2>/dev/null | sort -rh | head -20
If it looks like a break-in
Sometimes an unfamiliar process loads the CPU heavily and starts again after you stop it. Most often that means the server was hacked and a miner is running on it. Just stopping the process won't help, the attacker will bring it back. Save the data you need and reinstall the system. After that, change all passwords and turn off password login so the server can only be reached with an SSH key.
Can't find the cause? Contact support. Tell us which server it is and at what time it was slow.
