[UPHPU] Question: Has anyone used forks before in a web app?

Mac Newbold mac at macnewbold.com
Thu Jun 2 13:29:17 MDT 2005

Today at 10:28am, David Boucha said:

> I have to do a lot of archiving of data and statistic gathering in an
> app I'm working on. This data needs to be updated in near real time
> and there are times I'd like to fork another process to take care of
> this database number crunching so the user doesn't have to wait for it
> to finish. I need to add a bunch of calculations, and I know it's
> going to make certain pages unbearably slow if the user has to wait
> for the number crunching.
> Has anyone used forking in a web app before? The php manual talks
> about pcntl_fork(), but in the notes it seems that you have to use it
> with php as a cgi. Is there another route I could take with this? A
> cron job running an update script isn't going to do it.

A site I spent a lot of time working on (www.emulab.net) has a lot of 
these all over in it. As long as you're on a linux/BSD server, you can 
even just call system("cmd &") and have it fork that way. The code for 
emulab.net is open source, and last I checked, you could download it from 
their site, if you want to see how they do it.


Mac Newbold		MNE - Mac Newbold Enterprises, LLC
mac at macnewbold.com	http://www.macnewbold.com/

More information about the UPHPU mailing list