DigitalOcean high CPU usage can be a nightmare for Droplet owners.
Usually, high CPU usage happens due to faulty processes, wrong configuration or even a lack of server resources.
The real challenge lies in finding the exact process that makes the CPU usage high.
At Bobcares, we help our customers in managing Droplets as part of DigitalOcean Managed Services.
Today, let’s take a look at how we identify the real reason for the DigitalOcean high CPU usage and fix it.
Impact of high CPU usage in DigitalOcean
Are you curious to know the downside of high CPU usage on a DigitalOcean Droplet?
Just like any other server, when the CPU usage goes high, the server and even the websites become slow. It takes too much time to complete a process.
Due to this delay in execution, the processes keep on queuing. This further adds to the server load. Ultimately, it can even result in a server crash.
That’s why most DigitalOcean customers set up realtime monitoring of server resources. This triggers an email alert when CPU usage goes beyond a particular limit.
A similar notification email on one of our customer’s Droplet turned up as:
Common causes for DigitalOcean high CPU usage
From our expertise in managing DigitalOcean Droplets, we often deal with resource usage problems. Let’s now check the common reasons that cause high CPU usage in Droplets.
1. Incorrect service configuration
Quite often, the CPU usage problems crop up due to errors in the service configuration. Usually, it will be badly configured MySQL service, Java processes, etc.
Due to the unoptimized queries to databases, each process creates a big impact on the CPU. When there are multiple processes of the same service, it can lead to high CPU usage.
2. Insufficient server resources
Similarly, insufficient resources on the Droplet can also trigger high CPU usage.
For instance, imaging a user trying to run a CPU intensive application on a $10 Droplet. Initially, the app will work fine when the number of users are less. Thereafter, when the app users go high, it starts using more CPU.
Thus, the resource allocation should always be proportional to the expected usage.
3. Poorly configured applications
Many times, some applications may also increase CPU usage. This mainly happens when applications trigger resource-intensive processes. This can be a backup or restore process, updating files, etc.
Here, the best way to properly test the application before making it live.
How we fix DigitalOcean high CPU usage
Till now we saw the various reasons for the high CPU usage in Droplets. We’ll see how we fixed the problem for one of our customers.
He was getting alert emails about CPU usage hitting the limits every day. There was a spike in the server load. Sometime later it became alright again.
We logged in to the Droplet via SSH and checked the server load. Then we issued the command:
We found that the server load was due to a wp-cron process under a WordPress website. The process table appeared as per the snippet below:
The server had too many wp_cron processes running for a long period of time. It was consuming %CPU of 42.2, 35.3, etc. This was overloading the server.
Further, we checked the processing power of the DigitalOcean Droplet using the command,
This command displays the number of processing units available.
From the results, we inferred that the server had enough processing power. Therefore, we intimated the details to the customer.
Later, we changed the frequency of the WordPress cron to fix the high CPU usage. Also, we scheduled the task to run at an off-peak time of the server.
This fixed the CPU usage problem of the Droplet.
In some cases, when the Droplet resources are insufficient, we suggest customers upgrade to the next higher package too.
[Struggling to find out the exact process behind the high CPU usage on the server? Get help from the experts!]
In short, the DigitalOcean high CPU usage occurs due to faulty service configuration, lack of server resources, etc. Today, we saw how our DO Experts identify the exact process that uses the CPU processing power and fix it.