Issue: This simple WordPress site was randomly spiking the CPU for over a year at 75-100%. Once every 2-4 days, sometimes every day. Sometimes for five minutes sometimes for an hour. When checking during an event Apache was always the high CPU consumer. As it’s just a hobby I was interested but not too worried, but… people may be having trouble visiting this amazing website! LOL. The options were to turn off monitoring (it’s fixed!) or see if we could find the culprit. We learned a lot on the way as always!
Solutions that helped but didn’t resolve
- Database Housekeeping – manually deleted thousands of WordPress post revisions and a lot of orphaned database tables and data – here’s some handy SQL queries for cleanup. Ran optimization and tune up plugins. The database dropped from 35megs to 12megs. Ten years of WordPress plugin cruft and changing various settings 2.5 millions times may do that.
- NGINX – Building a clone of the site using the LEMP stack. I figured a clean build + NGINX the optimal Web Server engine for WordPress (so some say!) might do the trick and would be fun to learn. I abandoned when I started getting similar high CPU reports to what I’d seen with my LAMP build.
- Fresh start – built a fresh LAMP droplet. All the latest tools and my amazingly honed new admin skillz having now done this least 3 or 4 times! Fresh setup of everything, except the database. Initial hopes soon crushed when High CPU reports started coming in after 4 days and continued. Like the Windows guy I am I tried rebooting as last resort knowing full well it wouldn’t help because, it’s not Windows…
- Plugins – Deactivating caching and other suspect plug-ins that may perform resource intensive tasks.
- Update to latest – Apache, MySQL, PHP and Ubuntu
- Cron jobs – took a look, suddenly found myself in front of a medicine cabinet reaching for an aspirin…
Solution that worked – Like a lazy lad I dropped a Lincoln$ on it…
- Resized my droplet – by adding a second virtual CPU, upping my game to 2 vCPUs running with 2gb memory (rocket ship!).
- Hope – rarely do I give up on thee but why not try learning about… adding a CPU, mouse clicks can be tricky!
- This after years on a single $5 monthly plan, then the $10 plan – now paying $15. Hmm… evil plan by Digital Ocean or just WordPress getting phat with age?
- *No I do not work in the Digital Ocean Marketing department. Yes I suspect this is just a plot I’ve fallen into to sell me more of their services.