Tag Archives: sidekiq

Scheduled Task with Sidekiq and Sidetiq

Sometimes, we need to do scheduled task for our Rails app, for example for caching, sending mass notification, etc. There are multiple solution available, one of them is by using Sidekiq and Sidetiq.

Sidekiq is a gem that enable us to do asynchronous works by creating background workers. What makes it better from other solution like Resque is Sidekiq uses multithreading so it is much more memory efficient than resque. For queuing, Sidekiq requires Redis, so make sure to setup it first.

Now, if you want to make recurring scheduled jobs, we can add Sidetiq on top of Sidekiq. With Sidetiq, you can easily define the interval of the schedule like daily, minutely, etc. Please use ruby > 2.0 when using Sidetiq, since it has a known memory issues when used with ruby 1.9.3 or lower.  You also need to use Redis > 2.6, so check your redis version out. It costs me half a day just to figure that out, hahah.

If you do everything correctly, Sidetiq can give you this beautiful UI:

sidetiq ui

The recurring jobs are only listed in production environment though. This is because in Rails development environment, eager loading is disabled by default.

Ok, hope that helps you in using Sidekiq and Sidetiq. Cheers!