views:

1149

answers:

2

I'm running a Django app using FastCGI and lighttpd.

Can somebody explain me what I should consider when deciding what value to use for maxrequests, maxspare, minspare, maxchildren?

These options are not too well documented, but seem quite important.

Don't just tell me what they do; I want to understand what implications they have and how I should decide on what values to use.

Thanks.

+7  A: 

Let's start with the definition

    maxrequests: How many requests does a child server before being killed 
                 and a new one forked
    maxspare   : Maximum number of spare processes to keep running
    minspare   : Minimum number of spare processes to prefork
    maxchildren: Hard limit number of processes in prefork mode

This means that you'll have at most maxchildren processes running at any given time in your webserver, each running for maxrequests requests. At server start you'll get minspare processes, which will keep growing until maxspare (or maxchildren) if more requests are coming.

So, minspare lets you say how many concurrent requests are you expecting at a minimum (important to avoid the process creation if you start with one, it's good to start at, say 10), and maxspare lets you say how many concurrent requests will your server attend to at most (without compromising it's expected response time and so on. Needs a stress test to validate). And maxrequests is talking about the lifetime of each child, in case they cannot run forever due to any kind of constraint.

Vinko Vrsalovic
Good explanation. Can you however say more about maxrequests? That is my biggest concern. Why would you want a child process to die after a certain number of requests? To protect from eventual memory leaks?
ionut bizau
I can't speak for everyone, though with Django and fastcgi we've been seeing a lot of memory issues with long-lived fastcgi processes. Setting a reasonable value for `maxrequests` keeps us from having to manually kill large processes since they're not around long enough for the memory leak to do much damage.
jgeewax
So what's the difference between maxchildren and maxspare? They seem redundant to me.
Dustin Boswell
There can be a maximum of `maxchildren` processes, and there can be a maximum of `maxspare` spare processes (free, unused, waiting for request processes). So maxchildren >= maxspare.
Vinko Vrsalovic
A: 

Don't forget to coordinate your fcgi settings with your apache worker settings. I usually keep more apache workers around than fcgi workers... they are lighter weight and will wait for an available fcgi worker to free up to process the request if the concurrency reaches higher than my maxspare.

diclophis