Re: InfoWorld web server shootout

Dean Gaudet (
Mon, 7 Jul 1997 23:49:35 -0700 (PDT)

On Mon, 7 Jul 1997, Alex Belits wrote:

> Apache originally was not threaded, and I don't know, which versions are
> threaded -- they definitely are not suitable for any platform but NT or
> Solaris, where native threads are more efficient compared to processes.

Nothing released yet is threaded. We have threading in our NT port, which
hasn't been released even in beta yet.

> However, simultaneous accept() in multiple processes can cause problem
> that was called "thundering herd" on freebsd-hackers ML -- all processes
> awakened, but only one succeeds in accept() when connection arrives.
> FreeBSD fixed that in 2.2.?, although I don't know if such problem exists
> in Linux.

We've had indications that the problem exists in sunos, and eyeballing the
linux code makes it obvious that it exists in linux as well. For this
reason, and others, apache uses another mechanism to serialize all of the
children before they enter accept() (either fcntl or flock in the 1.2
series, but I'm looking at using semaphores). Various of our users on
many architectures have reported much improved behaviour after enabling
the serialization directives, which is why I'm sure it's a common problem
(and why we chose to default them to on for more arches in 1.2.1). The
apache code in this area is mildly lame though.

The thing that messes it up is supporting multiple Listen directives. If
you do a naive select/accept loop you'll either end up starving some
sockets (if you use blocking listeners), or you'll end up spiking the load
(if you use non-blocking listeners) as most of the children race out of
select, fail on accept, and run back into select. For a single listening
socket it's much easier.