You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Alexei Kosut <ak...@organic.com> on 1997/07/14 22:11:38 UTC

Apache/Win: threading?

I'm still trying to understand exactly how Apache/Windows currently
handles requests. So if anyone can help me answer this question, I'd be
happy.

AFAIK, it starts up a bunch of processes, but only one actually receives
the requests. There were some emails about this last week, when I asked
why the scoreboard didn't use shared memeory (btw, what if the lead
process dies - does the scoreboard get reset? Maybe we should rethink
this).

Within this process, the server is multithreaded, each thread
handling a connection, or waiting for one. As near as I can tell, the
server starts up the number of threads specified by the ThreadsPerChild
directive (BTW, it looks like if this is missing, there is no default
value, threads_per_child remains uninitialized - this is bad) at the
beginning of its lifetime, and never adds any new ones. Which means that
if there are more requests that come in than there are threads (the
reccomended default is 20), those requests would have to wait. I may be
wrong, but that's how the code looks.

I thought one of the points of multithreading was to allow essentially
infinite requests at a time, since threads can be created and destroyed
with mininal time and effort (unlike processes). I understand that on a
heavy-load server, I could set ThreadsPerChild 1000 or something, but
that would mean 1000 threads would pop up all the time, which could be
rather memory consuming. Also, Apache would not just "work" (albiet
inefficiently) out of the box, as Apache does in Unix.

How hard would it be to, upon receiving a connection, have the thread
check how many are left, and if it is less than a MinSpareThreads-like
number, spawn off a MaxSpareThreads-like number more, and set some of the
existing threads to die off at the end of their current connection (so
you don't get infinite growth).

It doesn't sound like it would be too hard to implement. Of course, there
would still want to be a maximum number (MaxClients) of threads, but it
would probably give Apache a greater flexibility in how it worked.

BTW, going back to Unix. I remember a discussion a month or so ago about
how Apache only spawns a new process once a second, and this can make for
too-slow growth on heavily-hit servers that are not configured
properly. I remember it was suggested that Apache use an exponential
growth method - fork one server a second, two the next, then four, eight,
etc... That sounded like a good idea. Did anyone ever implement it?

-- Alexei Kosut <ak...@organic.com>


Re: Apache/Win: threading?

Posted by Dean Gaudet <dg...@arctic.org>.
On Mon, 14 Jul 1997, Alexei Kosut wrote:

> BTW, going back to Unix. I remember a discussion a month or so ago about
> how Apache only spawns a new process once a second, and this can make for
> too-slow growth on heavily-hit servers that are not configured
> properly. I remember it was suggested that Apache use an exponential
> growth method - fork one server a second, two the next, then four, eight,
> etc... That sounded like a good idea. Did anyone ever implement it?

This is one of the things I wanted the feature freeze extended for.  It
hasn't been implemented yet though. 

Dean