Since this is always a hot topic and not always properly explained, I thought I would take the time out to explain what has been explained to me by Bluehost support. I figured many people who come here with CPU exceed problems may find some use and possible answers since the limitations are not fully explained in most places I have looked or are sometime not made very clear.
/* These limits are those of Bluehost, yours may be higher or lower! */
40 seconds of CPU usage within every minute.
No more then 20 processes running at once.
- 40 seconds of CPU time per every minute is pretty self explanatory. Most good processes are in and out of there before you know it but if you have processes that take many seconds to run you may find yourself using your allotted time before that minute is up. As soon as you pass the 40 second marker your site is made unavailable for a short amount of time.
- Again this one is exactly how it sounds. You can only have 20 processes going at the same time. As soon as you hit 21 your site will not be allowed to start any other processes until processes start to close and you fall under the limit again.
What can be done to help prevent CPU exceeds.
- First and foremost optimize your scripts and databases. If you are not good with coding it will be hard to optimize your scripts but you can find many online resources to help and you may even be able to find someone to help you out. As for the databases, you can always use phpMyAdmin to optimize your tables. This should be done regularly. The bigger the database the more frequently it should be done. Also index those tables!
Keep programs being used up to date. Sometimes updates provided for these programs improve performance and update code that is outdated which can help ease the load on your site and server in whole.
Try to limit the amount of processes your site is running. In other words don't have processes running that are not really needed for your site. Optimize how many processes are used to make your site operate. An example of needless processes can even include using php and databases for a static page that you will either never change the information on or will only rarely change like your privacy page or contact us page. Things like that are best ran on regular (x)html. Otherwise you are calling up processes to create a page that is unchanging and not in need of anything fancy. We have to remember to use our resources wisely on shared hosting.
Try turning off Awstats. Some people have found that Awstats itself was their big problem. This normally happens on sites with higher traffic and larger stats logs. Keep in mind it may not be the culprit on your site.
Use robots text to limit spiders and how fast they move through your site. This one is fairly important if you have google or another major, resource hog of a spider that seems to love peering through your site, especially when it's peeking through pages counting towards your process count. You only have 20 process at any given time so you want to slow that spider down enough so that it shares those 20 processes with human visitors instead of tripping your CPU limits all by itself. If you find that a spider is not obeying your robots text and is causing a problem for your site, you may have to ban it completely. Granted you will lose a spot in that search engine BUT your site is going to lose all its visitors if it is always exceeded. Again banning the search engine is the last resort but a few of the 'major' ones are notorious for crashing sites that have more resources then each of us uses on bluehost. In fact some major sites have taken to banning a some of them.
Keep a vigilant eye over your site. Stay on top of your error, slow queries and CPU exceed logs. They can reveal a lot about what is going on within a site and the problems that can be taking your site down from CPU exceed or other issues. Also peek in on your running processes from time to time. Now and then one or more may stall and need to be manually shut down. After all, for every process that won't shut off you have one less process remaining out of your 20.
Again I wrote this as a way to try and help people understand CPU limitation and exceeding them. This is meant to be constructive and helpful. Personally, the 3rd limit on the list is one that I don't think is pointed out enough and it was one that took the longest for me to find out about. Everything I wrote about the limits is as bluehost support has explained them to me. So if someone finds any of the information or tips helpful then I will be happy.
If anyone else has any more tricks and tips they use to help their site I would be interested in hearing them.
Credits To: 1darkangel of BlueHost Forum & Gerardcole For Netnaija Forum