Best Ruby on Rails Add-ons for Heroku Hosting
After 8 years of working, I have my own favorite set of Heroku add-ons that work great with Rails apps. Learn about add-ons that can come in handy in your daily Ruby developer life.
Join the DZone community and get the full member experience.Join For Free
After working for over 8 years with Heroku and Ruby on Rails projects I have my own favorite set of Heroku add-ons that work great with Rails apps. You are about to learn about the add-ons that come in handy in your daily Ruby developer life.
Here it is, a list of my favorite Heroku add-ons from Heroku Marketplace and why I choose them for my Ruby on Rails projects hosted on Heroku.
Heroku Scheduler can run scheduled tasks every 10 minutes, every hour, or every day. I use it to run my scheduled rake tasks. For instance every day I run a rake task that will send a summary of users who signed up in the last 24 hours to my mailbox.
Heroku Scheduler add-on is free. The only limitation is that it has fewer options than the cron in the Unix system. If you need to run a rake task every Monday then you need to set up a rake task as a daily task in Heroku Scheduler and do a check of the day in the rake task itself to skip it when needed.
New Relic APM
New Relic add-on does application performance monitoring. It’s one of my favorite add-ons. It allows to track each process like puma/unicorn/sidekiq per dyno and its performance. You can see which Rails controller actions take the most time. You can see your API endpoints with the highest throughput and those which are time-consuming. New Relic helped me many times to debug bottlenecks in my app and thanks to that I was able to make Knapsack Pro API with an average 50ms response time. Who said the Rails app has to be slow? :)
Rollbar allows for exception tracking in your Ruby code and also in JS code on the front end side. It has a generous free plan with a 5000 exception limit per month.
You can easily ignore some common Rails exceptions to stay within the free plan limit.
Logentries collects your logs from Heroku standard output so that you can browse them later on. If you need to find info about an issue that happened a few days ago in your logs then Logentries might be helpful.
Of course, you could use Heroku Command Line Interface and run the
heroku logs -n 10000 --app my-heroku-app command in the terminal to browse logs for the last 10,000 lines but this method has limitations. You can’t go that much in past logs or easily filter logs as in Logentries.
Logentries has a 5 GB and 7 days retention period in a free plan. This is enough for small Rails apps.
A nice feature I like in Logentries is an option to save the query and later on quickly browse logs by it. You can also display charts based on logs. Maybe you want to see how often a particular worker in Sidekiq has been called? You could visualize it.
If you use Redis in your Ruby on Rails app then Redis Cloud is your add-on. It has a free plan and paid plans are more affordable than other add-ons have.
Redis Cloud add-on does automatic backups of your data and offers a nice web UI to preview the live Redis usage and historical usage of your database instance.
I like to use Redis Cloud + sidekiq gem in my Rails apps. Also, Redis is useful if you need to cache some data quickly in the memory and expire it after some time.
SendGrid is a free add-on that allows you to start sending emails from your Ruby on Rails. You can even connect your domain to it so your users get emails from your domain.
There are free 12,000 emails per month in the free plan.
Heroku Add-ons to Save You Time and Money
Here are a few of my favorite add-ons that will help you save money and time in your project.
AutoIdle lets you save money by automatically putting your staging and review apps to sleep on Heroku. I use it to turn off my web and worker dyno for the staging app when there is no traffic to the app. No more paying for Heroku resources during the night and weekends. ;)
Rails Autoscale is a powerful add-on that will help you save money on Heroku. It will measure requests queue time and based on that add or remove dynos for your web processes. If you have higher traffic during the day it will add more dynos. During the night when the traffic is low, it will remove dynos.
Rails Autoscale can also track your worker queue. For instance, if you have a lot of jobs scheduled in Sidekiq then Rails Autoscale will add more worker dynos to process your job queue faster. It can even shut down worker dyno when there are no jobs to be processed which can save you even more money.
Knapsack Pro is a Heroku add-on and Ruby gem that can run your Rails tests in RSpec, Cucumber, Minitest, etc, and automatically split the tests between parallel machines on any CI server. It works with Heroku CI, CircleCI, Buildkite, Travis CI, etc. It will help you save time by doing a dynamic split of tests with Queue Mode to ensure all parallel jobs finish work at a similar time. This way you optimize your CI build runs and save the most time.
Below you can see an example of the optimal distribution of tests, where each parallel CI machine performs tests for 10 minutes, thanks to which the entire CI build lasts only 10 minutes instead of 40 if you would run tests on a single CI server only.
I’ve been working on the Knapsack Pro add-on and I’d love to hear your feedback if you give it a try.
Published at DZone with permission of Artur Trzop. See the original article here.
Opinions expressed by DZone contributors are their own.