Why do Unix webservers typically use fork() instead of multi-threading?
|
|
0
|
|
|
|
Reply
|
bob136 (381)
|
2/7/2009 3:59:46 PM |
|
bob@coolgroups.com wrote:
> Why do Unix webservers typically use fork() instead of multi-threading?
Perhaps aside from Java Web servers and roll-your-own, most don't fork() for
concurrency. Most are single process, and use asynchronous network I/O.
You're probably thinking of Apache. But the multi-process model is quite
common in general.
A more illuminating question might be why Windows network servers use so
much multi-threading.
Generaly speaking, unless you need to share many complex data structures
between threads of control, it's easier, simpler, and more robust (more
secure, for many definitions of secure) to employ multiple processes than
multiple threads w/ shared memory.
And often times when you do need to share complex data structures, you can
just use asynchronous I/O and a single thread of control.
In general, performance has nothing to do w/ it, other than people making
ill-informed decisions based on that factor.
|
|
0
|
|
|
|
Reply
|
William
|
2/7/2009 6:02:58 PM
|
|
>> Why do Unix webservers typically use fork() instead of multi-threading?
Because that's usually what you want.
An alternative question is -- why don't non-Unix webservers fork?
The aswer is usually that they don't support fork or that their process
model makes fork() too expensive.
--
mac the na�f
|
|
0
|
|
|
|
Reply
|
alexc8 (94)
|
2/8/2009 12:06:57 AM
|
|
Alex Colvin <alexc@theworld.com> wrote:
> >> Why do Unix webservers typically use fork() instead of multi-threading?
> Because that's usually what you want.
> An alternative question is -- why don't non-Unix webservers fork?
> The aswer is usually that they don't support fork or that their process
> model makes fork() too expensive.
I haven't voluntarily used a Windows computer since 3.11. But Vista and
Windows 7 finally have fork(), and though I won't switch, whenever somebody
tells me they don't like Vista, I exclaim, "but it has fork!" Of course, I
get confused looks, but they're intrigued by my enthusiasm.
IMHO, it's arguably the biggest advancement since Windows 95 joined Unix in
32-bit, protected-mode land. Fortunately, I had already jumped ship to Linux
before that happened. But for the first time I'm actually excited about a
new MS product. I wish it well, because it'll make my life easier writing
cross-platform software. Now, I just need WINE to pick up the pace chasing
Microsoft's APIs.
|
|
0
|
|
|
|
Reply
|
William
|
2/8/2009 4:28:14 AM
|
|
On 2009-02-08, William Ahern <william@wilbur.25thandClement.com> wrote:
>
> I haven't voluntarily used a Windows computer since 3.11. But Vista and
> Windows 7 finally have fork(), and though I won't switch, whenever somebody
> tells me they don't like Vista, I exclaim, "but it has fork!" Of course, I
> get confused looks, but they're intrigued by my enthusiasm.
[off topic]
Does it?! I've been coerced in the past to write cross-platform programs
that'll work on windows, and something like that would really help!
Since I've read your post, I've been skimming through the MSDN process
section and can't find something relevant, can you elaborate? Is it a
new system call, something like _fork (tough chance) or is it a new
parameter for CreateProcess?
Now if only the win32 PE linker/loader/whatever supported leaving symbols
unresolved in DLLs to be resolved at load time using symbols in the
process that loads them (like -rdynamic), I'd be on easy street :)
[/off topic]
--
John Tsiombikas (Nuclear / Mindlapse)
http://nuclear.sdf-eu.org/
|
|
0
|
|
|
|
Reply
|
nuclear (91)
|
2/8/2009 5:42:04 AM
|
|
On Feb 7, 7:06=A0pm, Alex Colvin <al...@TheWorld.com> wrote:
> >> Why do Unix webservers typically use fork() instead of multi-threading=
?
>
> Because that's usually what you want.
> An alternative question is -- why don't non-Unix webservers fork?
>
> The aswer is usually that they don't support fork or that their process
> model makes fork() too expensive.
With a multithreaded model (as opposed to fork) I would think you at
least get a tighter latency when you need to switch to another thread
to handle an event, since you don't have to flush the TLB along the
way. But admittedly I have no idea how much/little these cache misses
actually matter to the overall latency for a web server.
-Will
|
|
0
|
|
|
|
Reply
|
willh126 (1)
|
2/8/2009 5:11:14 PM
|
|
bob@coolgroups.com writes:
> Why do Unix webservers typically use fork() instead of
> multi-threading?
'UNIX(*) webservers' typically use any multiplexing facilities
available to them, depending on what the focus of development
was. Insofar this refers to Apache: The first Apache versions
exlusively used preforked processes and a dedicated process per
request (or connection), presumably, because this was the most
portable solution back then. This is still the default
'multi-processing module' for installation UNIX(*)- or UNIX(*)-like
systems.
As long as their isn't a specific reason to proceed otherwise, leaving
the defaults as they are usually make sense.
|
|
0
|
|
|
|
Reply
|
rweikusat (2680)
|
2/8/2009 7:10:02 PM
|
|
bob@coolgroups.com wrote:
> Why do Unix webservers typically use fork() instead of multi-threading?
Because it is easier to put a child in jail than a thread.
Because most of them were written before the thread libraries.
Because the programmers were more familiar with it.
Because that is the example in the book.
Some other dozen reasons.
Take your pick.
|
|
0
|
|
|
|
Reply
|
gldncagrls (469)
|
2/8/2009 11:30:36 PM
|
|
Rainer Weikusat wrote:
> bob@coolgroups.com writes:
>> Why do Unix webservers typically use fork() instead of
>> multi-threading?
>
> 'UNIX(*) webservers' typically use any multiplexing facilities
> available to them, depending on what the focus of development
> was. Insofar this refers to Apache: The first Apache versions
> exlusively used preforked processes and a dedicated process per
> request (or connection), presumably, because this was the most
> portable solution back then. This is still the default
> 'multi-processing module' for installation UNIX(*)- or UNIX(*)-like
> systems.
Since apache supports 3rd party loadable modules, bad code will only zap
one process at a time. Requests not using the bad module will always work.
-srp
|
|
0
|
|
|
|
Reply
|
saju.pillai2 (32)
|
2/9/2009 6:26:51 AM
|
|
Golden California Girls wrote:
> bob@coolgroups.com wrote:
>> Why do Unix webservers typically use fork() instead of multi-threading?
>
> Because it is easier to put a child in jail than a thread.
>
> Because most of them were written before the thread libraries.
Don't you mean "during the period in which threading fell out of favour
(aka the perceived decline of the mainframe, Burrough's machines had
thread in the 70's (or possibly even the 60's))."
Cheers,
Gary B-)
--
______________________________________________________________________________
Armful of chairs: Something some people would not know
whether you were up them with or not
- Barry Humphries
|
|
0
|
|
|
|
Reply
|
grschmidt (100)
|
2/9/2009 11:52:16 AM
|
|
Gary R. Schmidt wrote:
> Golden California Girls wrote:
>> bob@coolgroups.com wrote:
>>> Why do Unix webservers typically use fork() instead of multi-threading?
>>
>> Because it is easier to put a child in jail than a thread.
>>
>> Because most of them were written before the thread libraries.
> Don't you mean "during the period in which threading fell out of favour
> (aka the perceived decline of the mainframe, Burrough's machines had
> thread in the 70's (or possibly even the 60's))."
You were writing *WEBSERVERS* in the 60's and 70's?
|
|
0
|
|
|
|
Reply
|
gldncagrls (469)
|
2/9/2009 5:33:47 PM
|
|
Golden California Girls wrote:
> Gary R. Schmidt wrote:
>> Golden California Girls wrote:
>>> bob@coolgroups.com wrote:
>>>> Why do Unix webservers typically use fork() instead of multi-threading?
>>> Because it is easier to put a child in jail than a thread.
>>>
>>> Because most of them were written before the thread libraries.
>> Don't you mean "during the period in which threading fell out of favour
>> (aka the perceived decline of the mainframe, Burrough's machines had
>> thread in the 70's (or possibly even the 60's))."
>
> You were writing *WEBSERVERS* in the 60's and 70's?
The subject is "fork", with a web server just being an example of fork
versus threads.
Cheers,
Gary B-)
--
______________________________________________________________________________
Armful of chairs: Something some people would not know
whether you were up them with or not
- Barry Humphries
|
|
0
|
|
|
|
Reply
|
grschmidt (100)
|
2/9/2009 10:24:31 PM
|
|
John Tsiombikas <nuclear@siggraph.org> wrote:
> On 2009-02-08, William Ahern <william@wilbur.25thandClement.com> wrote:
> >
> > I haven't voluntarily used a Windows computer since 3.11. But Vista and
> > Windows 7 finally have fork(), and though I won't switch, whenever somebody
> > tells me they don't like Vista, I exclaim, "but it has fork!" Of course, I
> > get confused looks, but they're intrigued by my enthusiasm.
> [off topic]
> Does it?! I've been coerced in the past to write cross-platform programs
> that'll work on windows, and something like that would really help!
> Since I've read your post, I've been skimming through the MSDN process
> section and can't find something relevant, can you elaborate? Is it a
> new system call, something like _fork (tough chance) or is it a new
> parameter for CreateProcess?
*sigh* I think somebody played a very cruel joke on me. I could _swear_ I
remember reading it on one of the Vista features articles on Wikipedia, but
I can find no trace of it. I even vaguely remember reading about it on MSDN.
Maybe I deluded myself--mirages in the desert. :(
|
|
0
|
|
|
|
Reply
|
William
|
2/10/2009 12:54:59 AM
|
|
Golden California Girls wrote:
> Gary R. Schmidt wrote:
>> Golden California Girls wrote:
>>> bob@coolgroups.com wrote:
>>>> Why do Unix webservers typically use fork() instead of multi-threading?
>>> Because it is easier to put a child in jail than a thread.
>>>
>>> Because most of them were written before the thread libraries.
>> Don't you mean "during the period in which threading fell out of favour
>> (aka the perceived decline of the mainframe, Burrough's machines had
>> thread in the 70's (or possibly even the 60's))."
>
> You were writing *WEBSERVERS* in the 60's and 70's?
He'll release the beta Real Soon Now, as soon as he's
fixed the last bug ...
--
Eric Sosman
esosman@ieee-dot-org.invalid
|
|
0
|
|
|
|
Reply
|
esosman2 (2945)
|
2/10/2009 1:35:15 AM
|
|
Gary R. Schmidt wrote:
> Golden California Girls wrote:
>> Gary R. Schmidt wrote:
>>> Golden California Girls wrote:
>>>> bob@coolgroups.com wrote:
>>>>> Why do Unix webservers typically use fork() instead of
>>>>> multi-threading?
>>>> Because it is easier to put a child in jail than a thread.
>>>>
>>>> Because most of them were written before the thread libraries.
>>> Don't you mean "during the period in which threading fell out of favour
>>> (aka the perceived decline of the mainframe, Burrough's machines had
>>> thread in the 70's (or possibly even the 60's))."
>>
>> You were writing *WEBSERVERS* in the 60's and 70's?
> The subject is "fork", with a web server just being an example of fork
> versus threads.
>>>>> Why do Unix webservers typically use fork() instead of
>>>>> multi-threading?
Somehow I think my English teacher would disagree with you. But feel free to
diagram it.
|
|
0
|
|
|
|
Reply
|
gldncagrls (469)
|
2/10/2009 2:34:32 AM
|
|
William Ahern <william@wilbur.25thandClement.com> wrote in
news:3sv666-aev.ln1@wilbur.25thandClement.com:
> John Tsiombikas <nuclear@siggraph.org> wrote:
>> On 2009-02-08, William Ahern <william@wilbur.25thandClement.com>
>> wrote:
>> >
>> > I haven't voluntarily used a Windows computer since 3.11. But Vista
>> > and Windows 7 finally have fork(), and though I won't switch,
>> > whenever somebody tells me they don't like Vista, I exclaim, "but
>> > it has fork!" Of course, I get confused looks, but they're
>> > intrigued by my enthusiasm.
>> Does it?! I've been coerced in the past to write cross-platform
>> programs that'll work on windows, and something like that would
>> really help!
>
>> Since I've read your post, I've been skimming through the MSDN
>> process section and can't find something relevant, can you elaborate?
>> Is it a new system call, something like _fork (tough chance) or is it
>> a new parameter for CreateProcess?
>
>
> *sigh* I think somebody played a very cruel joke on me. I could
> _swear_ I remember reading it on one of the Vista features articles on
> Wikipedia, but I can find no trace of it. I even vaguely remember
> reading about it on MSDN. Maybe I deluded myself--mirages in the
> desert. :(
The "NT native API" underlying the Win32 API supports the equivalent of
fork() and always has. Unfortunately, Microsoft has never provided
enough public documentation of this API to make it easily usable. See
this discussion:
http://groups.google.com/group/microsoft.public.win32.programmer.kernel/
browse_frm/thread/7a3b4709999dc9a2
[http://tinyurl.com/bhqrr8]
There is also a published book that describes the native api.
http://books.google.com/books?id=Fp1ct-
bKYdcC&printsec=frontcover&dq=windows+2000+native+api
[http://tinyurl.com/b2esq3]
GH
|
|
0
|
|
|
|
Reply
|
gil_hamilton (26)
|
2/11/2009 2:15:05 PM
|
|
|
15 Replies
35 Views
(page loaded in 1.228 seconds)
Similiar Articles: Using fork() with a telnet-esque socket connection - comp.lang ...There is still an appreciable delay between a client making a connection and that client being serviced, however, due to the fork. 3. Pre-forking. question about execl(), fork(), stdin, stdout, stderr - comp.unix ...I'm not understanding what exactly happens with stdin, stdout and stderr when I fork and execl from the child. Here's what I want to do: After NNTP ... fork function failed - comp.sys.hp.hpuxfork function failed - Toolbox for IT Groups Hi there, We have a 7029,6C3 with 2Gb of RAM, AIX 5.1 ML 3 with Oracle 9i release 2. Oracle is installed and running happily ... fork() race in SIGCHLD handler - comp.unix.programmerHi, In tracking down some unexpected behaviour in a program of mine, I have noticed that the test code below exhibits a timing race on fork() in Linu... format command not work - comp.unix.solarisniraj_vara <niraj.vara@gmail.com> wrote: > -bash-3.00# format > -bash: fork: Not enough space Are you out of memory and swap? Are MANY programs behaving that way? how to debug forked child in eclipse CDT - comp.unix.programmer ...} } I also tried step by step from the beginning but the child process ran away right after fork(). I'm using Eclipse 3.1.2. Thanks, -- Metaosp SIGCHLD, fork() and sleep() - comp.unix.programmerHello, I cannot understand this simple situation: I ignore SIGCHLD signal and quickly fork N child processes. As I ignore SIGCHLD signal the... fork (UDP) server - comp.unix.programmeri'm writing a UDP protocol to transfer file, I have a problem into serverside : I'd like to fork the server process for any new client. A code like th... fork(): how can I kill forked process and all ITS children, but ...I am trying to write a program that will fork a process, and execute the given task... the catch is that if it runs too long, I want to clean it up. ... how to terminate a child process properly - comp.unix.programmer ...Hi, I have a program need to fork a child which in turn fork other 2 processes (grand children). I used the following method to kill grand child pro... Practice of using fork() - comp.unix.programmerSo I thought that maybe I should avoid exec and just fork my process and let one branch return, while the other branch executes another function (instead of execing ... how to generate 100% cpu load on solaris 10 zone - comp.unix ...By being at 33% does it mean there are 3 zones ? here it says : http://www ... #!/usr/bin/perl print "Eating the CPUs\n"; foreach $i (1..64) { $pid = fork ... how to kill all child when parent exits - comp.unix.programmer ...Guys, I am writing an application where the parent (daemon) forks few child processes. My requirement is that when the parent process exits/kil... waitpid == -1 and errno == ECHILD - comp.unix.programmer ...> > -- > Alan Curry Suppose that 1) pid =3D fork() > 0, in parent process (ie, fork() was successful) 2) there is NOT any handler for SIGCHLD, that colls wait*() 3) there ... Assura terminates on Segmentation violation - comp.cad.cadence ...> > *WARNING* aveng exit with bad status > *WARNING* Status 256 > *WARNING* Assura execution terminated > > > ***** aveng fork terminated abnormally ***** > I ... III Forks Steakhouse and Seafood | USDA Prime Steakhouse | Upscale ...III Forks is one of the best steakhouses in town. From thick signature cuts of USDA Prime Beef to ocean-fresh fish and buttery lobster, the food at III Forks is ... fork(3): create new process - Linux man pageThe fork() function shall create a new process. The new process (child process) shall be an exact copy of the calling process (parent process) except as ... 7/18/2012 2:12:37 PM
|