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

Go Back   LiteSpeed Support Forums > External Applications > PHP > Trying to understand phplsapi settings

Reply
 
Thread Tools Display Modes
  #1  
Old 07-16-2007, 10:36 AM
PSS PSS is offline
Senior Member
 
Join Date: Jun 2007
Posts: 126
Default Trying to understand phplsapi settings

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:
    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
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 Code:
<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 == 0) {
print 
$n "|";
  for (
$b=0$b<=200$b++) {
    print 
"<!--  " ee_make_suffix(32) . " -->" ;
  }
  
flush();
}
usleep(1000000);
}
print 
" ---" $n " <br /><br />EOF";
?>
</body>
</html>
Reply With Quote
  #2  
Old 07-16-2007, 10:48 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
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.
Reply With Quote
  #3  
Old 07-16-2007, 11:11 AM
PSS PSS is offline
Senior Member
 
Join Date: Jun 2007
Posts: 126
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.
Reply With Quote
  #4  
Old 07-16-2007, 11:34 AM
PSS PSS is offline
Senior Member
 
Join Date: Jun 2007
Posts: 126
One question: does client throttle distinguish clients from same IP (using e.g. ETag, browser,OS)?
Reply With Quote
  #5  
Old 07-16-2007, 12:17 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
No, only IP is used to distinguish clients. Usually it is not a problem.
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:49 PM.



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