Trying to understand phplsapi settings

PSS

Well-Known Member
#1
I have been experimenting with different phplsapi settings (not on a live server) in order to understand what the settings do and how the affect.

Well, I can't get it. Litespeed seems to create lsphp processes for each script that has started, ignoring max limits totally. I was hoping to see with following settings that

a) maximum number of parent processes are 30
b) each parent process can create maximum 30 child processes.

I presume the requests should be queued after all those are full, are they?

My server phplsapi settings are

Code:
Max Connections	        30
Environment		PHP_LSAPI_MAX_REQUESTS=5000
			PHP_LSAPI_CHILDREN=30
			LSAPI_MAX_PROCESS_TIME=300
Instances		1

Litespeed Enterprise on 2 dual core Woodcrests.

A simple test case is to run a php script (on Firefox, see end of this post for the code) and when the code starts (after initial page load) I hit right away "reload" on same browser. Every reload creates a new lsphp child, ignoring PHP_LSAPI_CHILDREN. When there are more than PHP_LSAPI_CHILDREN childs, the connections with other browsers to Litespeed becomes jerky (browser waits and waits), but more processes are created with each reload.

Code:
[SIZE="1"]    1 23776 23775 23775 ?           -1 S        0   0:00 lshttpd
23776 23777 23775 23775 ?           -1 S        0   0:00  \_ lscgid
23776 23778 23775 23775 ?           -1 S       99   0:00  \_ lshttpd
23778 23779 23779 23779 ?           -1 Ss      99   0:00  |   \_ lsphp -c ../php
23779 24072 23779 23779 ?           -1 S       99   0:00  |   |   \_ lsphp -c ../php
23779 24175 23779 23779 ?           -1 S       99   0:00  |   |   \_ lsphp -c ../php
23779 24177 23779 23779 ?           -1 S       99   0:00  |   |   \_ lsphp -c ../php
23779 24364 23779 23779 ?           -1 S       99   0:00  |   |   \_ lsphp -c ../php
23778 23784 23775 23775 ?           -1 S       99   0:00  |   \_ admin_php
23776 23780 23775 23775 ?           -1 S       99   0:00  \_ lshttpd
23780 23944 23944 23944 ?           -1 Ss      99   0:00  |   \_ lsphp -c ../php
23944 23945 23944 23944 ?           -1 S       99   0:00  |       \_ lsphp -c ../php
23944 24466 23944 23944 ?           -1 S       99   0:00  |       \_ lsphp -c ../php
23776 23781 23775 23775 ?           -1 S       99   0:00  \_ lshttpd
23781 23808 23808 23808 ?           -1 Ss      99   0:00  |   \_ lsphp -c ../php
23808 23809 23808 23808 ?           -1 S       99   0:00  |       \_ lsphp -c ../php
23776 23782 23775 23775 ?           -1 S       99   0:00  \_ lshttpd
23782 23792 23792 23792 ?           -1 Ss      99   0:00      \_ lsphp -c ../php
23792 23855 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24131 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24140 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24141 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24149 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24151 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24152 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24153 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24154 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24162 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24163 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24164 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24165 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24167 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24176 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24178 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24179 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24180 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24197 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24219 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24220 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24221 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24229 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24230 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24231 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24232 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24233 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24241 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24242 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24327 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24335 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24336 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24337 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24339 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24391 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24392 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24400 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24401 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24402 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24403 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24411 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24412 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24475 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24476 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php
23792 24499 23792 23792 ?           -1 S       99   0:00          \_ lsphp -c ../php[/SIZE]
See, way over 30 child processes. I don't know much about these things, but to me it looks like someone hitting reload on browser with long-running php script can saturate the processes and prevent other accessing the server. LSAPI_MAX_PROCESS_TIME of course kills processes but you simply can not put that to 10s...

Do you have a bug here or do I completely misunderstand the whole concept. If reason is latter, could you please explain, draw a diagram, use powerpoint or something to make my thick head understand how the settings are related and how can I control process creation (and understand what it does to clients).

Thanks!


The script I wrote:

PHP:
<html>
<body>
<?php
error_reporting(255);
        function ee_make_seed() {
            list($usec, $sec) = explode(' ', microtime());
            return (float) $sec + ((float) $usec * 100000);
        }
        function ee_make_suffix ($lenght) {
                srand(ee_make_seed());
                $randval = rand();
                $random_suffix = md5($randval);
                $suffix = substr($random_suffix,0,$lenght);
                return ($suffix);
        }
for ($n=0; $n<=1800; $n++) {
if ($n % 5 == 0) {
print $n . "|";
  for ($b=0; $b<=200; $b++) {
    print "<!--  " . ee_make_suffix(32) . " -->" ;
  }
  flush();
}
usleep(1000000);
}
print " ---" . $n . " <br /><br />EOF";
?>
</body>
</html>
 

mistwang

LiteSpeed Staff
#2
Your understanding is correct.

LSAPI may start extra children process when more requests need to be processed, please take a look at LSAPI_EXTRA_CHILDREN.

To prevent a client exhousting all backend php processes, please try our request rate throttling.
 

PSS

Well-Known Member
#3
Ok, that (LSAPI_EXTRA_CHILDREN) explains the extra processes and why it starts to get flakey when there are about 45 processes (with PHP_LSAPI_CHILDREN=30)!

LSAPI_EXTRA_CHILDREN (default: 1/2 of LSAPI_CHILDREN)

I'll study these more.

Thanks for your quick reply.
 
Top