![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| fork() help | alexicopax | High Level Programming | 3 | 03-08-2007 12:08 AM |
| shm sem fork etc... Please help | Dana73 | High Level Programming | 1 | 02-28-2006 04:51 AM |
| Fork () | iwbasts | High Level Programming | 5 | 11-09-2005 12:39 AM |
| Fork or what? | crippe | High Level Programming | 0 | 03-08-2005 01:21 AM |
| fork() | MKSRaja | High Level Programming | 2 | 02-07-2005 07:55 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
What is a fork? Why would one create a fork? What are the advantages and disadvantages of using a fork?
Please advise. Thank You. Deepali |
| Forum Sponsor | ||
|
|
|
|||
|
Hi,
I'm new to programming under unix too, and I'm trying to implement a load balancing system for web traffic. The idea is this, I have a single web server running on PC A, and I have 5 other PCs (PC B - PC F) running only mysql servers. Assuming all the databases contain synchronized data, I would like to implement a database search facility where the web server receives the input, split the input keywords into single keywords and using fork() in the cgi-script, spawn multiple child processes to issue seperate queries to each of the database servers via different connection strings to receive the result. Will this result in a much faster response time than just running a single database server and searching all the keywords serially ? Is there a better way to do it besides forking ? What are the drawbacks of forking and implementing it this way ? Sample code would very much be appreciated. Thanks, Wee |
|
||||
|
Threading
I thibk you should do some reading on how write threaded programs.
__________________
Patrick Van der Veken - UNIX consultant (c) 2001 - 2001 http://www.baanboard.com - http://www.ux-core.com 'True strength lies in gentleness' - Irish proverb |
|
||||
|
forking
Wee,
Yes you could use fork() BUT... I would also recommend using threads to accomplish what you are proposing. If you were to use fork(), you would have as many separate programs running as you have keywords per query. Then, you would have to synchronize the results of each into a single result. Threads will allow you to run each keyword query against separate databases but still allow you to synchronize the results from within the same program. I would recommend reading... "Programming with POSIX Threads" ISBN 0-201-63392-2 "Pthreads Programming" ISBN 1-56592-115-1 |
||||
| Google UNIX.COM |