lsphp4 using high CPU

Discussion in 'PHP' started by anewday, Mar 20, 2008.

  1. anewday

    anewday Moderator

    The high load, I haven't noticed much difference (as many have experienced) after replacing Apache. Before, Apache processes with mod_php was using a lot of ram, not high CPU usage like it is now with lsphp process...
    Last edited: Mar 21, 2008
  2. mistwang

    mistwang LiteSpeed Staff

    That's because PHP requests has all been handled by one or two lsphp processes, while with Apache mod_php, that load has been distributed among many Apache httpd processes. If add all the cpu usage of httpd processes up, it is higher than lshttpd + lsphp.
  3. anewday

    anewday Moderator

    I don't ever remembering the apache processes using high CPU, even when all added together it's much less than lsphp4 or lsphp5. Here's an output of the ps aux command from a while ago.

    Code:
    USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
    nobody 27384 0.3 2.0 33300 20912 ? SN Oct25 18:21 /usr/local/apache/bin/httpd -DSSL
    nobody 27386 0.3 2.0 33048 20896 ? SN Oct25 21:34 /usr/local/apache/bin/httpd -DSSL
    nobody 27387 0.3 2.0 33312 21684 ? SN Oct25 20:37 /usr/local/apache/bin/httpd -DSSL
    nobody 27393 0.3 1.8 32564 18948 ? SN Oct25 17:01 /usr/local/apache/bin/httpd -DSSL
    nobody 27394 0.3 1.9 32844 19684 ? SN Oct25 17:41 /usr/local/apache/bin/httpd -DSSL
    nobody 27395 0.3 1.8 32616 19244 ? SN Oct25 17:56 /usr/local/apache/bin/httpd -DSSL
    nobody 27397 0.3 1.7 32972 18484 ? SN Oct25 18:20 /usr/local/apache/bin/httpd -DSSL
    nobody 27398 0.3 1.7 32960 18568 ? SN Oct25 19:17 /usr/local/apache/bin/httpd -DSSL
    nobody 27399 0.3 1.7 32212 17956 ? SN Oct25 17:40 /usr/local/apache/bin/httpd -DSSL
    nobody 28012 0.3 1.8 32756 18888 ? SN Oct25 17:13 /usr/local/apache/bin/httpd -DSSL
    nobody 30931 0.3 1.8 32912 18724 ? SN Oct25 20:44 /usr/local/apache/bin/httpd -DSSL
    nobody 30932 0.3 1.8 32880 18620 ? SN Oct25 19:04 /usr/local/apache/bin/httpd -DSSL
    nobody 30933 0.2 1.8 32652 18628 ? SN Oct25 16:27 /usr/local/apache/bin/httpd -DSSL
    nobody 19565 0.4 1.7 32936 18572 ? SN Oct28 9:59 /usr/local/apache/bin/httpd -DSSL
    nobody 31529 0.4 1.4 32064 15080 ? SN 11:07 1:16 /usr/local/apache/bin/httpd -DSSL
    nobody 610 0.2 1.3 32104 13520 ? SN 11:25 0:32 /usr/local/apache/bin/httpd -DSSL
    nobody 1151 0.0 0.2 29604 2396 ? SN 11:30 0:00 /usr/local/apache/bin/httpd -DSSL
    nobody 10538 0.5 1.6 32520 16904 ? SN 13:02 0:46 /usr/local/apache/bin/httpd -DSSL
    nobody 13460 0.3 1.2 32160 12504 ? SN 13:39 0:20 /usr/local/apache/bin/httpd -DSSL
    nobody 20294 0.0 0.2 29604 2184 ? SN 14:40 0:00 /usr/local/apache/bin/httpd -DSSL
    nobody 24565 0.1 0.7 31668 8164 ? SN 15:21 0:00 /usr/local/apache/bin/httpd -DSSL
    nobody 24571 0.0 0.2 29464 2168 ? SN 15:21 0:00 /usr/local/apache/bin/httpd -DSSL
    
    I haven't noticed a difference in load after using LiteSpeed. It still ranges from 1-2 on average during the peak times. :(
    Last edited: Mar 21, 2008
  4. mistwang

    mistwang LiteSpeed Staff

    Are you using PHP suexec with LiteSpeed, sometimes, PHP may have permission problem and may lead to higher load.
    Some PHP code uses disk cache, for some reason, it causes high load problem when there is permission problem.
  5. anewday

    anewday Moderator

    Yes I'm using that with LiteSpeed. I only run one mysql/php forum and another small static on my dedicated server.

    From WHM > CPU/Memory/MySQL Usage

    Top Process %CPU 61.0 lsphp5
    Top Process %CPU 56.0 lsphp5
    Top Process %CPU 49.0 lsphp5
    Last edited: Mar 21, 2008
  6. mistwang

    mistwang LiteSpeed Staff

    Try turning off "php suexec", since you only have one main site. And do not compare php5 with php4.
  7. anewday

    anewday Moderator

    I turned it off before to no avail before I enabled it yesterday. Tried it on both php4 and php5, built with the same config parameters in the GUI.
  8. mistwang

    mistwang LiteSpeed Staff

    Are you using similar php.ini for both mod_php and lsphp4, except for the part of eaccelerator?
  9. anewday

    anewday Moderator

    Yes, I copied the php.ini as you instructed but the cpu spikes were happening with the default php.ini it came with. I just changed a few settings on that file.
  10. mistwang

    mistwang LiteSpeed Staff

    the opcode cache will work better if you turn off PHP suexec. For a server hosting one main PHP site, I would turn it off.
  11. anewday

    anewday Moderator

    I turned it off now, still cpu spikes happening very often. :(
  12. anewday

    anewday Moderator

    mistwang, if I give you access to my server, could you take a look? This is the only issue remaining that is preventing me from buying a license after the trial expires. :(
  13. mistwang

    mistwang LiteSpeed Staff

    I can take a quick look.
  14. mistwang

    mistwang LiteSpeed Staff

    changed you lsphp4 external app to more optimized configuration.
    Swtiched to Apache for a little while to compare, with litespeed, the load is around 0.3, with Apache the load is around 0.5-0.6. Apache has cpu usage spike as well. LiteSpeed is running well.
  15. anewday

    anewday Moderator

    Great, thank you so much! lsphp4 PHP_LSAPI_MAX_REQUESTS=50000 is so much more than lsphp5 setting, did you mean to change it for lsphp5 too? :p

    My websites are the least busiest at this time, let's see how the new settings hold up during tomorrow's peak times.

    By the way, I noticed the "find member's posts" function on my forum takes much longer than before, 1-2 seconds to complete, now it's taking nearly 10 seconds. Does it have something to do with the "Instances" setting in lsphp4 external app?

    Again, thank you for providing the amziing service. The product is awesome and well worth the money. :)
    Last edited: Mar 24, 2008
  16. mistwang

    mistwang LiteSpeed Staff

    Yes, you can mirror the lsphp4 configuration.
    Try that with Apache, it should take about same amount of time. "Instances" has nothing to do with that. strace -p <pid> shows that PHP spend a lot of time in mysql query, it is has nothing to do with LSAPI, just PHP code.
  17. anewday

    anewday Moderator

    It was taking only 1-2 seconds with the old settings before you changed them. I tested it by changing Instances to 40 and it made a big difference, the old value was 80. Hmmmm. :eek:
  18. mistwang

    mistwang LiteSpeed Staff

    Please do more test, it should not.
  19. anewday

    anewday Moderator

    I've done the test more than a few times, I searched for member's posts (over 10,000) with "Instances" set at 1 and it takes around 10 seconds to finish. Then, I changed that value to 40, restarted FireFox, emptied cache, and tried again...this time it took seconds only. Again, I switched it back to 1, repeat the process...takes much longer. Moreover, it was very fast until you changed the settings.

    If you want, I can give you a test account on my forums to test.
    Last edited: Mar 24, 2008
  20. mistwang

    mistwang LiteSpeed Staff

    Yeah, you can send me one.

Share This Page