CPU usage spiked heavily lately. ISP support says it’s okay but I’m worried. I had this problem before and thought it was fixed. I have no idea why it’s using this much CPU time, and I really wanted to get to the bottom of it.
The culprit must be wordpress, but what exactly is causing it? I don’t open the dashboard until I’m ready to post, I barely even use the system. Most articles and forum posts say plugins, some say themes too. I don’t have that many plugins, having stripped to the most essential. Then I found a really detailed and helpful guide.
Step 1: check system
I followed the guide and checked awstats, server response time, GTmetrix. The website is slow, but not alarmingly so. From awstats I saw I was being pinged a lot by crawler bots, with bingbot taking almost 5GB bandwidth. I googled around and added to my robots.txt file, I’ll check back in a week or so. I don’t really care about SEO ranking and being visible on search engines so I’ll test by banning all the big searchbots, especially bing.
The guide has a link to a huge list of bad bots I can add to .htaccess, I’ll see if the robots.txt fix works first.
Step 2: configure wordfence
Wordfence also has some controls that limit crawlers and physical views. The lower the time I allow crawlers and the fewer chances I give them, the better. The guide also gives me settings to reduce the CPU time Wordfence itself uses, it’s quite a demanding plugin. An example is its live traffic report, which I don’t use.
Step 3: install WP-Disable and WP-Optimize
Seems counter-intuitive, to install more plugins. WP-Disable lets me turn off a lot of CPU intensive tasks, so I’m happy to install it. I disabled or reduced emojis, google maps, fonts, pingbacks, and the like. These features aren’t in use, so why not turn them off.
WP-Optimize cleans the database, I can schedule it to automatically clean once a month. It’s like defragging a hard disk I suppose.
Step 4: uninstall high CPU plugins
There is a list of slow loading or high usage plugins. Jetpack and WP-Statistics are the only two I use and I went into their settings to disable unused functionalities.
There are other things to do, that I didn’t think applied to me. I’m not sure I can justify more additional cost by using a CDN. And the last part of the post is basically an ad for an ISP, so I ignored that.
The results are striking. Such a big relief, looking at this week’s CPU resource usage. I wish I had the patience to only make one change at a time, so I can see what was the culprit. I still don’t know what exactly was causing the heavy CPU time, but it’s okay, it’s the end result that matters. The obvious ‘if-only’ is if only MT didn’t stop working. Even after 2 years, I’m not at all happy or confident of WP.