High CPU usage is a very common issue when it comes to shared hosting. Shared server hosts hundreds to thousands of websites and many of them are running PHP processes and MySql queries. There are many WordPress plugins that require more RAM and Processing power to work.

What may create High CPU usage problem

  • Lot of WordPress installed regardless of they are getting low traffic
  • Resource consuming plugins installed
  • Hacked hosting account
  • Buggy WordPress plugin or a PHP script
  • Real-time stats collector plugins
  • High number of online visitors
  • Self hosted Media streaming
  • Longer duration Simultaneous download connections
  • Running frequent and long run cron jobs
  • WordPress Heartbeat API

High CPU Usage WordPress - How to resolve-01

All above given things are the potential causes of high CPU usage. Now I am telling you how to resolve most of this kind of issues and how to tweak your hosting account to make it lightest for shared server.

Optimize WordPress database – Clean up database junk

Advanced Database Cleaner (ADC)

Image 2

We install and uninstall several WordPress plugins and themes time to time. And when we delete a plugin/theme, it leaves its tables and options in database. With the course of time there is accumulated lots of orphan tables and options in database making database unstable and resource consuming. So it becomes essential to cleanup this unused junk in database. Many free database optimizer plugins are available to install via WordPress repository. But I will recommend Advanced Database Cleaner. With the help of ADC, we can clean unapproved comments,  post revisions, comments meta, orphan relationships, orphan tables and options etc. ADC optimizes database tables too. Please note that cleaning orphan relationships, tables and options are pro features of this plugin and you can get its pro version shelling out just $15. I cleaned over 5000 orphaned options and 50+ tables with the help of Advanced Database Cleaner Pro.

Important

– Many plugin accumulate junk in their tables in the form of logs or anything. They can increase  database size drastically and make it unstable. For instance, Pretty Link store click stats in its prli_clicks table. This table added 75mb to my database. I discovered it via ADC and then emptied the table via phpMyAdmin. (do backup before emptying a table containing useless logs).

Download ADC

[Fix] Lots of WordPress installed regardless of they are getting low traffic

This issue many be resolved easily by using a good caching plugin. I recommend you to use W3 Total Cache that can cut 90% load caused by WordPress. But I will also add that if you have over 7-8 WordPress websites on a single shared host, you should buy additional hosting to host some of your blogs to this additional host as every WordPress needs RAM and CPU to run properly and these resources are limited on a shared hosting account.

[Fix] Resource consuming plugins installed

Use P3 Profiler plugin to find out which plugin is causing high load. Having found out about that plugin you should replace that plugin with any other better alternative. For example if All in One SEO plugin is taking higher resources then you should replace it with SEO by Yoast or any other light SEO plugin.

Tip – Deactivate all your plugins and then reactivate them again. Sometime it sorts out the problem and reduces the CPU usage.

[Fix] Hacked hosting account

It is one of the major reason of high CPU usage. This issue can not be resolved easily. You can work manually to resolve this issue or you will have to take help of an expert. You can start with Sucuri plugin. This plugin scans your site and tells you about possibilities whether your blog is hacked.

Best way to protect your account from infections

If you want to protect your hosting account from unwanted hacking attempts, you should have full backup of your hosting account for last 30 days so that you could restore it from any previous unhacked version. Make sure whether your hosting provider offers free backup / restore facility.

Read

Guide to remove malware from WordPress

How to protect WordPress website from hackers

[Fix] eCommerce Website

Generally eCommerce websites need more system resources as they have a powerful ecommerce software in their core. If you are using Woocommerce you need at least 2GB physical RAM and up to 2 CPU cores burstable up to 100% usage. If your host’s CPU limit doesn’t meet these requirements, you should think to change your web hosting. Checkout our recommended hosting list.

[Fix] Real-time stats collector plugins

If you have any tracking plugin installed that collects traffic information of your WordPress website it may cause high load on database server. You can replace that plugin with external trackers such as Histats, Google Analytics, Sitemeter etc.

[Fix] High volume of online visitors

If hundreds of visitors hit your site at once, your hosting account needs more system resources and thus it may be a culprit of high CPU usage on shared server. Using W3 Total Cache plugin (with page cache, browser cache and minify activated), you can reduce load caused by high traffic. A reliable shared hosting can bear up to 3k – 4k visitors per day with W3 total cache plugin. If your traffic goes up, you should consider buying Managed WordPress hosting or VPS.

[Fix] Media streaming from your hosting account

Media streaming is against  terms of conditions of all shared hosting providers. So you have to buy VPS hosting for this purpose.

[Fix] Longer duration Simultaneous download connections

It is against  terms of conditions of all shared hosting providers. So you have to buy VPS hosting for this purpose. Shifting your downloads to 3rd party storage websites like Dropbox, Google Drive will fix this issue.

[Fix] Running frequent and long run cron jobs

You must control excessive run of cron jobs and schedule them at that time when Hosting server is least busy. Moreover you can run cron jobs in batch mode to reduce load on CPU. Generally WordPress backup plugins run cron jobs when you schedule backup. Ensure that your backup plugin uses batch mode to create backup and send it to any remote destination. Updraft Plus and Backupbuddy support batch backup creation and I recommend these plugins to generate backup if you use WordPress to generate backup.

[Fix] WordPress Heartbeat API function

With Heartbeat API function, WordPress automatically communicates between the web browser and the server. With the help of this function WordPress automatically saves various kind of data including drafts, revisions etc.. It is really a great thing to save post changes automatically as revision and drafts, but sometimes this function sends heavy loads on admin-ajax.php and that is why admin-ajax.php creates high CPU usage.

To resolve this issue, install free plugin Heartbeat Control (from WordPress repository) and locate it it in admin dashboard > Settings. Then configure the plugin as shown in the image below;

hearbeat-control-wordpress

Other possible tweaks

CloudFlare

CloudFlare cuts huge load caused by your websites. CloudFlare prevents spambots from visiting your website and thus saves your website from unwanted and useless traffic. Moreover CloudFlare caching system makes your site faster and lighter. CloudFlare comes free with most of shared hosting services such as Arvixe, A2 Hosting, HostGator etc.

Use External commenting system

By default comments are enable and we can’t ignore the importance of comments for a professional blog. That is why we can’t disable comments. But in fact most of blogs get thousands of spam comments per day that causes heavy load on database server. It is better to disable WordPress default commenting system and use a 3rd party commenting system. I would recommend Disqus.

Hope all these suggestion will work for you. But keep in mind if your host is not reliable you can never get rid of High CPU Usage issue. Over 90% hosts offer insufficient CPU per hosting account and it is impossible to resolve CPU issue on those hosting.

Use a free CDN service

CloudFlare, However, helps much reduce pressure on the server, but if a content delivery network (that serves media content)  was used, it will make all the difference. There are many premium CDN services are available including MaxCDN.

CDN (content delivery network) cuts most of the load delivering most of the site content from itself. A CDN provider can host and serve website images, js and CSS files making your website blazing fast and lighting up your server.

There are two free but of premium quality CDN providers are;

  • (recommended) Amazon CloudFront (free for one year) (you can set up your own subdomain to deliver content, such as we use content.inrealsense.com)
  • WordPress.com Photon (connects your self hosted WordPress via Jetpack plugin) (subdomain pointing is not available. Images are delivered with the direct links from wordpress.com)

Amazon CloudFront can be set up easily with W3Total Cache plugin and you can disable CDN any time.

Your web host may also be a culprit

There may be many chances that high CPU usage is not your fault and your hosting provider is not supplying sufficient system resources to your hosting account. In shared hosting industries most of the hosting companies offers cheap hosting but there CPU usage limit is very low. This limit is totally insufficient to run even a single WordPress website properly.

To fix this issue, confirm CPU usage limit and hardware configuration of the shared server on which your websites are hosted. You should confirm following things with your hosting support;

How much percentage of total RAM and CPU is allotted per hosting account? or

How much physical RAM is allotted per shared account? (should be at least 1GB) and How many CPU cores are burstable to 100% per account? (should be at least 2 cores)

If your host doesn’t live up to these specifications, you should change your host. You can consider some hand picked best hosting providers here