In October 2016 the server load stats of my hosting account showed that this WordPress site regularly used up more than the allowed 100 CPU-minutes per day. I contacted support and, as always with ICDsoft, received a prompt reply:
The highest CPU usage belongs to the WordPress index.php file, and to the wp-cron.php script. All WordPress requests go through its index.php file. That’s why it is hard to determine which is the exact module/plugin that is causing the load. However, you can reduce the CPU usage of the wp-cron.php script.
You can disable the default WordPress cron, by adding the following line to your wp-config.php file:
Then, you can set up a cron script to run wp-cron.php every hour, via the Cron Jobs section of the hosting Control Panel. You can name the script wpcron.sh. For example, you can use the following code for the cron script:
GET “http://www.prepressure.com/wp-cron.php” > /dev/null
This should greatly reduce the number of executions of the wp-cron.php script and will lower the related CPU usage. The number of such executions for yesterday is 1450. You can also review your currently active plugins and disable the ones that are not essential for the operation of your site.
Since I only had about a dozen WordPress plugins running, it seemed logical to make the above changes. I configured the new script so that it would run once every hour.
After monitoring server load for a few days, I noticed that the suggested changes had not made any difference. I contacted support again, who added one vital piece of information to the above procedure:
It seems that you’ve attempted to disable the automatic wp-cron.php execution with the following line: define(‘DISABLE_WP_CRON’, true);
However, the line is added at the bottom of the wp-config.php file. Please try moving it above the following line: /* That’s all, stop editing! Happy blogging. */
Doh! After moving the line to the correct spot, server load did decrease significantly. Below you see the resource usage graph, with the red line indicating 100 CPU minutes. I made the second change around 4 November, causing load to drop by 25% or so.
What is left unanswered are two basic questions. I haven’t made any significant changes to this site in the past year, so why did the server load suddenly increase so much? On a more fundamental level: this site had a similar number of visitors several years back. I used WordPress with about a dozen plug-ins in those days, and its setup has not really undergond major changes. Back then CPU load was not an issue. With Moore’s law in mind, shouldn’t server load have dropped significantly over the years? Or does the hosting company compensate for that gain by increasing the number of sites that are hosted per server. If you have any insights on that latter question, please add a comment.