cpu from 13% to 100% in one minute

I have a website (it’s the only site hosted on the droplet) and sometimes (about 1 time each month, but not on the same day) the CPU usage goes through the roof. I have absolutely no idea what’s causing it, but in 1 minute the CPU usage goes from 5-13% straight to 100% causing the server to hang.

Disk I/0 also peaks and memory usage goes from 30% to 70%.

I have checked Google Analytics to check if there is a sudden increase in visitors as my client thought this happened after posting an instagram story. However, the largest visitors at the same time is only 15 which is unlikely to cause this.

I have no clue where to start looking what might be causing these issues. Any hints?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I had the same problem now I found a solution I hope it will work for you. actually, someone was attacking with a brute force attack on my website so why my website was down and the graph shows CPU 100% usage.

First of all, check which application takes much usage so enter the command “top” it will show the real-time CPU usage. in my case, PHP-fpm was taking 95% usage.

Now you have to check your Nginx log file. “sudo tail -f /var/log/nginx/access.log” it will show the error or bad gateway access details… now you have to copy the IP address which is repeated a lot of times you have to block it.

You can block IP by using this command “iptables -I INPUT -s -j DROP

I hope this issue will be resolved.

I found that my unicorn.log file in /var/log/unicorn was over 10gb in size. Deleting that helped my 100% CPU issue.

No backups running at that time…

Is your script something that logs everything or should you manually trigger it to log? Because by the time I notice it, the only way to resolve the problem is to restart the server.