What is high CPU usage and how can I reduce my usage?

What exactly is CPU Usage and What does it mean to your hosting account? CPU time (or CPU usage, processing time) is the amount of time for which a central processing unit (CPU) was used for processing instructions of a computer program, as opposed to, for example, waiting for input/output operations.

The web server's CPU is used to obtain and serve your web pages to your visitors, whether these pages are static or dynamic is totally irrelevant. More CPU cycles or resources are used when your web pages are served dynamically from a database or script, since the database has to do some fair amount of processing to construct and serve these web pages to the visitors. It has to load the web template, obtain data for that particular page from the database, execute any plugins or modules that you have installed, and finally package the page to be served to your website visitors.

CPU time is a finite resource shared by all websites hosted on a particular web server, if any one website uses the CPU excessively; other websites on the same server will be deprived the opportunity to serve their pages in a timely manner, and will often appear either appear to be sluggish.

As a result of this, we usually monitor the amount of CPU your site uses on shared web hosting plans, to curb problems when a single website uses too much of the CPU time, adversely affecting other websites on the same server. Each hosting account has a CPU usage limit, which, when reached, may result in the account being suspended.

To reduce the CPU usage of your account, there are several general rules that you should follow:

  • Upgrade all third-party web applications to the latest stable release available (Drupal, Joomla, Word Press and any other content management or blog systems, forums, galleries or any other scripts that you have installed on your account)
  • Check to see if any of the web applications that you use have add-ons or plugins, and make sure they are upgraded to the latest available versions
  • Perform a general house-keeping and remove any unused web applications and/or plugins/add-ons that you have installed
  • Any web applications that allow caching should have this feature enabled or activated.
  • If you have developed your own script(s), try reducing the number of MySQL/MSSQL/ PostgreSQL queries and optimize your scripts to use less processing time.

To deal with and reduce a high CPU usage on your hosting account, you must in the first instance identify the reasons for the high CPU usage. Identifying these reasons can be quite difficult, most especially if you are using third-party web applications such as forums, content management or blog systems, which you have not developed yourself, and have little or no knowledge about how they use system resources.

There are, however, several things that you could check that would give you head start:

  1. Troubleshoot and identify the website that is most likely to be responsible for the high CPU usage: If you host more than one website (domain/sub domain) in your account, you should start by identifying which one is most visited and which one generates the most traffic - this is probably the one that's responsible for the high CPU usage. Concurrent hits to any of your website can have an effect on the CPU. Go to the Bandwidth Stats section and find out which of your websites (domains or sub domains) has generated the most traffic for the past day and for the current month.
  2. Drill down deeper to identify the file that is most likely responsible for the high CPU usage: Once you have established which website has generated the most traffic by looking at the Bandwidth Stats, go to the Traffic Stats section of your Web Hosting Control Panel and view the traffic stats for this domain/sub domain for the current period. Look for the file(s) that have generated most traffic - this can normally in the report by looking at the Top 10 apps, Total URLs by KBytes table. Look particularly for any PHP/CGI script files in this list that have generated unusually high amounts of traffic. This file(s) is most likely the reason for the high CPU usage and you should consider optimizing it.
  3. Identify the visitor/host that is most likely responsible for the high CPU usage: Like in step 2, look at the monthly traffic stats for your domain/sub domain and look for the visitor/host that has generated most traffic this month. You will find the list under Top 10 of XX Total Sites by KBytes - look for any hosts that have generated unusually large amounts of traffic (when compared to others in the same period) - this will either be an IP address or a hostname of some sort, somedomain.com. Once you have identified this host or IP address that is zapping up CPU time, you may want to consider blocking access for this host(s) or at least restrict it to reduce the CPU usage of your account.

In conclusion, if you are still unable to reduce the CPU usage of your account after following the advices given in this article, you should either look for the help of a professional developer or simply consider the fact that should switchover to a semidedicated or a cloud hosting plan.

Was this answer helpful?

 Print this Article

Also Read

How do I limit what the search engines can index ?

Various search engines such as Google have what are called 'spiders' or 'robots' continually...

What is phpSuExec?

phpSuExec (pronounced sue-eksek) is a more secure environment for PHP. All of our shared servers...

CAPTCHA: Telling Humans and Computers Apart Automatically

A CAPTCHA is a program that protects websites against bots by generating and grading tests that...

How to flush DNS cache in my PC?

How to flush DNS cache in Linux / Windows / Mac Flush dns to get a new name resolution. Also...

How do I activate SSL in osCommerce?

In order to configure osCommerce to work with SSL please open the file...