5

I would like to know what a threaded web server is?

I have performed many searches but am unable to find anything that gives a clear explanation or definition; perhaps somebody can enlighten me.

2 Answers 2

10

A threaded web server is one that handles each request with a new thread, as opposed to handling each request with a new process.

Multi-threading is more complex than concurrency with processes, so there's an increased risk of the web server crashing if one of its modules isn't working correctly. Also, if it does crash, it's more likely to crash all of the threads (ie. all of the requests being handled at the time). However, multi-threaded servers consume less memory and are generally faster.

Here's a benchmark comparing the two (mutually exclusive) apache modules: prefork and worker.

http://www.camelrichard.org/apache-prefork-vs-worker

and their definitions...

http://httpd.apache.org/docs/2.0/mod/prefork.html

http://httpd.apache.org/docs/2.0/mod/worker.html

4
  • As a note: "as opposed to handling each request with individual processes" - there would be other options, too to implement a server. Like event-based where single thread in a single process uses event-based socket-operations
    – johannes
    Apr 27, 2011 at 10:22
  • Agreed... as in node.js ( stackoverflow.com/questions/5681853/… )
    – Homer6
    Apr 27, 2011 at 10:26
  • I don't think the definition of multithreaded server is necessarily 1 request 1 thread. I don't think that would scale real well. Jul 16, 2013 at 22:23
  • You're right. It doesn't. However, that model has been present for some time. I'm not sure that the definition is necessarily one thread per request either. Having a finite thread pool would also be considered a threaded web server. I believe the one thread per connection is more of a pedagogical model, as it's easier to build than a server that uses a thread pool instead.
    – Homer6
    Jul 17, 2013 at 4:58
5

It's a web server that has a queue for incoming HTTP requests and a pool of threads for satisfying them. The server takes the first request off the queue and assigns a thread from the pool to do the work. Requests line up in the queue when they come in faster than the threads can process them or if the pool runs out of threads.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .