php 5 config tuning

#1
I have had great trouble so far trying to get LSAPI php 5.2.5 to work well for me in high concurrency situation, and need some guidance. Currently I am using apache 2.2 with httpd.conf MaxClients=1000, KeepAlive on, KeepAliveTimeout 3, MaxKeepAliveRequests 100, Timeout 60, MaxRequestsPerChild 50, ServerLimit 1250 and MySQL my.cnf max_connections=1600 and max_user_connections=1600. It works but is not very fast when I reach 1000+ concurrent users. I hoped lsws would handle more users and be faster but it froze overnight the first time I ran it, and load is much too high when I reach 1000+ users. I have maxConnections=2000, maxKeepAliveReq=15, smartKeepAlive=1, keepAliveTimeout=3, eventDispatcher=epoll, LSAPI maxconns=1500, PHP_LSAPI_MAX_REQUESTS=2000, PHP_LSAPI_CHILDREN=1499, LSAPI_AVOID_FORK=1, LSAPI_MAX_IDLE=30, persistConn=1, pcKeepAliveTimeout=3, backlog=100, instances=1.

This is on X86_64 Linux 2.6.16.53 #1 SMP with 8GB RAM and dual processor dual-core AMD Opteron 2.2 GHz
 

mistwang

LiteSpeed Staff
#2
Your LSAPI configurations are over tuned. Try the following

LSAPI maxconns=150, PHP_LSAPI_MAX_REQUESTS=2000, PHP_LSAPI_CHILDREN=150, persistConn=1, pcKeepAliveTimeout=N/A, backlog=100, instances=1

if the "WaitQ" for the lsphp external app in the real time status report is constantly non-zero, increase "LSAPI maxconns" and "PHP_LSAPI_CHILDREN" to 250.

You need to make sure your MySQL are optimized. LiteSpeed cannot cure bad PHP code either.
 
#5
thanks, I made those changes and went straight to 250 rather than 150 - this morning, which is my busiest time of day, my server load is an acceptable 38 or so - however, my error log shows lots of warnings about running short of concurrent connections, and real-time stats show about 200 "requests in processing" and 63 requests/second and about half the time the WaitQ is > 0 - can I raise this above 250 on my system do you think?

also, is there a better description of these config options, or is it simply a black art ?
 

mistwang

LiteSpeed Staff
#7
if the requests/second drops to very low number or zero occasionally, you probably need to optimize your SQL or MySQL, MySQL is blocking PHP.

Adding more PHP process may not help the performance.

"Running short of concurrent connections" means that you need to increase server maxConnections maybe to 4000.
 
#8
thanks - occasionally WaitQ does drop to 0 but it really fluctuates a lot - I have not seen requests/second drop to anything near 0 - I have maxConnections set to 2000 but it shows 4000 max connections in real time stats - looks like 2 instances are running even though I only configured for 1 instance
 
Top