Reduce WordPress CPU and Memory Usage Easily

Easy guide to reducing WordPress CPU usage that is particularly useful for shared hosting. WordPress is  great publishing platform, but is seriously lacking when it comes to optimizing performance. To fix the bulk of performance issues associated with WordPress you need to solve two fundamental issues. The first is that for every page loading WordPress accesses a database on the server, which can be resolved by caching. The second issue is that WordPress runs its Cron updates too frequently, which can be resolved by setting up the server to run Cron tasks at lesser intervals. With these two fixes in place your WordPress blog will not only use less resources but will also load faster for visitors.

WordPress Caching

A WordPress cache works very simply by storing page information in individual files rather than the database. The thing with WordPress is that each individual component of a page needs to be accessed separately, including each and every plugin. This puts an understandable drain on resources. A cache works by making a copy of these requests and keeping it stored so that the database requests are minimized. The benefit of this is speed, the cost is that updates to page elements like new content on the sidebar will not appear until the cache is regenerated. This is something that is important to keep in mind when updating your site after installing caching. The cost, however, is very minor compared to the great benefits and this has lead some to argue it should simply be  a default feature of WordPress.

Caching can very easily be installed as a plugin. My personal choice was Quick Cache due to its simplicity, but there are quite a few such as W3 Total Cache and WP Super Cache.

If you go with Quick Cache, I recommend a Cache Expiration Time of 7200 seconds if the default 3600 seconds does not prove sufficient for performance increases.

Cron Rescheduling

Cron is simply a system that runs automated maintenance tasks associated with your website and more specifically your WordPress blog. The problem, however, is that WordPress runs this far too often. The solution is a little more complicated than caching, but well worth it and in my case yielded far greater performance increases than caching due to the large volume of my site. It is worth noting that to implement this fix you need access to the CPanel account associated with your hosting.

Step 1:

Find the wp-config.php file in the base directory of your WordPress blog and add the following line:

define(‘DISABLE_WP_CRON’, true);

Step 2:

Login to CPanel and go down to Advanced Section then click Cron Jobs (highlighted here in red).

CPanel Advanced Cron

Once you have clicked that, go down to Add New Cron Job and select Twice a Day in Common settings and then add the following line to the command section:

/usr/bin/php -f /home/username/public_html/wp-cron.php >/dev/null

You may need to change the path to reflect your own server settings. For example ‘username’ should be your username.

It should thus look like this:

Add New Cron Job

Then click ‘Add New Cron Job’.

What this means is that twice a day the cron is scheduled, rather than the default which is roughly every 15 minutes or so depending on plugins. This will dramatically improve your WordPress performance.

Related posts: