Ruby On Rails: Cron Job Scheduling using Redis, Resque, and Rufus
The 5 R: Ruby on Rails, Redis, Resque, Rufus.
Now the question is what’s the best way to run scheduled tasks in a Rails environment? Generally, Rails developers can use an application specific crontab to run application tasks. […] Downsides of Cron are:
- Cron works well on a single server but what if you need to scale to multiple app servers? You’ll need to introduce some kind of lock to avoid concurrency problems. Also, you need to maintain these shared locks.
- The other problem with Cron is that they are difficult to debug.
- Cron is for scheduling things, not doing them.
This can almost always be better to place jobs in queue and place the worker system to perform or to execute those jobs. Luckily there is a very good gem named ‘resque‘ available in Ruby on Rails.
Original title and link: Ruby On Rails: Cron Job Scheduling using Redis, Resque, and Rufus (NoSQL databases © myNoSQL)
via: http://hemju.com/2011/03/04/rails-cron-job-scheduling-using-redis-resque-and-rufus/