[OT] This feels wrong (pthreads question)

Levi Pearson levi at cold.org
Mon Jan 29 13:40:46 MST 2007


"Daniel C." <dcrookston at gmail.com> writes:
> Apache does this iirc, and it seems to work fairly well.
>
> Or am I confusing threads and processes?

Depends on which version of apache you're talking about.  Due to the
short-lived nature of http requests, you can get a lot of web hits
without having too many of them be simultaneous, especially if you are
serving small static files like html files and small images.  Thus,
apache almost never needs to have a couple hundred threads running,
much less hundreds of thousands.

A MUD, on the other hand, has long-lasting persistent connections.  If
there are 1000 users connected and each has a thread, there will be a
lot of threads!  The threaded *style* of programming has its
advantages (as well as a lot of disadvantages), but the
*implementation* that maps each thread to a kernel-level process
structure with a unique data stack does not mix well with massively
multithreaded applications due to the heavyweight nature of those
threads.

For an example of what I'm talking about, see this page:
http://www.sics.se/~joe/apachevsyaws.html in which apache 2 and yaws
(a webserver written in Erlang, which implements its threads based on
a select()-style event loop) face off against what amounts to a DOS
attack.  You'll see that apache falls over and dies completely LONG
before yaws does.  I would expect something like Lightthpd to perform
similarly to yaws in a comparison like this, since it also uses an
event-driven model.

                --Levi



More information about the PLUG mailing list