Hi guys, Could you recommend a common design for the following case (or point me in the right direction): - the user makes a request - the server processes is it, but the process is long therefore it is split into "chunks". - the page is rendered with the first chunk - when another chunk is ready, it is pushed to the client (say at the bottom of the page or something). I guess a solution could be: - do the process in the background, store the chunks in a DB (marked using session) - get periodic AJAX calls from the client to check whether there is "something new available" in the DB - if there is, push to the client. But it seems a bit heavy (and could potentially be thread unsafe?) to me. Besides, it would be better to push the chunks as soon as they are ready rather than waiting for periodic calls. Is there a preferred way to do that? Thanks a lot, Peter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Peter De Berdt
2010-Feb-16 10:00 UTC
Re: How to deal with user requests that take time to process?
On 15 Feb 2010, at 20:48, PierreW wrote:> Could you recommend a common design for the following case (or point > me in the right direction): > > - the user makes a request > - the server processes is it, but the process is long therefore it is > split into "chunks". > - the page is rendered with the first chunk > - when another chunk is ready, it is pushed to the client (say at the > bottom of the page or something). > > I guess a solution could be: > - do the process in the background, store the chunks in a DB (marked > using session) > - get periodic AJAX calls from the client to check whether there is > "something new available" in the DB > - if there is, push to the client. > > But it seems a bit heavy (and could potentially be thread unsafe?) to > me. Besides, it would be better to push the chunks as soon as they are > ready rather than waiting for periodic calls. > > Is there a preferred way to do that?Juggernaut (Flash based pushing) or Comet (persistent HTTP connection pushing). Doubt there''s a lot of prechewed code for either of them out there though. Polling isn''t really that bad in this case imo. When there is no chunk, your app will just return a status, when there is, it returns data. That''s less actual data than Campfire has to deal with and they are using polling. Best regards Peter De Berdt -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.