Heroku Dyno on Steroids

Rails Development

For my last day project, Collegememes, I needed cron and delayed_job functionality. Basically, my app, which can be found on Github by the way, fetches the memes from their respective Facebook groups' walls and feed them to the database. Since I didn't wanted to pay money for an extra worker or cron functionality to keep the memes up-to-date, I initially just thought of using either cron.io or just manually updating the database via HTTP-authenticated GET requests (/admin/update). However, I remember reading about introducing more concurrency to a Heroku dyno here, and I ended up doing the following:

Using the Unicorn gem, it not only allows me to spawn more than one web worker per dyno, but also spawn a job worker and clockwork worker, as specified in this config file:

Now that I look at it, I could probably get away without the job worker, which was necessary for the manual updates.

The clockwork gem takes care of the cron functionality:

Voila, with just two small changes, we mutated a single worker Heroku Dyno to a complex web application with cron and delayed_job functionality.

comments powered by Disqus