I will begin by saying that I am not a WordPress expert, I do know a little about MS servers (hence all the articles) but WordPress I am learning as it comes. So as the destiny decided to make aware of another aspect of WordPress, We got an email from my WebHost stating that our account has been suspended because of CPU overload. Though they were kind enough to restore it once but wanted an assurity that we will fix whatever is causing the High CPU overload. Hence the learning started. I read a lot of articles and discussion from the very kind and big WordPress community and made some interpretations of my own.
Following are the steps I took to resolve the issue or rather the way I approached the problem.
Ask your WebHost:
Usually the Web Host’s support team is helpful and after all they felt that your site is over utilizing the CPU and suspended you. So lets ask them the following questions
a) How much over the quota am I ?
Probably they allow you 100,000 cycles and you are at 125,000 cycles. It’s best to know, it gives you an idea of how deep are you
b) Whats causing the CPU over load?
CPU over load can be because of Plugins , widgets , theme or may be just the visitors. They may not be able to answer very clear (But try to drill them a little), it may result in meaningful information. At least they should provide you which files are being queried upon the most and the name of the files should be able to give you a fair idea if its Theme, Plugin or widget.
c) Whats the solution ?
Usually webhost wouldn’t be able to provide you a solution to your issue but No harm in asking after all we are their customer and we have a right to ask.
Start Monitoring your site
Yes, its time you take charge of the situation. There are tools available in your Cpanel which will help you see how many executions/CPU usage your site is doing. You may not be able to understand the figures much but monitoring graphs and other numbers will help you understand if the steps which you are going to take next are actually helping the situation.
Following are the tools which are available in SiteGround CPanel, your Cpanel may or may not have all of them
Optimise your site
Now that we know how to monitor the situation, lets start working to fix it as well.Usually resource overload is due to plugins on your site, so its best recommended to keep the plugins to minimum. Only add and activate the plugins that your really need. Same goes for the widgets. And now that you are facing the issue, it will be a good time to disable and delete the not needed plugins. Once you have deleted all the unused plugins/widgets, it’s quite possible that you still have quite a few of them which are active. And it’s also very well possible that one of those is causing the problem. The Big question is How to find which Plugin is causing the most CPU utilisation.
Thankfully, we have a plugin for that too :), it’s called at P3 (Plugin Performance Profiler), Install this plugin and run a scan, it should be able to give you a fair idea if and what plugin is causing the resources overload. Once found you can either look for a fix from plugin developer or look for an alternate plugin with same functionality.
What Is a Cron Job?
cron is a Linux utility which schedules a command or script on your server to run automatically at a specified time and date. A cron job is the scheduled task itself. Cron jobs can be very useful to automate repetitive tasks.
Wp-Cron are the schedule tasks of WordPress, the problem is they are very sensitive to their schedule.By default WordPress is setup to call wp-cron.php every time someone visits your WordPress website when a scheduled task is present, to basically ask “is it time to do anything yet?”.
By the times there are not many visitors on the site, its fine to have such annoying schedule but once you have a good amount of visitors this repeated tasks can cause very high CPU utilisation. So the solution is to probably run the task once or twice everyday and not with every visitor.
How to Disable Wp-Cron.php
1) Open FileManager from your WebHost Cpanel
2) Browse to the WordPress installation root directory for example “/Home/Grishbi/PublicHtml”
3) Take a back up of WP-config.php and than edit it
4) Add the following line of code at the top or bottom of the file
5) Save and exit of the WP_config.php
Setup Manual Cron Job
Now that we have disabled the automatic Cron Jobs , we need to manually create a schedule for Cron Jobs
1) Go to WebHost Cpanel
2) Under Advanced , click Cron Jobs
3) Under Add New Cron job -> Common settings -> select Once in a Day or what ever you like
4) In the command box add the path to your WP-Cron.php file after replacing the domain/account with your website name. (check this path in file Manager). This step is also visible in the image above.
cd /home/Name/public_html; php -q wp-cron.php
Are Crawlers the curlprit ?
Some times your web host will simply tell you that it’s not your theme or Plugins/Widget but it’s actually the visitors which are causing this issue. No matter how much we want it to be true, buts it’s actually not. If you analyze the situation you will find that 60% of the visitors which its talking about are the Crawlers or Bots or Spiders. Aspiring search engines (there are many) run continues scans across the web and hence scan your website every now and then. At times they do not have the correct compression algorithms as well and they end up eating a lot of resources of your website including CPU and Bandwidth. You want the crawlers to check your site but not all and especially if any one hitting your site repeatedly.
How to Check and Block Crawlers
The easiest way to do anything in WordPress is to find a plugin for the task, unfortunately that’s always not the best way as I wrote above that you should keep minimum plugins. Any which way there is a plugin available for this task as well and its highly rated and used by many.
The plugin has various features including scanning your site of vulnerabilities, caching and Firewall, it’s the firewall we want to use here. The plugin is capable of distinguishing between Human visitors and Crawlers, it also gives you a capability to block any IP or Crawler. There this tab which tells you about IP which is utilising the site the most, it will usually be some crawler and you will get an option to block the IP there and then. WordFence can also be configured with Firewall rules to automatically block IP’s over abusing the site.
Robots.txt is a file in WordPress installation (you can create if not present already) which basically allows or disallows Bots (or Crawlers) on your site, so you can create or Edit this file to deny access to not needed BOTs from your site. Like the following ROBOTS.txt allows access to only a few Google and MSN based bots and deny access to all others.
Refer this link here for more details about Crawlers and Robots.txt
If you are genuinely getting visitors ?
Finally if you are among the lucky ones who are genuinely getting actual unique visitors causing the high CPU utilization than I consider it good news, probably you would like to upgrade yourself to better plan or virtual dedicated hosting. Talk to your web host and they should be able to give you a fair advice.
Still if you think its early to upgrade and you want to try other options than try enabling options like SuperCacher or CDN/CloudFare which does website caching and reduce the number of actual CPU execution required. WordFence also has some caching options though I am not sure how good are they.
Here, this article I have tried to share some knowledge, hope it helps you to fix the issue at hand. Else you may want to start a thread in our Forum, so that we can help you more with situation.
Latest posts by Shishir Chandrawat (see all)
- Exchange 2010 Std: Mailbox server has reached the maximum database limit of 5 Error RcrExceedDbLimitException - December 12, 2016
- Exchange 2010: Unable to add Mailbox Database copies on DAG member servers, Error: An error occurred while processing a request on server - December 12, 2016
- Unable to Mount Microsoft Exchange DAG Database, Error: Failed to determine the mount status of the active database copy - December 12, 2016