This add-on is operated by Rails Autoscale
Simple, reliable queue-based autoscaling for your Rails app.
Last updated 14 June 2020
Table of Contents
Rails Autoscale is an add-on that automatically scales web and worker dynos for Rails applications.
Autoscaling ensures that your app can gracefully handle increased traffic while only paying for the dynos you need.
This documentation page is a high-level summary. See the official documentation site for more.
How is this different from Heroku’s own autoscaling?
Heroku offers a native autoscaling solution that’s worth a try if you run performance dynos and you only need to autoscale web dynos. Rails Autoscale goes beyond this by autoscaling based on request queue times, autoscaling worker dynos, and working with all dyno types. For more info, check out the common questions doc.
I’ll walk you through the full installation and setup process in the 5-minute video below. Additional instructions are in the getting started guide.
Check out Rails Autoscale on Heroku Elements for pricing and plans.
$ heroku addons:create rails-autoscale -----> Adding RAILS_AUTOSCALE_URL to sharp-mountain-4005... done, v18 (free)
After Rails Autoscale is provisioned, a
RAILS_AUTOSCALE_URL config var is available in the app configuration. You don’t have to do anything with it. This setting is used by the
rails_autoscale_agent gem when communicating with the Rails Autoscale service.
Rails Autoscale supports Rails 3.2+ and Ruby 1.9.3+.
Adjust your settings in the Rails Autoscale dashboard
After you install the gem and deploy your application, you’ll begin to see activity in your Rails Autoscale dashboard.
Access the dashboard via the CLI:
$ heroku addons:open rails-autoscale Opening RAILS_AUTOSCALE_URL for sharp-mountain-4005
You can also access the dashboard from your app’s Heroku Dashboard:
The Rails Autoscale dashboard documentation is here.
Request queue time threshold
Rails Autoscale triggers scale events by monitoring the request queue time for every request. This is the time between Heroku accepting a request and your application beginning processing. Queue time will increase when your application servers are too busy to handle all incoming requests.
For a thorough explanation of queue time, read Nate Berkopec’s excellent article “Scaling Ruby Apps to 1000 Requests per Minute - A Beginner’s Guide”.
Rails Autoscale tracks the 95th percentile queue time, which for most applications will hover well below the default threshold of 100ms. A breach of this threshold will trigger an UPSCALE for your application, adding one web dyno. After 10 minutes of measurements below the downscale threshold (50ms by default), a DOWNSCALE event is triggered.
Rails Autoscale’s queue time metrics will not match APM tools like Scout and New Relic. Those tools typically show an average, while Rails Autoscale tracks the 95th percentile.
Rails Autoscale provides default settings that work for most apps, but some apps may need a higher or lower threshold. These settings are described in detail in the official docs.
Rails Autoscale supports autoscaling worker dynos that are using Sidekiq, Resque, Delayed Job, or Que. It’s as easy as autoscaling your web dynos, and the settings page will walk you through the setup. See the launch announcment for a video walkthrough.
Migrating between plans
heroku addons:upgrade command to migrate to a new plan.
$ heroku addons:upgrade rails-autoscale:newplan -----> Upgrading rails-autoscale:newplan to sharp-mountain-4005... done, v18 ($49/mo) Your plan has been updated to: rails-autoscale:newplan
Removing the add-on
Rails Autoscale can be removed via the CLI.
This will destroy all associated data and cannot be undone!
$ heroku addons:destroy rails-autoscale -----> Removing rails-autoscale from sharp-mountain-4005... done, v20 (free)