views:

69

answers:

3

Hey guys, I have a program that uses ajax to send a post to multiple social networks via their APIs based on user form input. I was wondering if this process (which doesn't take more than 2-3 seconds when I test it myself) is worth daemonizing with something like BackgroundRB? In other words, were this program to become used by 100+ people, would the simple call to an action via AJAX slow the entire application down?

+2  A: 

Yeah I'd recommend using DelayedJob to accomplish this task. You want to avoid unnecessary HTTP requests to your app. With DelayedJob, it connects to your database and makes third party connections without initiating any HTTP requests to your app.

I wouldn't recommend BackgroundRB.

bensie
Alright, however, I need to be able to tell the user if an error occurred while sending the posts. The direct way lets me send an immediate response back and I can use a periodical AJAX call to check a BackgroundRB job's status. Is there something similar to check on the status of a delayed_job?
hmind
+1 for DelayedJob. One of my favourite additions to my Ruby on Rails toolset.
Mike Trpcic
You should always write your delayed job code so the job itself can't fail. Whether you rescue from a particular error or whatever, the job should finish so it doesn't try again. In your case I would update a DB column saying that sending updates to a particular social network failed.
bensie
+1  A: 

Sort answer: you have to go into background, use delayed_job

Longer answer:

The problem is that although it takes only 2-3 seconds, it completely locks the application server while it does it. so if you have lets say 5 mongrels, or passenger app servers running, it means that if 5 people decide to do this action within 2-3 seconds interval no other requests will be able to be processed.

So while its ok to do it during the development it's a must to move it to background in production.

I wouldn't recommend BackgroundRB. For what you need it seems you need delayed_job

Vitaly Kushner
A: 

You have a lot of solution to made that

  • bj
  • delayed_job
  • resque
shingara