- by x32x01 ||
Imagine logging into your server and seeing this:
The most important advice first:
❌ Don’t rush to increase server resources
✅ Find the root cause first
Let’s go through the most common scenarios 👇
If you want to list processes by CPU usage:
You will usually find a specific process consuming most of the CPU.
From there, the investigation begins.
There is a strong chance your server is infected with a crypto mining malware.
Find where the executable is located:
Then check the logs to determine how the attacker gained access:
You may notice:
If you see the same IP sending thousands of requests within seconds, you likely have a crawler overload.
Example configuration in Nginx:
Signs include:
Or:
The problem may simply be bad application code.
For example:
If this query runs without:
If the website does not use caching systems like:
In MySQL, run:
If the output shows:
That means no index is being used.
Indexes dramatically improve query performance.
This can happen with:
If a script constantly consumes CPU, review the code and check for mistakes like:
without a proper exit condition.
Check memory usage:
If swap usage is high, you may need to:
If the real problem is:
You just need to know how to read the signs 👨💻🔥
- CPU usage = 100%
- Load Average extremely high
- The server suddenly becomes very slow
- Your website starts crashing or responding slowly
- And there is no normal traffic that explains it 👀
The most important advice first:
❌ Don’t rush to increase server resources
✅ Find the root cause first
Let’s go through the most common scenarios 👇
Step One: Login via SSH and Identify the Process 👨💻
Connect to the server using SSH and run:top or htopIf you want to list processes by CPU usage:
Bash:
ps aux --sort=-%cpu | head From there, the investigation begins.
1️⃣ Hidden Crypto Miner Malware ⛏️💀
If you notice a suspicious process with a strange name running from a path like: Code:
/tmp/.xyz/miner What should you do?
Kill the process immediately: Code:
kill -9 PID Code:
ls -lah /proc/PID/exe - Vulnerable application
- Weak password
- Exposed service
2️⃣ Aggressive Web Crawler Overloading the Site 🤖
Sometimes the problem isn’t malware but a crawler or bot scanning your entire website too aggressively.You may notice:
- High CPU usage from PHP or Python processes
- Heavy load on your web server such as
Nginx, Apache HTTP Server, or Microsoft IIS
Code:
tail -f /var/log/nginx/access.log Solution
Limit the number of requests per IP.Example configuration in Nginx:
Code:
limit_req_zone $binary_remote_addr zone=one:10m rate=5r/s;
limit_req zone=one burst=10 nodelay; 3️⃣ Possible DDoS Attack 🚨
Another common cause is a Distributed Denial of Service (DDoS) attack.Signs include:
- Huge numbers of requests
- One IP or multiple IP ranges generating traffic
- Abnormally high network usage
Code:
netstat -ant | grep :80 | wc -l Code:
ss -s Possible solutions
- Rate limiting
- Firewall rules
- Using services like Cloudflare
- Tools such as Fail2Ban
4️⃣ Application Bug Overloading the Database 🗄️
Sometimes the issue isn’t an attack at all.The problem may simply be bad application code.
For example:
SQL:
SELECT * FROM huge_table; WHERELIMIT- Proper caching
If the website does not use caching systems like:
- Redis
- Memcached
Solution
- Enable caching
- Review installed plugins if using a CMS
- Temporarily disable suspicious plugins to test performance
5️⃣ Missing Database Indexes 📊
Large databases without proper indexes can cause extremely slow queries.In MySQL, run:
SQL:
EXPLAIN SELECT * FROM users WHERE email='test@example.com'; Code:
type = ALL Fix
Create an index: SQL:
CREATE INDEX idx_email ON users(email); 6️⃣ Background Process Stuck in an Infinite Loop 🔁
Another common issue is a script running endlessly in the background.This can happen with:
- Cron jobs
- Scheduled scripts
- Background services
crontab -lIf a script constantly consumes CPU, review the code and check for mistakes like:
while True:without a proper exit condition.
7️⃣ High Virtual Memory Pressure 🧠
If your RAM is full, the server may start using Swap memory, which dramatically slows performance.Check memory usage:
free -mIf swap usage is high, you may need to:
- Reduce running processes
- Adjust memory limits
- Review memory-heavy applications
The Most Important Advice 💡
Many administrators see high load and immediately say:- Let’s upgrade the server
- Add more RAM
- Add more CPU
If the real problem is:
- Malware
- DDoS attacks
- Programming bugs
- Bad database queries
Final Thoughts 👑
If your server suddenly hits 100% CPU load, follow this order:1️⃣ Check running processes
2️⃣ Analyze server logs
3️⃣ Determine if it's malware, bots, or a DDoS attack
4️⃣ Review application code and database queries
5️⃣ Never upgrade resources before understanding the issue
A server usually tells you exactly where the problem is.2️⃣ Analyze server logs
3️⃣ Determine if it's malware, bots, or a DDoS attack
4️⃣ Review application code and database queries
5️⃣ Never upgrade resources before understanding the issue
You just need to know how to read the signs 👨💻🔥