Linux – What are these 99+% peaks in Google Cloud VM CPU Usage

cloudgoogle-cloud-platformgoogle-compute-enginelinuxWordpress

So i got a Google Cloud VM which is running a woocommerce store. It works fine but now i got this problem for the second time. The VM's CPU Usage suddenly goes over 99% for a long period of time. During that time the site is basically offline.

When i stop the VM and then restart it it goes back to normal CPU usage which is <1% most of time and 1 – 10% some periods of time.

Also when i use sudo kill with the process id's of the .php-fpm.bin it solves the problem for a few hours but then it starts running the .php-fpm.bin again under a different PID.

Also when i use killall on .php-fpm.bin the website goes down altogether.

This is a big issue which can turn very bad very soon and i'm a beginner with servers.

Any help with the root cause of this will be very very much appreciated!

–EDIT–

Here is my CPU usage shown using 'top' on SSH:

result top on ssh

Something unusual is going on with .php-fpm.bin, anybody got an idea of what i might be?

This is visible when i type ps auxin SSH:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
daemon   10048 99.9  0.9 286860 71564 ?        R    13:13  83:15 php-fpm: pool wordpress 

If you need any other monitoring stats please do tell me what you need to know and i will look it up for you.

Best Answer

Caveat: I'm also not a server / sysadmin person but had to dive in earlier this year.

I've encountered performance issues like this when running node.js processes. It's possible there are parallels to what you're seeing. In my case, based on changes I experimented with it looks to have been related to hitting max pages limits.

These are configuration changes I performed that helped resolve issues:

In /etc/security/limits.d/custom.conf

root soft nofile 1000000
root hard nofile 1000000
* soft nofile 1000000
* hard nofile 1000000

In /etc/sysctl.d/99-sysctl.conf

fs.file-max = 1000000
fs.nr_open = 1000000
net.nf_conntrack_max = 1048576

To update running processes:

sudo sysctl -w fs.file-max=1000000
sudo sysctl -w fs.nr_open=1000000
sudo sysctl -w net.nf_conntrack_max=1048576

As root:

ulimit -n 1000000

You're milage may vary based on what's managing your processes.

Here's some documentation with further sysctl tweaks, some of which I plan to research and implement: https://easyengine.io/tutorials/linux/sysctl-conf/