Current time: 11-29-2024, 06:05 PM Hello There, Guest! (LoginRegister)


Post Reply 
No Upgrade but getting Errors
Author Message
kilburn Offline
Development Team
*****
Dev Team

Posts: 2,182
Joined: Feb 2007
Reputation: 34
Post: #3
RE: No Upgrade but getting Errors
php5-cgi sucking up all the CPU time means that the problem is at the php side, not at the database (otherwise you would see mysql sucking up the time).

Therefore, what you should do is try to discover *why* is this website (php side) consuming sooo much CPU. This usually turns out to be either generating thumbnails over and over again (which is processor intensive), sorting/filtering of data at the php level (instead of the db), or a piece of really stupid code.

For instance, I saw a client's code once that tried to select 10 ads from those that were introduced in the database, by doing (pseudo-php+mysql):
Code:
$ads = array();
$available_ads = 'select count(*) from ads'
while (count($ads) < 10) {
$rnd = rand(0, $available_ads);
$ads[$rnd] = 'select * from ads where id = $rnd'
}

Guess what happened when there were few ads in the database? Slow load and duplicated queries all the time. We finally discovered the problem the day that he got less than 10 ads in the database, and the website stopped working altogether...
(This post was last modified: 09-09-2011 06:17 PM by kilburn.)
09-09-2011 06:17 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
No Upgrade but getting Errors - ewestlake - 09-07-2011, 02:59 AM
RE: No Upgrade but getting Errors - kilburn - 09-09-2011 06:17 PM

Forum Jump:


User(s) browsing this thread: 2 Guest(s)