Any time our systems administrators flag your account for excessive resource usage, we try to provide the option to either reduce your website CPU usage, or upgrade your account to a VPS or Dedicated platform. This guide will explain what is excessive resource consumption, what causes it, and how to resolve issues.
- What is Excessive CPU Processing?
- Common Causes of Resource Usage Issues
- How to Resolve Excessive Resource Usage Issues
What is Excessive CPU Processing?
On a server the CPU or Central Processing Unit can be thought of much like the brain of the machine, almost any request the server has to deal with is going to require time from the CPU to process that request.
The level of CPU processing for a website should be very minimal compared with local desktop CPU activities. Realizing the impact on the server a CPU intensive website could be having can help prevent you from possibly running into an account suspension for having your account use up an excessive amount of CPU time.
As an example, an average WordPress site with a few plugins enabled on it and no form of caching, will typically consume around 1 second of CPU time, that is, it requires the attention of the CPU for at least 1 second before it can send back to the website visitor the full HTML code for their web-browser to display.
Most CPU activites that happen on the server will be in the range of fractions of a second of CPU time, to maybe at most 5 CPU seconds per execution. Where you can begin to run into problems is when you’re doing more intensive CPU activities that typically would be ideal on a desktop CPU, but not a server CPU that is being shared by other users.
If you are wondering “How much ram and CPU does my website need,” you can view your CPU resource usage in cPanel on the right-hand sidebar.
Common Causes of Excessive Resource Usage
In the previous article, we talked about CPU and memory usage and you may be wondering why is my website CPU usage so high? Now that you have a basic understanding of server resources, we’re going to cover common reasons a website is causing high CPU usage.
This can mean many different things. MySQL refers to your site’s database(s) and mysqld is the server that handles database requests. For example, if you have a WordPress website, it uses MySQL to store your website’s content in a database and database queries are handled by mysqld.
WordPress and MySQL high CPU usage issues are often caused by long running MySQL queries (asking the database for too much information) or excessive amounts of querying (asking the database for more information repetitively) which can cause your website to load slowly or even crash. This typically means mysqld is using too much memory.
Poorly-Coded Scripts, Plugins, or Modules
It’s a common misconception that all websites have the same CPU / Memory usage. This is not the case though. For example, a WordPress website with a default theme and no plugins uses far less memory than another WordPress website with a custom theme and 20 plugins. Also, keep in mind that a website with one poorly coded plugin can cause more CPU and website memory usage than a website with 20 well-coded plugins.
Sometimes it’s as simple as updating your plugins and scripts to the latest versions. Most developers will update their code to address resource usage and fix security holes. If your website is custom coded you may need to examine the code or contact the developers who built the website for you.
Cron Jobs are basic task schedulers. This allows you to schedule a script to run in specific increments like every minute, every hour, or every day. Cron jobs that aren’t configured properly or ran too often can cause high server loads which can affect how your site loads.
High traffic isn’t a bad thing. This means your website is getting a lot of visitors, and with the right marketing you can leverage that traffic into increased sales or whatever your chief objective may be. A great way to look at this is using a basic fish analogy:
Let’s say you buy a small fish and a tank for it to live in. Eventually, the fish grows and is happy and healthy. However, at some point, this fish may have grown too big to live comfortably in the original fish tank you purchased. It may be time to move to another tank to ensure your fish remains happy and healthy.
The same applies for websites. You may have simply outgrown your current hosting plan, and it might be time to upgrade to a different plan that better suits the needs of your CPU-demanding websites. Please read our article for more information on upgrading your account.
Search Engine Crawling
At times, we see our customer’s sites being crawled excessively by search engine bots. Having your site indexed by the search engines can be important so people can find your website. There comes a point where the search engines can be over-crawling your site which can affect your site’s ability to function as you have intended it.
Over-crawling your site can mean different things. Google and other search engines can be crawling too many pages of your website, especially ones that you do not want the public to see. Also, over crawling can mean they are making too many requests to the server. To resolve this please review our article on setting a crawl delay in Google Webmaster Tools or how to stop search engines from crawling my site.
One of the most common instances of excessive CPU processing would be from image manipulation. If you’ve ever loaded up Adobe Photoshop or some other image software on your desktop PC, you might have noticed when you try to resize a large image, or run certain filters on an image it can take a long time to finish. All along you are probably doing this on a dedicated desktop PC that may have two or more processors dedicated solely to your tasks with nothing else going on in the background.
On a server, especially if you’re using shared hosting instead of a VPS or dedicated server, there are multiple CPU cores, but they are constantly being requested to do little spurts of work to fulfill all the various website requests from all the users on the server. When you all of the sudden queue up 50 large image manipulation tasks for the CPU to handle, this can throw a wrench in the server being able to keep up with all requests globally, not to mention it can eat up close to a minute of CPU time per image manipulation, which would equate roughly to the same as serving up a standard WordPress site to 60 unique visitors.
It’s generally recommended when uploading images into an application that is going to resize or manipulate the image data on the server-side, that you first use a local desktop image application to optimize the images for the web prior to uploading them. There are also websites that allow you to upload and optimize images for free, such as TinyPNG. This will allow you to upload more images, faster, and without as much risk to your account’s resource usage becoming excessive.
Resolving Excessive Resource Usage Issues
In some cases it may not be possible to decrease your usage to levels that are acceptable on a shared hosting platform. You may be wondering, “Why do some websites use so much CPU?” Sites that require larger databases or are controlled by server-driven software (like PHP, Python, and Perl) and/or have larger images and files being hosted naturally require more resources in order to function properly.
Resource usage intensifies as traffic increases, which is why higher-traffic server-interactive sites tend to outgrow a shared platform more easily than static HTML sites. If your website uses 100% CPU, it is generally too resource-intensive for a shared system and an upgrade may be in your best interest.
Keep in mind, we cannot offer programming assistance or support for third-party software, and we cannot provide definitive solutions to decrease your usage. However, when possible, we can offer tips and suggestions that have helped other customers in similar situations.
Any site has the potential for high resource consumption, but some software has a greater potential to use more system resources than others. Software we commonly see associated with high resource usage are listed below:
- WordPress – How to Optimize WordPress , Setting up WordPress Super Cache
- Magento – Increasing Magento’s Performance (Note: the developers of Magento have warned about high resource usage, indicating that it may not be shared-server friendly.)
Since PHP and MySQL are server-side languages, the server has to compile every PHP page and process every MySQL query. If your site uses PHP or MySQL, caching can reduce your resource usage and improve the performance of your website load times. Caching stores PHP pages as static HTML files, so the next time the page is loaded, the HTML page is loaded instead. If you are using a Content Management System such as WordPress or Drupal, you likely have a caching system in place or can download a third party plugin to help with caching.
- WordPress – WP Super Cache
As databases grow they may need to be re-indexed. Indexing databases helps speed up how data is retrieved when a query is run. This reduces how hard the server has to work to get the data. Think of database indexes as a table of contents in a book. The index — or table of contents — allows the server to go to the specific place where the data is stored without having to “read” the entire database.
The easiest way to accomplish this is by logging into your cPanel > phpMyAdmin and running the ‘optimize’ or ‘repair’ commands against your database. Please read our article on How to Use phpMyAdmin to optimize a database.
Enabling Hotlink Protection
Hotlinking is more common with sites that serve a lot of images, such as gallery sites. Hotlinking is a term that describes when another site directly links to images on your site, and is generally frowned upon and described as “bandwidth stealing.” You can enable hotlink protection in your cPanel, but be sure to include your addon/parked/sub-domains in the ‘allow’ list so that all your sites function properly. Please see our article on Enabling Hotlink Protection for more information.
Search engines and robots can account for a large percentage of a site’s traffic, and most of this traffic can be unnecessary, so reducing it can save a lot of resources on the server. You don’t want to eliminate search engines altogether, but you should restrict them from being able to access directories that don’t contain content you need indexed, and you should block unfamiliar bots and spiders that are frequenting your site. You can identify the spiders and bots crawling your site by looking at your AWstats, and restrict their activity using a robots.txt file. Also, they may be crawling your website too quickly. You can use Webmaster Tools to set a crawl delay to help in this case. Please see our article on how to block search engines from crawling my site and our article on how to set a crawl delay using Webmaster Tools.
CSF Configuration (For VPS Users)
When it comes to resource usage, you may see or hear mention of ConfigServer and Security Firewall (CSF) configuration. This would only apply to VPS users, since a shared hosting account cannot access or create a firewall. There are are server-level security arrangements already in place for shared hosting. But we mention it here for additional context with regard to how CSF can affect resource usage in your web hosting account.
CSF configuration settings such as blocklists or IP deny lists can have a positive impact on resource usage by limiting certain types of traffic such as brute force attacks. Some CSF configurations may rely more heavily on disk I/O in order to perform their functions, which can be another source of increased resource usage. So having a balance in your configuration is important. Overall, it is necessary to take all these factors into account when configuring CSF in order to ensure that your server has the resources it needs for optimal performance. See the section below on upgrading your hosting plan in order to take full advantage of services like CSF.
Upgrading Your Hosting Plan
If you have a high CPU usage website, keep in mind it isn’t always an issue with the site or coding. It’s not uncommon for popular websites to start out on a shared hosting platform and eventually outgrow it.
If this is the case, typically our systems administrators will notify you of the plan you’ll need to upgrade to, which will provide minimum platform requirements to support your website with high CPU usage. For more information please see our article on upgrading your hosting package in AMP.
In most cases, when you choose to upgrade we will handle moving your account over to the VPS or Dedicated server, and most moves do not result in downtime for your site(s).
Trust your website to an industry leader in website hosting. Secure web hosting with InMotion Hosting and enjoy 99.99% uptime, 24/7/365 technical support, and risk-free money-back guarantee.