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

Go Back   LiteSpeed Support Forums > External Applications > Ruby/Rails > LSWS starts too many dispatch.lsapi processes

Reply
 
Thread Tools Display Modes
  #1  
Old 08-02-2006, 04:14 AM
andreas andreas is offline
Senior Member
 
Join Date: Aug 2006
Posts: 91
Default LSWS starts too many dispatch.lsapi processes

Hi,

I configured my Rails app according to the description in the Wiki. I have set both max connections and LSAPI_CHILDREN to 3, but when I do multiple concurrent requests way too many processes are started:


├─lshttpd─┬─lscgid
│ └─lshttpd─┬─admin_php
│ └─dispatch.lsapi───11*[dispatch.lsapi]


Why?

Thanks
Andreas
Reply With Quote
  #2  
Old 08-02-2006, 07:07 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Are you using 2 cpu enterprise? Has "instances" been set to "1", has "Initial request timeout" been set to be greater than the time that the slowest ruby request will take?
Reply With Quote
  #3  
Old 08-02-2006, 07:25 AM
andreas andreas is offline
Senior Member
 
Join Date: Aug 2006
Posts: 91
Quote:
Originally Posted by mistwang
Are you using 2 cpu enterprise? Has "instances" been set to "1", has "Initial request timeout" been set to be greater than the time that the slowest ruby request will take?
I am using the standard version on a 1 CPU machine. My settings:

Name RubyRailsLSAPI
Address uds://tmp/lshttpd/rubyrailslsapi.sock
Max Connections 3
Environment RAILS_ENV=production
LSAPI_CHILDREN=3
Initial Request Timeout (secs) 30
Retry Timeout (secs) 30
Persistent Connection Yes
Connection Keepalive Timeout N/A
Response Bufferring No
Auto Start Yes
Command /xyz/public/dispatch.ls api
Back Log 1
Instances 1
Run On Start Up Yes
Max Idle Time -1
Priority N/A
Memory Soft Limit (bytes) N/A
Memory Hard Limit (bytes) N/A
Process Soft Limit 1
Process Hard Limit 1

When I click on a link in my application a few times it results in an immediate increase in the number of processes until all the requests are handled, so I don't think the 30s timeout matters.
Reply With Quote
  #4  
Old 08-02-2006, 07:29 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
should increase the "Process Soft/Hard limit" to a more reasonable value, like "50-100". "Back log" should be increase to something like "10".
Reply With Quote
  #5  
Old 08-02-2006, 07:43 AM
andreas andreas is offline
Senior Member
 
Join Date: Aug 2006
Posts: 91
Quote:
Originally Posted by mistwang
should increase the "Process Soft/Hard limit" to a more reasonable value, like "50-100". "Back log" should be increase to something like "10".
I made the changes and restarted the server, but still the same probem. pstree suggests that the dispatcher forks a new process for every concurrent request and immediately kills it after it has answered its request.

A few concurrent requests active:
└─lshttpd───dispatch.lsapi───8*[dispatch.lsapi]

After the requests are handled the number of children immediately drops to 1:
└─lshttpd───dispatch.lsapi───dispatch.lsapi

Last edited by andreas; 08-02-2006 at 07:45 AM..
Reply With Quote
  #6  
Old 08-02-2006, 08:11 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Are you testing this from a browser by clicking "refresh" button quickly and repeatedly? Or using a load testing software like "ab"?
The former way may cause what you observed, that because the request has been canceled in the middle, so LSWS has to close the connection on its side before the request has been finished, on the dispatch.lsapi side, the process will die after finish the request since the connection to server has been lost.
the dispatch.lsapi process will stay alive as long as the connection to server is in good shape.
Lshttpd should not make more than 3 concurrent connections to dispatch.lsapi, but there might be more processes which were processing canceled requests.

That's my explanation, but I might be wrong. Please try you test with "ab", there should be four process at most. If it is not the case, please let me know.
Reply With Quote
  #7  
Old 08-02-2006, 08:39 AM
andreas andreas is offline
Senior Member
 
Join Date: Aug 2006
Posts: 91
Quote:
Originally Posted by mistwang
Are you testing this from a browser by clicking "refresh" button quickly and repeatedly?
Yes.

Quote:
Or using a load testing software like "ab"?
The former way may cause what you observed, that because the request has been canceled in the middle, so LSWS has to close the connection on its side before the request has been finished, on the dispatch.lsapi side, the process will die after finish the request since the connection to server has been lost.
the dispatch.lsapi process will stay alive as long as the connection to server is in good shape.
Lshttpd should not make more than 3 concurrent connections to dispatch.lsapi, but there might be more processes which were processing canceled requests.
Can't this be prevented? I find it worrying that someone can create insane numbers of processes with this kind of behaviour. Especially with the high RAM requirements of Rails it is very easy to DOS a small server this way.

Quote:
That's my explanation, but I might be wrong. Please try you test with "ab", there should be four process at most. If it is not the case, please let me know.
Yes, it doesn't create more than 3 children when I use ab -c 10. But it kills all but one after the requests are finished. Is there some way of keeping the processes alive?
Reply With Quote
  #8  
Old 08-02-2006, 09:17 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Quote:
Can't this be prevented? I find it worrying that someone can create insane numbers of processes with this kind of behaviour. Especially with the high RAM requirements of Rails it is very easy to DOS a small server this way.
We will improve the process manager see if we can come up with a better solution. This kind of attack can be easily fend off with our request rate throttling feature.
Quote:
Yes, it doesn't create more than 3 children when I use ab -c 10. But it kills all but one after the requests are finished. Is there some way of keeping the processes alive?
That's because "ab" cancels the extra requests it sent at the end of the test. If you try "ab -c 1", the child process is alive at the end.
Reply With Quote
  #9  
Old 08-03-2006, 09:20 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Quote:
Can't this be prevented? I find it worrying that someone can create insane numbers of processes with this kind of behaviour. Especially with the high RAM requirements of Rails it is very easy to DOS a small server this way.
Please try ruby-lsapi 1.4 release, the maximum number of children process is limited to twice of the configured value, the children process can stays alive as well.
Reply With Quote
  #10  
Old 08-04-2006, 02:27 AM
andreas andreas is offline
Senior Member
 
Join Date: Aug 2006
Posts: 91
Thanks for the quick update. Could you please also upload the new gem version of ruby-lsapi?
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
LSWS 3.0RC2 and trac-fcgi Erg CGI/Perl/Python 13 02-06-2009 12:16 PM
PHP processes constantly climbing matt Bug Reports 9 11-22-2005 11:54 AM
Not to stop FCGI apps while reloading LSWS Roman2K Feedback/Feature Requests 4 10-12-2005 01:21 PM
LSWS killed my pet squirrel!!! DNSFusion Bug Reports 1 07-24-2004 08:01 PM
Testimonial : LSWS as web app frontend instead of Apache bogus Feedback/Feature Requests 1 03-26-2004 10:32 AM


All times are GMT -7. The time now is 09:16 AM.



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