I have a wordpress site on digital ocean with following configuration
ubuntu 18 OS, php7.2-fpm, mariadb, wordpress

they are hosted on a 80$ droplet, A 4 core dedicated cpu droplet still my site goes DOWN, on checking graphs everything is normal i.e CPU usage is 20%, Disk at 50%, Memory at 33% but still site gives a 502 error during high traffic.

when i SSH into droplet and use Ubuntu’s command htop i see a single mysql pid using upto 200% CPU, is this a reporting problem ?

why all 4 core of my CPU is around 20-40% but a single pidof mysql is using 200% CPU internally and crashing the site and how can i fix it ?

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.

Submit an Answer
3 answers

Guessing you’re using the default Wordpress Droplet “out of the box”? If so, you likely need to do some tuning as I recall it is not configured to run production.

Really truly need more information about what plugins you’re running with Wordpress as well and what kind of site it is. Running Woocommerce with a healthy dose of supporting plugins can really put load on things compared to a blog with many more concurrent users.

Without much information the first thing I would do is split the web server out from the database and possibly switch to Nginx, or if you’re running woo or some heavy php utilization app then apache with nginx as reverse proxy.

Then Install MySQLTuner if you’re still seeing the same issue if you’re looking for more help. It will take you another step.

Finally, I love NewRelic for application tuning!

  • i myself have configured all the things from scratch & also downloaded latest WordPress from their site and uploaded via ftp, then configured it with database and it works fine with 98% uptime, it crashes when traffic is very high, i have some 7-8 plugins all very normal like yoast SEO, Niginx-helper, one ads plugin etc etc nothing fancy.....yeah i am not using woo commerce its just a news blog with very light theme (bimber) you can find in evanto market.

    this is the screenshot from htop seen via SSH, may be it can be of some help.


  • in the end i cracked it, as mysql was giving problem, i ran SHOW FULL PROCESSLIST command in terminal & i got the query which was causing mysql to to reach 100%, by querycy i narrowed down the plugin which caused it and removed that plugin “wordpress popular posts”, now things are ok, also i also configured redis cache.

There is no one thing that you can show that will fix your issue. Troubleshooting performance is a process of first validating configuration. You’ve built your own from scratch so that will be a complicated step by step process only you can undertake.

Once you’ve validated you don’t have any basic configuration mistakes nor any basic tuning for the volume you’re seeing, then you turn to basic performance tuning: you always go after the biggest bottleneck and work through each one until you’re satisfied.

For you, that is CPU (I’m not convinced you’re looking properly at I/O nor at Memory. Based on the way you are giving %s for each you’re looking at monitoring that is used for capacity management, not problem or performance management. htop is a start, you should also be concurrently looking at iostat, mysqltuner, maybe even give Nagios a go, but that will take you time you likely don’t have. Percona does consulting, and there are wordpress tuning experts, but that will cost you a fortune or get you nowhere cheaply.

The short of it: there’s no easy answer here if you really believe your tech stack is properly configured. You have to do the hard work of troubleshooting and monitoring specifically during your problem periods at a much tighter interval (seconds instead of minutes).

Honestly you would be better off not building from scratch, but instead using a container configuration tuned and configured by people who’ve already done the hard work of performance tuning and configuration management. They’ve made the mistakes for you and fixed them. You’re just kind of starting from scratch. You can do that and use a basic plugin to migrate to a new set of containers.