Portal Home > Knowledgebase > Articles Database > PHP performance down the drain all of sudden, can't figure out reason


PHP performance down the drain all of sudden, can't figure out reason




Posted by NuCode, 05-24-2008, 04:48 AM
Hi, I have fairly much of requests (should be getting over 30 to a single PHP file), and performance was really good still few weeks back. Loads of the server were generally under 1.0, this is a very lightweight PHP file with MySQL w/ 3 queries total (2xSELECT one Update), one under 500 iterations loop (very lightweight) and outputs a few hundred bytes. On default windows XAMPP installation on way slower desktop machine it easily handles 64 requests per second. However, a few weeks ago, something happened, and i can't pinpoint anything which would cause the performance to go down the drain, i cannot remember doing any changes either, i did WHM update at one point, but i think it was before that. Maximum it can reach is ~27requests/sec handled anymore, and even that results some ~20 load. Now running Apache 2.2 with 250 max clients, PHP 5.2.6 with eAccelerator (128m limit). All memory won't be used up. CPU usage goes to 100% as soon as concurrent requests hit around 35, but server is normally responsive to well over loads of 200, infact, no noticeable speed decrease, no problems on the shoutcast running on the same server, and backlog of requests keeps piling up. Same problem with Apache 1.3, with or without eAccelerator, PHP5 is needed but will try PHP4 as well. Any ideas wtf is going on with this server? Will post back as i downgrade now to 1.3 and PHP4.

Posted by NuCode, 05-24-2008, 05:13 AM
lol, this one is new: [Sat May 24 04:11:17 2008] [error] (27)File too large: could not open transfer log file /usr/local/apache/domlogs/DOMAIN. 6.3Gb Server uptime: 7 minutes 38 seconds Total accesses: 9351 - Total Traffic: 4.1 MB CPU Usage: u2.09 s3.52 cu277.22 cs544.88 - 181% CPU load 20.4 requests/sec - 9.1 kB/second - 456 B/request 179 requests currently being processed, 0 idle servers Instead of mostly user time, now it's mostly sys time, when compared to apache 2.2 Last edited by NuCode; 05-24-2008 at 05:25 AM.

Posted by RBBOT, 05-24-2008, 06:47 AM
Which process is actually eating the CPU time - mysql or httpd ? Your description sort of implies each hit does an update query to the same table. If this is the case, is it myisam or innodb, and does it update 1 row or many? How large is the table? With that number of concurrent updates, you may be better off with an innodb table which supports row-level locking.

Posted by NuCode, 05-24-2008, 07:17 AM
Updates same table as the first SELECT, affects only 1 row. tables MyISAM first select & update table: 104 records, 21.4k second select table: 595 records, 46.1k returns always multiple, usually 3 records Indexes used, first table queries by Unique ID which is used as the relation for second table. ps aux|grep mysql root 18400 0.0 0.0 5344 1060 ? S May22 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/hostname.pid mysql 18421 3.0 9.9 776904 206964 ? Sl May22 92:02 /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/hostname.pid --skip-external-locking on top: 18421 mysql 15 0 2 92:03.82 9.9 757m 201m 4448 S mysqld usually sits at around few % CPU usage. Tasks: 191 total, 2 running, 189 sleeping, 0 stopped, 0 zombie Cpu(s): 23.8% us, 10.9% sy, 0.0% ni, 64.5% id, 0.7% wa, 0.2% hi, 0.0% si Mem: 2073820k total, 1951476k used, 122344k free, 118480k buffers Swap: 4112580k total, 48100k used, 4064480k free, 958672k cached

Posted by acctman, 05-24-2008, 08:35 AM
I'm having a similar problem, everything was running smoothly then updated Apache from 1 to 2 and php4 to 5 yesterday. Now my system load is EXTERMELY HIGH, I went from a 2-3 load avg to a Load Averages: 216.12 208.27 173.86 thats insane. How is php5/apache 2 better with this load avg

Posted by acctman, 05-24-2008, 09:17 AM
Update, since I have both php4 and php5 installed i added the following to the .htaccess for the site i want php4 to run with. AddHandler application/x-httpd-php4 .php .php4 .php3 .phtml My large community site is back to a load avg of 2-3 with 13k users on at once.

Posted by NuCode, 05-25-2008, 05:32 AM
I changed PHP to cgi and that helped a fair bit. Current Time: Sunday, 25-May-2008 04:30:53 CDT Restart Time: Saturday, 24-May-2008 10:26:12 CDT Parent Server Generation: 1 Server uptime: 18 hours 4 minutes 41 seconds Total accesses: 2871117 - Total Traffic: 224.0 MB CPU Usage: u343.94 s484.66 cu19027.5 cs7678.41 - 42.3% CPU load 44.1 requests/sec - 3609 B/second - 81 B/request 6 requests currently being processed, 78 idle servers But imho that's still weak for Dual Core Xeon 3060 and 2Gigs DDR667 ECC REG and for that lightweight PHP code. Running now: Apache 1.3, PHP5 as CGI, phpSuExec, eAccelerator

Posted by gnusys, 05-25-2008, 12:07 PM
Clearout the log with large size!. That helps to reduce the load .Also analyze the log before.Just give thought as to why the domlog got this large Also try a php caching system like Xcache,eAccelerator or APC and you will get a good perfomance boost

Posted by NuCode, 05-26-2008, 11:45 AM
Read my post: log cleared, eAccelerator being used AND i know why the log is so large: almost 30 requests per sec 24/7/365 stable.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Reseller Hosting (Views: 538)
Home Web server (Views: 497)