views:

353

answers:

2

I would like to know why we prefer to make web servers multi-threaded

instead of make it multi-process web servers ....

Is it because of legacy issues.....

I would like to hear practical reasons as well as theoretical reasons

+1  A: 

Threads are usually cheaper than processes.

SLaks
What does cheaper ..... means ?????
Omar
They usually have less memory overhead.
SLaks
The specifics are operating-system dependent. In general, I understand UNIX (/Linux/etc) programming tends to be somewhat more process-centric and Windows more thread-centric, in part because Windows has (or, historically, had) inferior performance dealing with multiple processes.
fennec
+2  A: 

On *nix, to start up a process you need duplicate all the resources of the parent process. All the parents file descriptors are dup'ed, for example, and a new memory space is created to contain the new process. When the process terminates everything has to be torn down.

A thread, on the other hand, is essentially just a stack. Very quick to start and stop.

Early web servers didn't use threads for a simple reason: they weren't implemented yet.

Richard Pennington