Re: copy-on-write

From: Dean Gaudet <dgaudet-list-squid-dev@dont-contact.us>
Date: Wed, 4 Jun 1997 21:07:44 -0700 (PDT)

On Sat, 31 May 1997, Oskar Pearson wrote:
> This is what apache does (never actually looked at the source though ;):
>
> Forks multiple processes:
> does a listen on the port it's supposed to be watching
> when it gets a connection, it passes the filehandle to the first process
> it forked and considers it busy until it gets
> a reply from that process saying "done"
> if it gets another connection it passes it to the first available child.

That's how NCSA and apache-0.6 worked... apache uses a pre-forking model
in which the children are forked before the request arrives, and require
very little communication with the parent. The only communication they
use with the parent is to keep track of how many servers are in which
state.

The children all run a main loop which does an accept(). When something
comes in the child that happens to exit accept() handles it... at least
that's the theory, when you throw multiple Listens and various buggy
OSs into the mix it changes slightly.

In fact it looks like post-1.2 we're going to make it behave in the
following manner across the board:

    child_main()
    {
        for(;;) {
            acquire_mutex ();
            accept a connection
            release_mutex ();
            process connection
        }
    }

The alternatives just seem way too expensive. For example, in the
present code all the children sit in a select() on the listening sockets.
When a connection is pending, all the children wake up... if you've got
300 children that does fun things to your load avg. Actually a solution
like the above that has a configurable "accept concurrency" that allows
more than one child into the select/accept phase but doesn't let all of
them in at once is probably sufficient for max performance.

I mention this 'cause it's totally applicable to multiple process or
multiple thread models of programming, which is what you're all talking
about :)

Regarding your performance problems with apache, if you want to send them
to me privately I can either say "yup we know that one" or suggest a fix.
One of the worst problems with Apache performance is that it requires
you to know which knob to tune... kinda like linux.

Dean
Received on Tue Jul 29 2003 - 13:15:41 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:11:19 MST