I’ve got an app where it takes considerable time to process a list of
requests from a user, and so would like to use periodically_call_remote
to update a page showing how many requests have been processed. The
relevant page uses javascript to hide the user submission form and
replace with an animated “please wait” gif whilst the process runs, and
I’d also like it to display the count of requests processed. Here’s a
summary of the code:
def print_status
render :text => “#{session[:processed]} requests processed.”
end
session[:processed] is initially set to 0 but 1 is added to it
session.update run as each request is iterated over.
The result of this is that the page initially displays “0 requests
processed” in the correct place, but this text disappears after about 30
seconds. In another minute or so the browser times out and the “please
wait” message and spinner vanish as well.
Can anyone point out where I have got it wrong, above? Thanks.
I’ve got an app where it takes considerable time to process a list of
requests from a user, and so would like to use
periodically_call_remote
to update a page showing how many requests have been processed. The
relevant page uses javascript to hide the user submission form and
replace with an animated “please wait” gif whilst the process runs,
and
I’d also like it to display the count of requests processed. Here’s a
summary of the code:
How many mongrels are you running. if the answer is 1 (eg in
development) then that’s why. Rails won’t process more than 1
concurrent request per mongrel.
Long running actions
aren’t a good idea for that reason (offload to backgroundrb or similar)
It looks like backgroundrb is the answer then.
All that’s required is for the user to be notified when their data are
ready for collection and the site already does that by e-mail.
Thanks!
Rails won’t process more than 1
concurrent request per mongrel.
That’s it, then.
Is there any way of running multiple mongrels in development?
Thanks.
Same way as you would in production (mongrel cluster behind
something (eg apache) proxying to it).
That won’t solve your problem though: apache etc… will choose the
mongrel to proxy to round-robin style, so half of your requests will
be queued up behind this long running action. Long running actions
aren’t a good idea for that reason (offload to backgroundrb or similar)
Backgroundrb worked nicely for that particular problem, but now another
has cropped up.
One particular page allows the user to search through the database to
find and select some data that will be processed by the really long
query that backgroundrb deals with. The sequence goes as follows:
User starts the search, browser displays animated gif and says
“please wait.”
After two minutes the browser times out and displays a blank page.
After three minutes the mysql query finishes and is stored in the
mysql cache.
If the user tries the same query again the cached results appear in
seconds.
This is a bit of a nuisance. Does anyone have any suggestions for
dealing with this one?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.