RE: Forking another process in Apache?
Chris Hutchinson writes: > Avoids much work in httpd, and allows user to hang up web connection and > return later to continue viewing status. We used to do this, but found it more complex (more protocols and server types) than simply letting Apache/mod_perl handle the job. I guess this depends on the frequency of long requests, but in our case the mix is handle nicely with a single common server using http as the only protocol. The idea is that all the work is handled by the middle tier. This includes processing incoming mail messages, long running jobs, and credit card processing. There's a lot of common code between all these tasks, so memory is shared efficiently. One trick for long running jobs started by an http request is to reply to the user as normal and do the long part in a PerlCleanupHandler. This avoids a fork of a large process, which keeps the memory usage relatively constant. This simplifies resource allocation. Just another way to do it. Rob
RE: Forking another process in Apache?
We've had a fair amount of success handing long processing jobs off to daemons (written with Net:Daemon, in most cases passing across args using Net::Telnet), using pages with reloading redirects to check the daemon status in a table. Avoids much work in httpd, and allows user to hang up web connection and return later to continue viewing status. - Chris > -Original Message- > From: Mike P. Mikhailov [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, 22 January 2002 6:04 PM > To: eCap > Cc: [EMAIL PROTECTED] > Subject: Re: Forking another process in Apache? > > > Hello eCap, > > Monday, January 21, 2002, 10:45:37 PM, you wrote: > > e> A newbie question here... > e> I have a requirement to spin off a SQL loader process after a > web page (a > e> form which is qualified and accepted) has been submitted. Does it make > e> sense, or more importantly, is it dangerous to apply a "fork" > at the end of > e> a module such as this: > > > e> sub handler { > e> # do some qualification stuff here and accept the form submission... > e> if ($pid = fork) { > e> # parent > e> # ...whatever i need to accomplish to deliver return html code > e> return OK > e> } elsif { > e> # child > e> exec($sql_loader); > e> } else { > e> # ...whatever i ned to do to recover errors > e> return DECLINED > e> } > > e> } > > e> Are there any dangers in doing something like this? Or is there a more > e> efficient way to accomplish the same thing? > > e> Thanks for the advice, > e> Kirk > > > I'm recently implement exactly such loader. From the client HTTP > request I'm starting loader with double fork approach. I'm loading > posssible large enough (about 100 - 150 MB) data from DBF flat files > into Oracle in single transaction (I'm must provide consistency). > Loader process takes about 40-50 min to complete and consumes many > resources (CPU and RAM). But it works ! > > -- > WBR, Mike P. Mikhailov > mailto:[EMAIL PROTECTED] > > Pessimests are right more often, but optimists are happy more often > >
Re: Forking another process in Apache?
Hello eCap, Monday, January 21, 2002, 10:45:37 PM, you wrote: e> A newbie question here... e> I have a requirement to spin off a SQL loader process after a web page (a e> form which is qualified and accepted) has been submitted. Does it make e> sense, or more importantly, is it dangerous to apply a "fork" at the end of e> a module such as this: e> sub handler { e> # do some qualification stuff here and accept the form submission... e> if ($pid = fork) { e> # parent e> # ...whatever i need to accomplish to deliver return html code e> return OK e> } elsif { e> # child e> exec($sql_loader); e> } else { e> # ...whatever i ned to do to recover errors e> return DECLINED e> } e> } e> Are there any dangers in doing something like this? Or is there a more e> efficient way to accomplish the same thing? e> Thanks for the advice, e> Kirk I'm recently implement exactly such loader. From the client HTTP request I'm starting loader with double fork approach. I'm loading posssible large enough (about 100 - 150 MB) data from DBF flat files into Oracle in single transaction (I'm must provide consistency). Loader process takes about 40-50 min to complete and consumes many resources (CPU and RAM). But it works ! -- WBR, Mike P. Mikhailov mailto:[EMAIL PROTECTED] Pessimests are right more often, but optimists are happy more often
Re: Forking another process in Apache?
> I have a requirement to spin off a SQL loader process after a web page (a > form which is qualified and accepted) has been submitted. Does it make > sense, or more importantly, is it dangerous to apply a "fork" at the end of > a module such as this: You're probably better off using a cleanup handler to do this after disconnecting form the client. See the guide for more details: http://perl.apache.org/guide/performance.html#Forking_and_Executing_Subp rocess - Perrin
Forking another process in Apache?
A newbie question here... I have a requirement to spin off a SQL loader process after a web page (a form which is qualified and accepted) has been submitted. Does it make sense, or more importantly, is it dangerous to apply a "fork" at the end of a module such as this: sub handler { # do some qualification stuff here and accept the form submission... if ($pid = fork) { # parent # ...whatever i need to accomplish to deliver return html code return OK } elsif { # child exec($sql_loader); } else { # ...whatever i ned to do to recover errors return DECLINED } } Are there any dangers in doing something like this? Or is there a more efficient way to accomplish the same thing? Thanks for the advice, Kirk