Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Letting Apache know we're still alive

by pingo (Hermit)
on Aug 04, 2004 at 13:57 UTC ( #379992=perlquestion: print w/replies, xml ) Need Help??

pingo has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

I have a cgi script that does a very slow sql query, which causes a timeout. Is there any way for me to let Apache know that the script is still alive and hasn't died?

Oh, and no, I can't make the query faster (at least I don't think so) - I have used "explain", and from what I can tell MySQL seems to be using a sensible index.

Replies are listed 'Best First'.
Re: Letting Apache know we're still alive
by derby (Abbot) on Aug 04, 2004 at 14:15 UTC
    hmmm merlyn must be recuperating from OSCON ... he does have an article on that topic.
    -derby

      Good article. I had a queued request to look this up. I have an old CGI that worked for years using a timer to send activity characters back to the browser. I knew that might break with a new browser someday but the quick hack got me that initial mileage. Recently some Mac users complained that their browser doesn't get those status updates correctly and times out. merlyn's solution is the right one.

Re: Letting Apache know we're still alive
by hardburn (Abbot) on Aug 04, 2004 at 14:04 UTC

    I don't think Apache is a factor here, since it knows you're still alive because your process is alive. The problem likely is that the browser on the other end times out. There are ways to handle this, but it's hard to give specific advice without knowing more about your situation.

    Could you split the query into seperate chunks and send each bit to the browser? Could you fork off a process which will run the query while the parent sends data back to the browser?

    "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

      Hacking up the query would be very possible, actually. What it does is to select a field from one table and counting the number of rows in another table (using group by). I guess I could just select everything from the first table and then do multiple selects from the second one (sending bits back when they are ready).

      I think I'll have a go. Thanks for the idea!
Re: Letting Apache know we're still alive
by rbi (Monk) on Aug 04, 2004 at 14:00 UTC
    You can set proper values of KeepAlive and Timeout in the httpd.conf file of Apache, I guess.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://379992]
Approved by sweetblood
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2021-01-17 18:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?