CPU time?! Performance Statistics and Optimization!

CPU_Statistics_Optimization

The series of recommendations from the tech team at SuperHosting.BG hosting company continues with the promising topic of CPU time (CPU usage).

– What is CPU time?

– How is it calculated and what is included in the statistics?

– What are the main reasons for CPU usage increase? and – How to optimize your applications?

Those are some of the most interesting questions you are asking us about in the topic of CPU resources. And now is the time and place to reveal ‘the secrets’! 🙂 We will provide guidance about the optimal CPU resources usage based on six years of experience, your over 30 thousand operational sites and hosting accounts. Increased CPU usage is encountered in about 0.1% of websites, but it is crucial to pay attention to the ways for its optimal usage, since this is a limited resource shared by all clients of a shared hosting server.

What is CPU time?

This is the time required by a server processor core to execute the operations for script processing and to return a result. Also, 1 clock minute may equal several CPU minutes, because the CPUs usually have multiple cores (8-core, 16-core …). 🙂

How is it Calculated and What is Included in the Statistics?

The CPU time calculated for the shared hosting service only includes the processing of scripts (php, perl, python and other scripts) that the server is running. The statistics doesn’t contain the time for ‘serving’ the static content (css, js, images, etc.) and the time required for SQL processing of the queries in the websites. Statistics about the used CPU time may be found in your customer profile in the ‘Hosting accounts’ section -> ‘Details’. Bear in mind the information is updated every 24 hours.

Our system calculates the CPU resources on account basis, not on the basis of the websites, hosted on the account. (That is very important for the proper analysis of your apps!)

In most cases the increased CPU time usage is not due to a single script that is being executed for a long period of time and/or spends a lot of resources. Very often the scripts in a account are executed within milliseconds, but they are executed hundreds or thousands of times, which leads to accumulation of time, necessary for CPU operation.

The analysis!

The analysis of the CPU time spent requires you to give at least a little bit of your personal time (of your CPU usage) :).  A lot of useful information to help you with the analysis and optimization may be found in the Logs section of the control panel: Cpanel – Raw Access Logs and Awstats. From the statistics, you need to analyze the information in the following sections:

  • Days of month (Number of visits, Pages, Hits)
  • Pages-URL (Top 25)
  • Hosts (Top 25)
  • HTTP Status codes

That way you can track the visits on a given day, the IP addresses from where the site has been accessed, as well as the pages loaded.

Common reasons for increased CPU usage:

– dynamic photographs processing (dynamic visualization, thumbnails creation, placing a water mark on the image, etc.)

And here is some more information about the dynamic and static ‘serving’ of images:

The CPU time statistics, as we mentioned above, contains calculations about the time required for scripts processing by the hosting account (in this case, php scripts) while the time necessary for ‘serving’ static content is not accounted for. An example of dynamic image processing would be a picture visualized in a way similar to this one:

http://domain.com/image.php?path=image.jpg

To display the image, the script is invoked every time. Sites, however, usually do not contain just one image. For example, if a webpage contains 5 images, the script would be invoked 5 times, and that is just for one user, upon one page loading. The website, however, does not have just one user, and the page is not being loaded just once. That leads to the execution of the same script over and over, which leads to a non-optimal increase of the resources used.

Serving’ static content consists in invoking the picture directly, without using a script:

http://domain.com/image.jpg

Often times, most CMSs use scripts for dynamic resizing and images ‘serving’, such as phpthumb, timthumb and others. As the site grows, such scripts start spending resources in a non-optimal way and an apt solution would be to ‘serve’ them as static content.

– deployment of PHP chat, live chat, ShoutBOX ;

– statistical modules;

Such apps generate many hits to the web server, often every second, so that the information may be transmitted in real time. That also leads to a great increase in the resources spent.

– unnecessary fetching / hits on a large quantity of elements (images) per webpage, missing elements

– deployed system for ads management (PhpAdsNew, OpenAds) and others;

The automatic hits on certain elements or pages leads to unnecessary hits to the web server. The missing elements on the site can also increase the resources, if, for example, the 404 error is processed by PHP. An apt way of processing 404 errors is the use of SSI.

The ads management systems also use php scripts for content visualization, and upon increase in the number of hits, the CPU time usage also often increases.

– multiple visits and indexing by search engine crawlers.

Based on our experience, we’ve seen that bots are sometimes very aggressive upon site indexing. If you notice an increased indexing by bots, you can block them temporarily with the .htaccess file or decrease the frequency of site crawling. You can do that through the Crawl-Delay function in the robots.txt file.

The conclusion or our advice

We recommend that you always work towards apps optimization. Apart from decreasing the server resources used, that way you will also speed up your websites operation. By avoiding the above mentioned ‘Common reasons for increased CPU usage’, as early as the development stage of your website, you will avoid many technical issues manifested both during peak overload, and when it comes to sites with more visits. Still, the optimization alone is not always enough. There comes a time when a next-level hosting solution has to be selected due to the volume of visits and data contained on a given site. What we can help you with, is that we offer all the necessary hosting solutions and quality to satisfy the needs of any site, at every step of the way! 🙂

We’d like to give our special thanks to our colleague Rossy – Tech Support Dept., for the summarized and accurate information, included in this publication! 🙂

We will be happy to answer any and all your questions you may have about CPU time!

Finally, make sure you don’t miss any other useful tips from our colleagues, as well as everything else that is interesting and new in the world of hosting services, by subscribing to our blog. Don’t miss our Facebook fan page, and follow us on Twitter too.  🙂 

SuperHosting.BG
SuperHosting.BG
SuperHosting.BG is our SuperTeam! Every day we give our best to make our clients number one. The SuperPower of our SuperTeam is that we are always ready to provide you the precise information you need.
0 0 votes
.
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments