Hugs
Hugs

Reputation: 935

Background process in Rails 3

I am writing a Web app that will need to run a background process that will poll a web service every minute or so and then query my Rails db and send out alerts to users of the app via Twitter. I have researched this a lot but I feel I am just going around in circles. I have come across delayed_job, background_job and a few other options like creating a custom daemon suggested in a Railscast. Does anyone have any suggestions for the best way to do this? The process will have to run constantly in the background and won't be triggered by an event in the front end. Any help or guidance would be appreciated.

Upvotes: 2

Views: 1350

Answers (5)

nkm
nkm

Reputation: 5914

We can either use backgroundrb or unix crontab.

Crontab will do the job if you don't want to send any heavy loaded process to run asynchronously during the request process cycle of the application.

Backgroundrb consumes lot of memory and cpu in production environment if any of the process hangs out. Also we need to configure a monitor tool to make sure that the background process is running.

Upvotes: 0

maniempire
maniempire

Reputation: 801

I used delayed_job for our application.

While working on this, we researched many sites and finally we are able to apply it.

We apply our experiences in the following link

http://www.kyybaventures.com/blog/rails-delayed-job#more-2916

Hope this will help to get started with background process in rails 3.

Upvotes: 0

Maurício Linhares
Maurício Linhares

Reputation: 40333

Why don't you just create a rake task and add it to your CRON execution?

You can even use Whenever to configure this for you.

Upvotes: 1

Johny
Johny

Reputation: 1441

You can simply use cron for tasks that has to be executed every X minutes, hours etc.

gem whenever is usefull to setup this with rails: https://github.com/javan/whenever

I don't know much about delayed_job. But you can check out some tutorials, for example this article on heroku: http://devcenter.heroku.com/articles/delayed-job

Upvotes: 0

pdu
pdu

Reputation: 10423

I used Beanstalkd for this and can recommend it.

http://railscasts.com/episodes/243-beanstalkd-and-stalker

Upvotes: 0

Related Questions