Difference between Background DRb and AJAX


#1

Hi,

I need a user to initiate a long running task … say five minutes. And
I want the user to wait for a response before doing anything else.

The way I see it, using a straight HTTP POST is gonna time out.

So, I could start up a new thread using Backgroundrb (after an AJAX form
post), and use AJAX to ping the server every second to look at the
progress.

Or, I could just use an AJAX form post, and using AJAX poll the server
every second to see what’s up.

The way I see it, an AJAX call doesn’t time out the same way a normal
HTTP call could times out on the browser.

Therefore … is there any need to complicate things by using
backgroundrb in this scenario?

Or am I missing some major advantage using backgroundrb, or some major
disadvantage using a regular AJAX call?

Thanks
Joerg


#2

On 04 Apr 2007, at 17:29, Joerg D. wrote:

Therefore … is there any need to complicate things by using
backgroundrb in this scenario?

Or am I missing some major advantage using backgroundrb, or some major
disadvantage using a regular AJAX call?

Backgroundrb will release the thread, while a normal AJAX request
where you wait for a response will block one of your server
connections. This will be the best way to go btw, as your subsequent
AJAX calls will only take a few fractions of a second to query the
Backgroundrb process, then release the thread for other users.

To illustrate: suppose you’re running a mongrel cluster of 5 mongrels
and you have 5 people making such a long running task at the same
time, all mongrels will be in use and no one will be able to connect
to your site anymore if you use a normal AJAX request which waits for
a server response.

Best regards

Peter De Berdt


#3

Ah right. Yes - now I see the advantage of using backgroundrb …
Thanks!

Peter De Berdt wrote:

To illustrate: suppose you’re running a mongrel cluster of 5 mongrels
and you have 5 people making such a long running task at the same
time, all mongrels will be in use and no one will be able to connect
to your site anymore if you use a normal AJAX request which waits for
a server response.