CPU / Memory Usage Skyrocketing

April 4, 2018 459 views
PHP Nginx Ubuntu 16.04

Can someone point me in the right direction to figuring out what is going on with this? My server will skyrocket (seemingly) randomly in terms of CPU / Memory usage. Seems mysqld and php-fpm will cause the usage to go crazy. It only happens for a short time, and then things go back to normal.

This is what my graph looks like:

https://imgur.com/g3jMtG1

This causes my PHP based sites (Wordpress) to crash.

Thoughts?

Thanks in advance!

2 Answers

You've narrowed the issue down to mysql/php and since you are running WordPress my guess would be that you have a plugin or theme that is doing something to max out your resource usage.

Do these spikes occur only when someone is viewing the site or randomly even when there is no traffic? If it's the later I would recommend checking any cron jobs (scheduled tasks) that your plugins may be using. A plugin designed to back up your WP site could potentially cause a spike like this when it dumps the whole database through php to a file.

If you are running 3rd party plugins the best way to determine the source of the issue would be to disable these plugins and re-enable them one at a time to see if the issue recurs after a particular one is running. You can also check your access and error logs during the times of the spikes to see if anything is recorded.

Nginx access/error logs are in:

/var/log/nginx/

PHP-fpm logs can be found in:

/var/log/php-fpm/

B MI FREND I NEED SUM SO PLZ B MI FREND BECUZ I DONT HAV ANEE SO PLZ BE MI FREND THX ;)_

Have another answer? Share your knowledge.