When it comes to doing some asynchronous work, Ruby on Rails community have some great ready to use solutions to choose from. I think most popular is delayed_job and resque (and probably sidekiq, but a story for another blog post).

Delayed Job is great for small apps, it’s work out-of-the-box with ActiveRecord, you can also plug it into mongoid and it’s probably your first choice if you don’t want to setup redis. But when your traffic gets higher and higher, and you have to do more background jobs it’s becoming clear it’s not the perfect solution - the database-lock mechanism just don’t play very well with high amount of tasks.

Migrating to resque shouldn’t be a big problem (well, I guess it’s vary greatly, depending of you app specifics), I will provide here some quick tips, as usual:

{% codeblock config/routes.rb %} mount Resque::Server, :at => “/resque” {% endcodeblock %}

You will probably want to protect it with some kind of password using initializer:

{% codeblock config/initializers/resque.rb %} unless Rails.env.development? Resque::Server.use Rack::Auth::Basic do |user, password| user == ‘login’ && password == ‘password’ end end {% endcodeblock %}

And one final note - resque 2.0 is currently heavy development, you you might want to stick to 1-x-stable branch.