Re: Linus on Linux, Apache and Threads

Alex Belits (abelits@phobos.illtel.denver.co.us)
Thu, 22 Apr 1999 19:28:16 -0700 (PDT)


On 23 Apr 1999, Stuart Lynne wrote:

> > it's virulently unstable (I used it on OS/2, and it had
> > SEGV/BUS errors almost nonstop). If you enjoy playing with
> > threads, check it out.
>
> Apached processes are long lived processing multiple requests. So doesn't it
> boil down to the difference between passing file descriptors to child processes
> or a different thread? That and the fact that you probably can have a larger
> number of active threads than processes for any given amount of memory you
> want to use?

AFAIK Apache on Unix doesn't pass file descriptors -- every process does
all the work by itself. Apache on Windows passes fds between threads,
however that was done not as an attempt to make usable
multithreaded design but to make something that will work on Windows there
multiple-processes design simply won't work.

> This is not to say that the file passing model is optimal. A select() loop
> should be faster. But the apache team seems to be more interested in robust
> and portable with reasonable performance than performance at any cost.

It's rather complex issue -- select() has limited scalability, and
poll() that is supported as a syscall in later version of the kernel
scales somewhat better. Worse yet, 2.0.x kernels had 256 fds per process
limit, and that is also fixed in later versions. Another problem is that
select() loop shouldn't call any blocking syscalls, and sending large
amount of data through select() loop requires more syscalls and more user
time than blocking i/o.

In my FTP/HTTP server (fhttpd) I use a combination of main process that
uses select() or poll(), then passes fd (along with parsed request) to one
of many processes that use blocking I/O to reply to the client. The goal
of that design was mostly flexibility -- processes can be specialized
(file sending, PHP, possibly interpreters of other languages,
some applications), so main process can parse request and make decision,
which process should handle it. Lack of blocking in the main loop saves a
lot of trouble, however the performance of this thing depends on
select()/poll() scalability and the time of context switch between
processes.

-- 
Alex

---------------------------------------------------------------------- Excellent.. now give users the option to cut your hair you hippie! -- Anonymous Coward

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/