I’ve been getting spikes of 100% CPU usage. I checked it out recently because my Wordpress site wasn’t connecting.
Using top, I saw root user and snapd was using the CPU.
Looking at my CPU Usage graph, there are several spikes over the past two weeks, all reaching 100% usage. I have a screenshot, but can’t see how to attached it.
Thank you in advance.
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!
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.
Hey,
The
snapd
service is responsible for managing snap packages on Ubuntu. It’s unusual forsnapd
to consistently use a high amount of CPU. Ifsnapd
is not essential for your current setup, you can consider disabling it to see if it heps with the CPU load. You can stop thesnapd
service temporarily withsudo systemctl stop snapd
and see if the CPU usage decreases. To disable it from starting on boot, usesudo systemctl disable snapd
.After that, continue using
top
orhtop
to monitor the processes that consume the most CPU. If the high usage is not related tosnapd
, identify which processes are causing the spikes. For a WordPress site, high CPU usage might be related to specific plugins or themes, or it could indicate that your site is receiving more traffic than usual.On another note, sometimes, poorly optimized plugins or excessive plugins can cause significant resource usage. Consider using caching plugins like W3 Total Cache or WP Super Cache to reduce the load on your server.
You can also check your access logs to determine if the traffic is legitimate or if your site is under a brute force attack or experiencing increased bot traffic. You can use tools like
awk
,grep
, orgoaccess
to analyze your access logs. In addition to that, I would also recommend the following script, which you could use to summarize your access logs and find any potential suspicious requests:https://devdojo.com/bobbyiliev/bash-script-to-summarize-your-nginx-and-apache-access-logs
As a side note, if your Droplet is consistently at 100% CPU usage, it might be underpowered for your needs. Consider resizing your Droplet to a larger plan that offers more CPU and RAM to handle your workload better.
Since you mentioned you have a screenshot but can’t attach it here, you can use this website here instead:
If you follow these steps and still face issues, feel free to share more details, and we can dive deeper into troubleshooting the problem.
Best,
Bobby
Extremely informative. It’s been beneficial for me.