High CPU Usage on My VPS (Help)

Alf85

Elite Member
Joined
Sep 7, 2021
Messages
2,580
Reaction score
921
The CPU of my VPS is experiencing spikes of 100% usage. I have had the same VPS on Cloudways (DigitalOcean) since 2020 with WordPress, and I have never had these problems before. My traffic is much, much lower than before. I also don't have any new plugins, and Cloudways support has not been effective.

Is there a plugin or a way to see what is causing the CPU usage to spike so much? On another server that is exactly the same, this doesn't happen, and the CPU usage remains at 10%.

 
Check your I/O rate and logs.

Some WP plugin may be buggy and writing in the background like crazy.

It can also be that server has been compromised and mass emails are being send out for example.

Disk usage is also above normal for a WP install.
 
optimize your wordpress
 
Check your I/O rate and logs.

Some WP plugin may be buggy and writing in the background like crazy.

It can also be that server has been compromised and mass emails are being send out for example.
How can I check that with Cloudways? It is not cPanel.
 
Do you have SSH acces on your vps? If so you can easily check that is spiking your CPU usage by using linux tool called "htop". It will show you a list of processes currently happening and you can pinpoint if it is a wordpress or database issue or some DDOS attack.

If you are not being DDOS'ed I would suspect that your database is being corrupt. Unfortunately as your wordpress website is old your chances of getting a corrupt database are significantly higher.
Wordpress is not very optimized and it is writing a lot of lines daily in the database which easily eat your ram/cpu.

You can try to restart your VPS if you have ssh access or maybe you can restart on your hosting panel.
That should temporarily reduce load on your vps if the issue was caused by wordpress/database.
 
how many posts does the website have?
is it an autoblog, are you publishing too many posts frequently?
how many traffic are you getting? does the CPU goes up when the traffic is up or all day?
what plugins are using?
what are the CPU specs?
what's the php memory limit set for the website?

start by using htop in the VPS cmd, this should list what exactly is using most of the CPU,
mysql would be in 90% of the cases, but can be due to some other attacks,

try disabling your plugins 1 by 1 and check if it helps,
some plugins will skyrocket your CPU usage, especially the ones with heavy queries, related posts plugins are a good example,

make sure you're using a greater php memory limit, caching, controlling heart-bit,
wp-rocket (or any similar caching plugin) can take care of the caching and hearth-bit parts,

debugging will take some time,
just keep testing with several changes,
other than that, it could be that your VPS is simply not suitable for your current traffic, you need a better one
 
Consider changing hosting then
You are using Cloudways because they are available to help you dealing with this kind of matter
If they don't offer this kind of support, it's like using Vultr or Digital Ocean directly...cut the intermediary if the intermediary doesn't offer anything
 
so you have no idea how to login into your server via terminal?
Nop.
Do you have SSH acces on your vps? If so you can easily check that is spiking your CPU usage by using linux tool called "htop". It will show you a list of processes currently happening and you can pinpoint if it is a wordpress or database issue or some DDOS attack.

If you are not being DDOS'ed I would suspect that your database is being corrupt. Unfortunately as your wordpress website is old your chances of getting a corrupt database are significantly higher.
Wordpress is not very optimized and it is writing a lot of lines daily in the database which easily eat your ram/cpu.

You can try to restart your VPS if you have ssh access or maybe you can restart on your hosting panel.
That should temporarily reduce load on your vps if the issue was caused by wordpress/database.
Ok, I will read a guide and use the command.

In the section Error Logs of Cloudways I found a lot of errors like this:

[proxy_fcgi:error [pid 1094260:tid 1094493 [client 35.92.233.87:0 AH01071: Got error 'PHP message: PHP Warning: Undefined array key "access_token" in /home/MYSITE/gvyhanbtaf/public_html/wp-conte............/plugins/wordpress-seo/src/config/oauth-client.php on line 73PHP message: PHP Warning: Undefined array key "created_at" in /home/MYSISTE/gvyhanbtaf/public_html/wp-content/plugins/wordpress-seo/src/config/oauth-client.php on line 74'

I think is Yoast SEO.
 
Nop.

Ok, I will read a guide and use the command.

In the section Error Logs of Cloudways I found a lot of errors like this:

[proxy_fcgi:error [pid 1094260:tid 1094493 [client 35.92.233.87:0 AH01071: Got error 'PHP message: PHP Warning: Undefined array key "access_token" in /home/MYSITE/gvyhanbtaf/public_html/wp-conte............/plugins/wordpress-seo/src/config/oauth-client.php on line 73PHP message: PHP Warning: Undefined array key "created_at" in /home/MYSISTE/gvyhanbtaf/public_html/wp-content/plugins/wordpress-seo/src/config/oauth-client.php on line 74'

I think is Yoast SEO.
Yep it seems that Yoast seo is causing issues. A simple reboot of your machine will most likely fix the issue. Alternatively just disable the plugin/reinstall it, but I would advise a reboot.
 
Nop.

Ok, I will read a guide and use the command.

In the section Error Logs of Cloudways I found a lot of errors like this:

[proxy_fcgi:error [pid 1094260:tid 1094493 [client 35.92.233.87:0 AH01071: Got error 'PHP message: PHP Warning: Undefined array key "access_token" in /home/MYSITE/gvyhanbtaf/public_html/wp-conte............/plugins/wordpress-seo/src/config/oauth-client.php on line 73PHP message: PHP Warning: Undefined array key "created_at" in /home/MYSISTE/gvyhanbtaf/public_html/wp-content/plugins/wordpress-seo/src/config/oauth-client.php on line 74'

I think is Yoast SEO.
you need to ask some help to someone who knows to handle your server via terminal, otherwise you can do some bad things to it without knowing how to handle it. You need to check access logs to see if there are some hardcore crawl requests, if are bots, what kind of bots. your problem is not even for newbies on server side problems.
 
How can I check that with Cloudways? It is not cPanel.
You will probably have to use the terminal if you don't have simplified interface like cPanel available.

Nop.

Ok, I will read a guide and use the command.

In the section Error Logs of Cloudways I found a lot of errors like this:

[proxy_fcgi:error [pid 1094260:tid 1094493 [client 35.92.233.87:0 AH01071: Got error 'PHP message: PHP Warning: Undefined array key "access_token" in /home/MYSITE/gvyhanbtaf/public_html/wp-conte............/plugins/wordpress-seo/src/config/oauth-client.php on line 73PHP message: PHP Warning: Undefined array key "created_at" in /home/MYSISTE/gvyhanbtaf/public_html/wp-content/plugins/wordpress-seo/src/config/oauth-client.php on line 74'

I think is Yoast SEO.
That might be it if it's repeated constantly.
 
You will probably have to use the terminal if you don't have simplified interface like cPanel available.


That might be it if it's repeated constantly.
I don't think some PHP errors can make CPU go off the roof. That will happen only if there are hardcore requests somehow, but I'm pretty sure if that's the case he can't even open the error logs file. If he can't manage his server via terminal then he needs to get managed hosting and meanwhile start learning how to manage it by self.
 
Like this "[proxy_fcgi:error [pid 1094260:tid 1094493 [client 35.92.233.87:0 AH01071: Got error 'PHP message: PHP Warning: Undefined array key "access_token" in /home/MYSITE/gvyhanbtaf/public_html/wp-conte............/plugins/wordpress-seo/src/config/oauth-client.php on line 73PHP message: PHP Warning: Undefined array key "created_at" in /home/MYSISTE/gvyhanbtaf/public_html/wp-content/plugins/wordpress-seo/src/config/oauth-client.php on line 74'"

A lot every minute. Can I restart the server without terminal?
 
Like this "[proxy_fcgi:error [pid 1094260:tid 1094493 [client 35.92.233.87:0 AH01071: Got error 'PHP message: PHP Warning: Undefined array key "access_token" in /home/MYSITE/gvyhanbtaf/public_html/wp-conte............/plugins/wordpress-seo/src/config/oauth-client.php on line 73PHP message: PHP Warning: Undefined array key "created_at" in /home/MYSISTE/gvyhanbtaf/public_html/wp-content/plugins/wordpress-seo/src/config/oauth-client.php on line 74'"

A lot every minute. Can I restart the server without terminal?
You can restart it from you digitalocean account but that will not solve your issue. You really need someone who knows how to check all the logs and interpret them to can find out exactly what cause the problem. There can be just some hardcore crawl from some bots. But no one can guess your problem without checking it properly.
 
I have already restarted the server now I will download Putty to check it again more thoroughly.
 
I was able to connect with Putty and I am checking. On the other hand Cloudways support replied as follows:

I hope this message finds you well. We have again thoroughly investigated the issue, monitoring traffic statistics and reviewing slow page loads and database queries over the past few hours. While traffic statistics appear normal, we've identified some slow MySQL queries that may intermittently stress the server's resources. Please refer to the screenshot below for details:



To address this issue, we recommend optimizing your database. You may find plugins such as Breeze, WP-Optimize, or WP-Sweep useful for this purpose. Should you require further assistance, please don't hesitate to reach out to us again.

As I have Ezoic I don't know if I can use one of those Plugins, now I will check with Ezoic who makes use Leap. Any recommendation?
 
Maybe your wp needs an update also check if the php versions are compatible
 
I have the latest version of WordPress, PHP 8.0 and MariaDB 10.5
 
Update: I was recommended to install WP-Optimize to optimize my database. They also did something on the server, and it seems to have improved. Any extra tips to optimize the database?
 
Back
Top