Performance tuning - php 4/apc/lsapi

Discussion in 'PHP' started by bazza, Aug 22, 2006.

  1. bazza

    bazza Member


    I was wondering if anyone could provide some feedback as to optimal settings or performance tweaks to get the most out of a relatively standard lsws 2.1.20 std/php 4.4.2/APC setup?

    Things have been going along ok, but recently, we have had issues with huge load spikes. The load will spike from < 1 to > 100 in a matter of seconds. Looking through the access logs, there is nothing obviously untoward that would cause such a spike (DoS, etc). What I did notice is that when these spikes happen, the number of lsphp processes increases dramatically. Normally less than 10, it can increase to over 100.

    Previously, we did not have the PHP_LSAPI_CHILDREN env variable set, so I have been experimenting with different combinations of config settings.

    Is defining the PHP_LSAPI_CHILDREN variable provide better performance than not defining it? I think that in our case, it may help these load spikes, but it is too soon to tell. Also, what should the variable be set to? Is it more efficient to have 1 lsphp instance with # of children = max connections or should the number of instances be greater than 1 and the number of children less? I can see how there could be advantages and disadvantages to each, but not sure what the best options are.

    Also, we have been experimenting with keep alives, but have yet to really determine the optimal settings for those as well.

    Any input would be greatly appreciated.

  2. mistwang

    mistwang LiteSpeed Staff

    The root cause probably is not in PHP or LiteSpeed, maybe because the backend DB cannot keep up and it causes load spikes on front end server.

    PHP_LSAPI_CHILDREN may not help much. Better to find out why PHP has been slowed down. :)
  3. bazza

    bazza Member

    Thanks for the reply. I dont think the DB layer is the problem, but it could be something else (memcached, maybe?) It could also I guess just be a large influx of simultaneous requests. If this were the case, would it be wise to use PHP_LSAPI_CHILDREN to handle the concurreny better? Do you have any recommendations :)

  4. mistwang

    mistwang LiteSpeed Staff

    Using PHP_LSAPI_CHILDREN will start all PHP processes statically, so it may handle the traffic surge a little bit better, but it will not solve the load spike problem completely. You can set "Dynamic Requests/second" to smooth the traffic surge a little.

    Better to found out exactly what causes the problem and act accordingly.

Share This Page