1829102 Members
2559 Online
109986 Solutions
New Discussion

Re: Forking Server

 
SOLVED
Go to solution
Becke
Super Advisor

Forking Server


Hi Guys,

Can anyone describe, what is a forking server and how exactly it works???? what is the difference between a forking server and a server in the client/server relationship?

Thanks in Advance
Raf
9 REPLIES 9
Arunvijai_4
Honored Contributor
Solution

Re: Forking Server

Hi Raf,

There are primarily two models in server, one is Forking and other is Thread model. Forking server forks (creates) a new process when a request comes in whereas, thread server, creates a new thread for a new incoming request.

Apache supports both models.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
A. Clay Stephenson
Acclaimed Contributor

Re: Forking Server

Sure, a typical forking server listens for connections on a given port (e.g. 7777) just as a non-forking server would. The difference is that as soon as a client connection is established, the parent immediately forks and hands off that connection to a child process. The connection is transferred to another port (generally in the anonymous range; ie above 49151). The parent process then goes back to listening for new connections on the dedicated port (7777 in this example). A variation on this theme is the pre-forking server in which the parent process immediately forks a number of child processes upon startup so that the relatively expensive fork()'s are already done.

One of the best ways to tackle socket-based client/servers (non-forking, forking, and pre-forking) techniques is with Perl. The Perl code is very similar to what you would do in C and executes almost as fast. I do all of my client/server stuff in Perl these days.
If it ain't broke, I can fix that.
Becke
Super Advisor

Re: Forking Server


Thanks for the detailed info Stephenson and Arun, does anyone of you know a good site so I can jump on and do a bit of reading myself, this way I will understand the whole concept???

Cheers,
Raf
Arunvijai_4
Honored Contributor

Re: Forking Server

Hi Raf,

Yes, You can take a look at any of these sites

http://www.thescripts.com/forum/thread49550.html
http://docs.python.org/lib/node535.html

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Becke
Super Advisor

Re: Forking Server


Arun a quest for you,

You said,
There are primarily two models in server, one is Forking and other is Thread model. Forking server forks (creates) a new process when a request comes in whereas,
thread server, creates a new thread for a new incoming request.

Apache supports both models...

Raf,
You said it creates a new process when a request comes in. Q. Where is this request coming from, is this from a client???

What is the main difference b/w forking server and just a server on the network..I'm still not clear???

Look forward to hearing from you soon..

Arunvijai_4
Honored Contributor

Re: Forking Server

Hi Raf,

You said it creates a new process when a request comes in. Q. Where is this request coming from, is this from a client???

*** Yes, In case of Apache, whenever a client requests a page, a new process being forked everytime.

What is the main difference b/w forking server and just a server on the network..I'm still not clear???

*** Forking server is just another server, it creates a new process when it receives a request from a client.

Forking and threading are models of Server architecture. It is all how you deesign/write
your server.

Hope this is clear.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Arunvijai_4
Honored Contributor

Re: Forking Server

Hi Raf,

I request you to read this book, Internetworking with TCP/IP, Vol. III: Client-Server Programming and Applications--BSD Socket Version (2nd Edition) by Douglas E. Comer, David L. Stevens

http://www.amazon.com/gp/product/013260969X/104-8641370-4287960?v=glance&n=283155

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Arunvijai_4
Honored Contributor

Re: Forking Server

Raf,

An IEEE paper on Webserver architecture attached with this post, hope it will be helpful

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Becke
Super Advisor

Re: Forking Server


Thanks Arun, this would help a lot..

Cheers,
Raf