lsphp4 using high CPU

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

  1. anewday

    anewday Moderator

    Code:
    Tasks: 133 total,   1 running, 132 sleeping,   0 stopped,   0 zombie
    Cpu(s): 23.2% us,  4.0% sy,  0.3% ni, 65.4% id,  7.1% wa,  0.0% hi,  0.0% si
    Mem:   3114144k total,  3074580k used,    39564k free,   139360k buffers
    Swap:  2096440k total,      304k used,  2096136k free,  2288692k cached
    
      PID USER      PR  NI %CPU    TIME+  %MEM  VIRT  RES  SHR S COMMAND                                                              
    [B]20417 nobody    16   0   43   0:16.09  0.4 13184  10m 1588 S lsphp4  [/B]                                                             
     6769 mysql     21   6    4 234:25.70  8.2  725m 248m 2808 S /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --
    [B]19525 nobody    16   0    4   0:50.25  0.4 13412  11m 1744 S lsphp4[/B]                                                               
     2322 root      15   0    0  23:37.58  0.0     0    0    0 S [kjournald]                                                          
    21135 root      16   0    0   0:00.01  0.0  3520 1044  784 R top -c -d 2                                                          
        1 root      16   0    0   0:08.49  0.0  3236  508  432 S init [3]                                                             
        2 root      RT   0    0   0:05.21  0.0     0    0    0 S [migration/0]                                                        
        3 root      34  19    0   0:00.87  0.0     0    0    0 S [ksoftirqd/0]                                                        
        4 root      RT   0    0   0:06.90  0.0     0    0    0 S [migration/1]                                                        
        5 root      34  19    0   0:00.72  0.0     0    0    0 S [ksoftirqd/1]                                                        
        6 root       5 -10    0   0:02.76  0.0     0    0    0 S [events/0]                                                           
        7 root       5 -10    0   0:09.05  0.0     0    0    0 S [events/1]                                                           
        8 root       9 -10    0   0:00.00  0.0     0    0    0 S [khelper]                                                            
        9 root      15 -10    0   0:00.00  0.0     0    0    0 S [kacpid]                                                             
       37 root       5 -10    0   0:00.03  0.0     0    0    0 S [kblockd/0]                                                          
       38 root       5 -10    0   0:00.11  0.0     0    0    0 S [kblockd/1]                                                          
       39 root      15   0    0   0:00.05  0.0     0    0    0 S [khubd]                                                              
       58 root      15   0    0  31:51.28  0.0     0    0    0 S [kswapd0]                                                            
       59 root      12 -10    0   0:00.00  0.0     0    0    0 S [aio/0]                                                              
       60 root      12 -10    0   0:00.00  0.0     0    0    0 S [aio/1]                                                              
      204 root      25   0    0   0:00.00  0.0     0    0    0 S [kseriod]                                                            
      441 root       5 -10    0   0:00.00  0.0     0    0    0 S [ata/0]                                                              
      442 root       8 -10    0   0:00.00  0.0     0    0    0 S [ata/1]                                                              
      443 root       8 -10    0   0:00.00  0.0     0    0    0 S [ata_aux]                                                            
      447 root      15   0    0   0:00.00  0.0     0    0    0 S [scsi_eh_0]                                                          
      448 root      15   0    0   0:00.00  0.0     0    0    0 S [scsi_eh_1]                                                          
      473 root      15   0    0   1:45.97  0.0     0    0    0 S [kjournald]                                                          
     1845 root      25   0    0   0:00.00  0.0     0    0    0 S [shpchpd_event]                                                      
     2214 root       6 -10    0   0:00.00  0.0     0    0    0 S [kauditd]                                                            
     2318 root      15   0    0   0:00.00  0.0     0    0    0 S [kjournald]                                                          
     2319 root      15   0    0  11:02.79  0.0     0    0    0 S [kjournald]                                                          
     2320 root      15   0    0   0:43.55  0.0     0    0    0 S [kjournald]                                                          
     2321 root      15   0    0  13:30.63  0.0     0    0    0 S [kjournald]                                                          
     2323 root      15   0    0   4:36.31  0.0     0    0    0 S [kjournald]                                                          
     3230 root      16   0    0   1:00.09  0.0  3540  540  448 S syslogd -m 0                                                         
     3234 root      16   0    0   0:00.86  0.0  3092  388  320 S klogd -x                                                             
     3247 root      16   0    0   0:00.57  0.0  2556  296  216 S irqbalance                                                           
     3256 root      15   0    0   0:00.00  0.0  2580  296  236 S /usr/sbin/courierlogger -pid=/var/spool/authdaemon/pid -facility=mail
     3257 root      16   0    0   0:00.00  0.0  2408  608  492 S /usr/libexec/courier-authlib/authdaemond                             
     3285 root      16   0    0   0:01.09  0.0  2408  380  252 S /usr/libexec/courier-authlib/authdaemond                             
     3286 root      16   0    0   0:01.03  0.0  2408  380  252 S /usr/libexec/courier-authlib/authdaemond                             
     3287 root      16   0    0   0:01.23  0.0  2408  376  252 S /usr/libexec/courier-authlib/authdaemond                             
     3288 root      16   0    0   0:01.10  0.0  2408  380  252 S /usr/libexec/courier-authlib/authdaemond                             
     3289 root      16   0    0   0:01.09  0.0  2408  380  252 S /usr/libexec/courier-authlib/authdaemond                             
     3339 nobody    26  10    0   0:43.93  0.0  5800 1396  844 S proftpd: (accepting connections)                                     
     3351 root      15   0    0   0:02.51  0.0  2524  508  300 S /usr/sbin/smartd                                                     
     3360 root      20   0    0   0:00.00  0.0  3424  448  372 S /usr/sbin/acpid                                                      
     3426 root      16   0    0   0:00.00  0.0  2808  784  640 S xinetd -stayalive -pidfile /var/run/xinetd.pid
    I don't know why it's using a lot of CPU and are there 2 instances running because the server is on a Dual Core Xeon 3060? Since installing Litespeed, the load has been higher than when Apache was used. :confused:
    Last edited: Mar 20, 2008
  2. mistwang

    mistwang LiteSpeed Staff

    Have you installed a PHP opcode cache?
    LiteSpeed's gzip compression may contribute to the higher load, your Apache installation may not have it, so turn it off under server->tuning tab if it concerns you.
  3. anewday

    anewday Moderator

    I'm not using any opcode cache. Gzip is already disabled.

    I'll recompile PHP 5.

    this just happened:

    19525 nobody 16 0 42 2:09.60 0.4 13412 11m 1744 S lsphp4
    20417 nobody 16 0 27 1:06.83 0.4 13188 10m 1596 S lsphp4
    20233 nobody 17 0 12 1:39.54 0.4 14680 12m 1596 R lsphp4

    :eek:
  4. mistwang

    mistwang LiteSpeed Staff

    Which PHP version is used with Apache? PHP4 or PHP5, you should compile and use the same version of lsphp.
    Install a opcode cache like eAccelerator will help a lot.
  5. anewday

    anewday Moderator

    Apache is using PHP4. I thought you said it doesn't matter the version that cPanel/Apache uses since Litespeed is installing to a different location.

    I just compiled LSAPI PHP5 via the GUI, according to phpinfo, it says the php.ini file is in /usr/local/lsws/lsphp5/lib
    but I do not see the file there. Need to add the eaccelerator lines.
    Last edited: Mar 20, 2008
  6. mistwang

    mistwang LiteSpeed Staff

    Yeah, it is fine.
    But, if you want to compare performance, you need to use similar setup for both. PHP5 is slower than PHP4.
  7. anewday

    anewday Moderator

    Ok, I edited my post above.
  8. mistwang

    mistwang LiteSpeed Staff

    You need to create the php.ini file for PHP5 and added the eaccelerator line manually.
  9. anewday

    anewday Moderator

    I copied php.ini file from /usr/local/lsws/php/php.ini to /usr/local/lsws/lsphp4/lib/ then added the following to the end of the file:

    Code:
    extension="/usr/local/lsws/lsphp4/lib/php/extensions/no-debug-non-zts-20020429/eaccelerator.so"
    eaccelerator.shm_size="64"
    eaccelerator.cache_dir="/tmp/lswseaccelerator"
    eaccelerator.enable="1"
    eaccelerator.optimizer="1"
    eaccelerator.check_mtime="1"
    eaccelerator.debug="0"
    eaccelerator.filter=""
    eaccelerator.shm_max="0"
    eaccelerator.shm_ttl="0"
    eaccelerator.shm_prune_period="0"
    eaccelerator.shm_only="0"
    eaccelerator.compress="1"
    eaccelerator.compress_level="9"
    BTW, I decided to use PHP4 for now. Restarted LiteSpeed, it still doesn't show eaccelerator being used.
    Last edited: Mar 20, 2008
  10. anewday

    anewday Moderator

    this shows up in stderr.log

    PHP Warning: Unknown(): Unable to load dynamic library './/usr/local/lsws/lsphp4/lib/php/extensions/no-debug-non-zts-20020429/eaccelerator.so' - .//usr/local/lsws/lsphp4/lib/php/extensions/no-debug-non-zts-20020429/eaccelerator.so: cannot open shared object file: No such file or directory in Unknown on line 0

    Any help would be appreciated, if I can get this resolved..I'll seriously considering buying the license. ;)
  11. mistwang

    mistwang LiteSpeed Staff

    You should copy the php.ini used by Apache mod_php then add the eaccelerator configuration.

    From command line do "./lsphp4 -v" to make sure there is no error message complaining failed to load eaccelerator.so
    You can try removing "extension_dir" configuration in php.ini.
  12. anewday

    anewday Moderator

    I copied the php.ini from /usr/local/Zend/etc/ to /usr/local/lsws/lsphp4/lib/
    removed the Zend lines and added eaccelerator lines.

    Code:
    root@server [/usr/local/lsws/fcgi-bin]# ./lsphp4 -v
    PHP 4.4.8 (litespeed) (built: Mar 20 2008 13:29:02)
    Copyright (c) 1997-2004 The PHP Group
    Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
    Code:
    root@server [/usr/local/apache/logs]# cat stderr.log |grep eacc
    
    PHP Warning:  Unknown(): Unable to load dynamic library './eaccelerator.so' - ./eaccelerator.so: cannot open shared object file: No such file 
    or directory in Unknown on line 0PHP Warning:  Unknown(): Unable to load dynamic library './/usr/local/lsws/lsphp5/lib/php/extensions/no-debug
    -non-zts-20060613eaccelerator.so' - .//usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613eaccelerator.so: cannot open shared o
    bject file: No such file or directory in Unknown on line 0PHP Warning:  Unknown(): Unable to load dynamic library './/usr/local/lsws/lsphp5/li
    b/php/extensions/no-debug-non-zts-20060613/eaccelerator.so' - .//usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerat
    or.so: cannot open shared object file: No such file or directory in Unknown on line 0/usr/local/apache/bin/httpd_ls_bak: invalid option -- k
    PHP Warning:  Unknown(): Unable to load dynamic library './/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so
    ' - .//usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so: cannot open shared object file: No such file or dir
    ectory in Unknown on line 0/usr/local/apache/bin/httpd_ls_bak: invalid option -- k
    PHP Warning:  Unknown(): Unable to load dynamic library './/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so
    ' - .//usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so: cannot open shared object file: No such file or dir
    ectory in Unknown on line 0/usr/local/apache/bin/httpd_ls_bak: invalid option -- k
    PHP Warning:  Unknown(): Unable to load dynamic library './/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so
    ' - .//usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so: cannot open shared object file: No such file or dir
    ectory in Unknown on line 0/usr/local/apache/bin/httpd_ls_bak: invalid option -- k
    PHP Warning:  Unknown(): Unable to load dynamic library './/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so
    ' - .//usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so: cannot open shared object file: No such file or dir
    ectory in Unknown on line 0/usr/local/apache/bin/httpd_ls_bak: invalid option -- k
    PHP Warning:  Unknown(): Unable to load dynamic library './/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so
    ' - .//usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so: cannot open shared object file: No such file or dir
    ectory in Unknown on line 0/usr/local/apache/bin/httpd_ls_bak: invalid option -- k
    PHP Warning:  Unknown(): Unable to load dynamic library './/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so
    ' - .//usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so: cannot open shared object file: No such file or dir
    ectory in Unknown on line 0/usr/local/apache/bin/httpd_ls_bak: invalid option -- k
    PHP Warning:  Unknown(): Unable to load dynamic library './/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so
    ' - .//usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so: cannot open shared object file: No such file or dir
    ectory in Unknown on line 0/usr/local/apache/bin/httpd_ls_bak: invalid option -- k
    PHP Warning:  Unknown(): Unable to load dynamic library './/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so
    ' - .//usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so: cannot open shared object file: No such file or dir
    ectory in Unknown on line 0curl: try 'curl --help' or 'curl --manual' for more information
    PHP Warning:  Unknown(): Unable to load dynamic library './/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so
    ' - .//usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so: cannot open shared object file: No such file or dir
    ectory in Unknown on line 0/usr/local/apache/bin/httpd_ls_bak: invalid option -- k
    PHP Warning:  Unknown(): Unable to load dynamic library './/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so
    ' - .//usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so: cannot open shared object file: No such file or dir
    ectory in Unknown on line 0/usr/local/apache/bin/httpd_ls_bak: invalid option -- k
    PHP Warning:  Unknown(): Unable to load dynamic library './/usr/local/lsws/lsphp4/lib/php/extensions/no-debug-non-zts-20020429/eaccelerator.so
    ' - .//usr/local/lsws/lsphp4/lib/php/extensions/no-debug-non-zts-20020429/eaccelerator.so: cannot open shared object file: No such file or dir
    ectory in Unknown on line 0/usr/local/apache/bin/httpd_ls_bak: invalid option -- k
    PHP Warning:  Unknown(): Unable to load dynamic library './/usr/local/lsws/lsphp4/lib/php/extensions/no-debug-non-zts-20020429/eaccelerator.so
    ' - .//usr/local/lsws/lsphp4/lib/php/extensions/no-debug-non-zts-20020429/eaccelerator.so: cannot open shared object file: No such file or dir
    ectory in Unknown on line 0/usr/local/apache/bin/httpd_ls_bak: invalid option -- k
    PHP Warning:  Unknown(): Unable to load dynamic library './/usr/local/lsws/lsphp4/lib/php/extensions/no-debug-non-zts-20020429/eaccelerator.so
    ' - .//usr/local/lsws/lsphp4/lib/php/extensions/no-debug-non-zts-20020429/eaccelerator.so: cannot open shared object file: No such file or dir
    ectory in Unknown on line 0/usr/local/apache/bin/httpd_ls_bak: invalid option -- k
    PHP Warning:  Unknown(): Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20020429//usr/local/lsws/lsphp4/lib/ph
    p/extensions/no-debug-non-zts-20020429/eaccelerator.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20020429//usr/local/lsws/lsphp4/lib/p
    hp/extensions/no-debug-non-zts-20020429/eaccelerator.so: cannot open shared object file: No such file or directory in Unknown on line 0
    
    Last edited: Mar 21, 2008
  13. mistwang

    mistwang LiteSpeed Staff

    remove the "extension_dir" configuration in php.ini

    try ./lsphp4 -i

    until eaccelerator extension appear in the output.
  14. anewday

    anewday Moderator

    eaccelerator still does not appear in the output after removing the extension_dir line in php.ini :confused:
  15. mistwang

    mistwang LiteSpeed Staff

    check if the right php.ini has been used. And the right path has been used for eaccelerator.so, check if the file exist.
  16. anewday

    anewday Moderator

    finally working

    *whewwwww*

    extension_dir = "/usr/local/lsws/lsphp4/lib/php/extensions/no-debug-non-zts-20020429"
    extension="eaccelerator.so"

    eaccelerator.shm_size="48"
    eaccelerator.cache_dir="/tmp/lswseaccelerator"
    eaccelerator.enable="1"
    eaccelerator.optimizer="1"
    eaccelerator.check_mtime="1"
    eaccelerator.debug="0"
    eaccelerator.filter=""
    eaccelerator.shm_max="0"
    eaccelerator.shm_ttl="0"
    eaccelerator.shm_prune_period="0"
    eaccelerator.shm_only="0"
    eaccelerator.compress="1"
    eaccelerator.compress_level="9"

    I got an example from another site and changed it.

    Thanks for helping! :)
    Last edited: Mar 21, 2008
  17. anewday

    anewday Moderator

    Ok, not much have changed since I got eaccelerator working. The lsphp4 process still spikes the cpu usage.
  18. mistwang

    mistwang LiteSpeed Staff

    Have you setup /tmp/lswseaccelerator? any file got created?
  19. anewday

    anewday Moderator

    Yes, I made that folder and set the permissions correctly, there are many folders and files created. Could it be the fact that I put too many configure parameters during the PHP build?

    Also, I see this on the process list:

    1804 nobody 16 0 0 0:00.04 0.2 7672 5324 1504 S admin_php -c ../conf/php.ini

    why is it showing that path to php.ini file?
    Last edited: Mar 21, 2008
  20. ts77

    ts77 New Member

    I'm curious, are you really worried about a high overall load or just because you see php separately now? with apache you probably had mod_php loaded into apache and therefore only saw apache processes with high load. with litespeed php is run separately and gets requests through lshttpd.
    If you got lots of php pages / scripts requested than surely php is running high ;).

Share This Page