LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > LiteSpeed Web Server > General > lsphp5 is using too much CPU

Reply
 
Thread Tools Display Modes
  #1  
Old 04-18-2009, 08:10 PM
hpham hpham is offline
Member
 
Join Date: Aug 2007
Posts: 31
Default lsphp5 is using too much CPU

When using top, here is the result

Quote:
top - 23:09:01 up 15 days, 13:04, 1 user, load average: 10.80, 10.31, 8.08
Tasks: 127 total, 16 running, 111 sleeping, 0 stopped, 0 zombie
Cpu(s): 45.6%us, 3.7%sy, 0.0%ni, 0.5%id, 0.0%wa, 0.1%hi, 0.0%si, 50.2%st
Mem: 4194304k total, 2590184k used, 1604120k free, 223184k buffers
Swap: 2097144k total, 0k used, 2097144k free, 1790964k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
23648 mysql 15 0 360m 79m 4864 S 52 2.0 10:44.56 mysqld
8301 user-name 16 0 153m 46m 25m R 25 1.1 0:07.09 lsphp5
7919 user-name 19 0 155m 50m 29m S 24 1.2 0:13.80 lsphp5
8091 user-name 22 0 153m 46m 25m R 18 1.1 0:14.10 lsphp5
8352 user-name 19 0 154m 46m 25m R 16 1.1 0:05.84 lsphp5
7897 user-name 17 0 156m 47m 26m R 15 1.2 0:16.48 lsphp5
8256 user-name 16 0 153m 46m 25m R 12 1.1 0:08.14 lsphp5
Usually, I don't see that much. Is there any way to find out it's because of bad script, or bad configuration of my lsws?

Thanks.
Reply With Quote
  #2  
Old 04-18-2009, 09:20 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
In suexec mode is each PHP instance uses its own independent in memory cache, not shared among PHP processes.

I currently recommend eAccelerator with disk cache in /dev/shm .
Reply With Quote
  #3  
Old 04-18-2009, 09:28 PM
hpham hpham is offline
Member
 
Join Date: Aug 2007
Posts: 31
okay, I have replaced xcache by eAccelerator in /dev/shm. Plus applied some tricks from here http://www.litespeedtech.com/support...os_tuning_tips. The load is going down to around 4 now. Is there any other thing I can do?

Thanks.
Reply With Quote
  #4  
Old 04-18-2009, 09:32 PM
hpham hpham is offline
Member
 
Join Date: Aug 2007
Posts: 31
well... from the top command, when there are 13+ tasks running, the load still going up to 12+. There is still nearly 2GB free RAM.

Quote:
top - 00:31:35 up 15 days, 14:26, 1 user, load average: 13.24, 8.43, 9.18
Tasks: 127 total, 13 running, 114 sleeping, 0 stopped, 0 zombie
Cpu(s): 43.6%us, 4.0%sy, 0.0%ni, 0.7%id, 0.0%wa, 0.1%hi, 0.2%si, 51.5%st
Mem: 4194304k total, 2531036k used, 1663268k free, 225356k buffers
Swap: 2097144k total, 0k used, 2097144k free, 1825460k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
23648 mysql 15 0 358m 82m 4876 S 42 2.0 49:46.34 mysqld
6510 user-name 17 0 99280 31m 21m S 28 0.8 0:21.27 lsphp5
6608 user-name 16 0 98.0m 32m 21m R 24 0.8 0:23.17 lsphp5
4877 user-name 16 0 98.2m 32m 21m R 20 0.8 0:24.97 lsphp5
7570 user-name 16 0 98.0m 32m 21m S 20 0.8 0:03.42 lsphp5
7522 user-name 19 0 99488 31m 21m R 19 0.8 0:02.24 lsphp5
3560 user-name 15 0 100m 32m 22m R 15 0.8 0:32.80 lsphp5
7314 user-name 17 0 98.2m 32m 21m S 9 0.8 0:05.31 lsphp5
4981 user-name 18 0 99492 31m 21m R 5 0.8 0:29.18 lsphp5
5529 user-name 18 0 98.2m 32m 21m R 5 0.8 0:27.71 lsphp5
Any other tip please? I am using lsws 2-CPU license on quad-core CPU server
Thanks.
Reply With Quote
  #5  
Old 04-18-2009, 09:44 PM
anewday anewday is offline
Senior Member
 
Join Date: Nov 2007
Location: New York
Posts: 729
Read my responses on this thread: http://www.litespeedtech.com/support...ead.php?t=2830 and http://www.litespeedtech.com/support...ead.php?t=2723

Last edited by anewday; 04-18-2009 at 09:48 PM..
Reply With Quote
  #6  
Old 04-18-2009, 10:08 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
You need to check those php process using too much CPU see if anything wrong. "strace" should help.
Is /dev/shm mounted as tempfs?
Reply With Quote
  #7  
Old 04-19-2009, 07:04 PM
hpham hpham is offline
Member
 
Join Date: Aug 2007
Posts: 31
@anewday
Quote:
PHP_LSAPI_MAX_REQUESTS=500
PHP_LSAPI_CHILDREN=35
Max connections=35
Instances=1
@mistwang: yes, /dev/shm is mounted as tmpfs. I will check strace if there is anything wrong.
Reply With Quote
  #8  
Old 04-20-2009, 08:29 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
make sure the /dev/shm is not full, have a cron job clean it every 5-10 minutes.
Reply With Quote
  #9  
Old 05-02-2009, 08:40 PM
hpham hpham is offline
Member
 
Join Date: Aug 2007
Posts: 31
I run strace today, here is the result
Quote:
-bash-3.2# strace -c /usr/local/lsws/fcgi-bin/lsphp5
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
56.67 0.000034 1 41 mprotect
43.33 0.000026 0 290 umask
0.00 0.000000 0 46 read
0.00 0.000000 0 91 54 open
0.00 0.000000 0 36 close
0.00 0.000000 0 9 6 stat
0.00 0.000000 0 38 fstat
0.00 0.000000 0 16 lstat
0.00 0.000000 0 2 lseek
0.00 0.000000 0 90 mmap
0.00 0.000000 0 10 munmap
0.00 0.000000 0 25 brk
0.00 0.000000 0 8 rt_sigaction
0.00 0.000000 0 1 rt_sigprocmask
0.00 0.000000 0 1 1 ioctl
0.00 0.000000 0 2 1 access
0.00 0.000000 0 5 select
0.00 0.000000 0 1 shmget
0.00 0.000000 0 1 shmat
0.00 0.000000 0 1 shmctl
0.00 0.000000 0 1 dup2
0.00 0.000000 0 1 1 getpeername
0.00 0.000000 0 1 execve
0.00 0.000000 0 1 uname
0.00 0.000000 0 7 fcntl
0.00 0.000000 0 2 getcwd
0.00 0.000000 0 272 272 mkdir
0.00 0.000000 0 1 unlink
0.00 0.000000 0 2 readlink
0.00 0.000000 0 1 gettimeofday
0.00 0.000000 0 1 getrlimit
0.00 0.000000 0 6 getppid
0.00 0.000000 0 1 arch_prctl
0.00 0.000000 0 1 setrlimit
0.00 0.000000 0 2 time
0.00 0.000000 0 2 futex
0.00 0.000000 0 1 set_tid_address
0.00 0.000000 0 1 set_robust_list
------ ----------- ----------- --------- --------- ----------------
100.00 0.000060 1018 335 total
mprotect? umask? all calls to mkdir error?

Last edited by hpham; 05-02-2009 at 08:42 PM..
Reply With Quote
  #10  
Old 05-02-2009, 08:45 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
It does not looks right.

Better trace individual calls with

strace -tt -T -p <pid>

You can get a clue about what is going on as well.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:59 PM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.