Question

High CPU usage on a Wordpress/Ubuntu Droplet

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.


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.

Bobby Iliev
Site Moderator
Site Moderator badge
March 6, 2024
Accepted Answer

Hey,

The snapd service is responsible for managing snap packages on Ubuntu. It’s unusual for snapd to consistently use a high amount of CPU. If snapd is not essential for your current setup, you can consider disabling it to see if it heps with the CPU load. You can stop the snapd service temporarily with sudo systemctl stop snapd and see if the CPU usage decreases. To disable it from starting on boot, use sudo systemctl disable snapd.

After that, continue using top or htop to monitor the processes that consume the most CPU. If the high usage is not related to snapd, 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, or goaccess 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:

https://imgur.com/upload

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

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel