[Mongrel] Offloading Background Tasks
hemant
gethemant at gmail.com
Sat Mar 1 21:17:43 EST 2008
On Sat, Mar 1, 2008 at 7:10 AM, Nathan Esquenazi <lists at ruby-forum.com> wrote:
> Hello everyone,
>
> I am very interested in off-loading tasks from the request/response
> cycle in order to speed up my application. My application is heavily
> connected to using web services both external and from other servers we
> host.
>
> My application does the following long-running tasks:
>
> - accesses / pushes to the twitter api's (with possible need for status
> responses)
> - accesses / pushes the facebook api's (with need for status responses)
> - requesting data from another server we run (rails needs access data)
> - pushes information to aim using ruburple
>
> I am just curious and grateful for any help people can give for what
> would suit me best. I am familar with backgroundrb and bj along with
> starling, etc. I don't know which one will suit me best based on the
> tasks I need to queue.
>
> My main concern is how to properly request data and then show it to the
> user. For instance, when the user logs into the rails application, I
> need to show them certain information about them which comes from
> complex analyzing of data done by another server we run.
>
> When a user logs in, I need to show them the current results of this
> analysis. To do this, I need to perform a GET request to another server
> and get the results and then show them to the user. What is the "best
> practice" way to achieve this in which I can offload this task to a
> background worker and then get the results and display them to the user.
>
> For instance, say the user logs in and then the background worker kicks
> off to retrieve their current analyzed data from the server. How do I
> then wait for the data to be retrieved by the worker and when it's ready
> display it to the user?
>
> I feel like I am missing something because I don't see how the worker
> can "tell" the main rails application that it now has the data and then
> somehow show it when its "ready". Do I need to constantly poll the
> server or how is this usually done.
>
> Also, I need to allow the user to make certain changes to data fields
> and then I need to push those changes to twitter and facebook via a
> background process.
>
> What solution is best suited based on what I described and could someone
> please help me understand the pattern for how to do this. I will be
> eternally grateful.
> --
For what you are describing, I think BackgrounDRb will be best fit.
Since, its the only solution ( that I know of ) provides interfacing
with rails so as you can actually fetch results retrieved by a worker
in rails.
Bj is a worker queue to offload tasks. AFAIK, you can't really
interact seamlessly from rails. I don't know much about startling. But
this is coming from guy who maintains bdrb to take it with a grain of
salt.
More information about the Mongrel-users
mailing list