Background Tasks & Rails – A Sidekiq Example

This post involves a little bit of everything–queuing (Sidekiq), JSON, API calls, redis, database manipulation. Enjoy!

The latest feature I am pushing to Dotawithme is listing the players by who is currently online. This is an oft requested feature (with good reason – DOTA players are impatient) but I wasn’t entirely sure what the best way to go about this was.

Of course I couldn’t just hammer Valve’s Steam API or I would quickly hit my daily limit. This means I need to create a background process to run at set intervals and update the database accordingly. There are many different gems to help your Rails app out with this and I settled on Sidekiq (‘Sidekick’) because it’s fast and (supposedly) simple to use.

Continue reading