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.

link|improve this question

feedback

migrated from stackoverflow.com Apr 29 '11 at 4:09

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 5 down vote accepted

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

link|improve this answer
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 '11 at 10:22
Agreed... as in node.js ( stackoverflow.com/questions/5681853/… ) – Homer6 Apr 27 '11 at 10:26
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.