php 5 config tuning

Discussion in 'PHP' started by wkenzie, Apr 14, 2008.

  1. wkenzie

    wkenzie New Member

    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
  2. mistwang

    mistwang LiteSpeed Staff

    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.
  3. anewday

    anewday Moderator

    Isn't 2000 for PHP_LSAPI_MAX_REQUESTS too low? You input 50000 on my server with much less concurrent connections. :p
  4. mistwang

    mistwang LiteSpeed Staff

    It does not really matter much.
  5. wkenzie

    wkenzie New Member

    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 ?
  6. wkenzie

    wkenzie New Member

    my WaitQ is now over 700 ! with 1050 Requests in Processing !
  7. mistwang

    mistwang LiteSpeed Staff

    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. wkenzie

    wkenzie New Member

    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
  9. mistwang

    mistwang LiteSpeed Staff

Share This Page