Skip to content

Instantly share code, notes, and snippets.

@nz
Last active December 13, 2015 19:48
Show Gist options
  • Save nz/4965299 to your computer and use it in GitHub Desktop.
Save nz/4965299 to your computer and use it in GitHub Desktop.

Fixing Heroku's random queuing router

So Heroku routes their requests to your dynos randomly. While you're enhancing your middleware to log that dyno-level queue time, I have an optimization for you that should help fix the issue outright!

Rails 3 apps, or 2.3 with Bundler, and Ruby 1.9

Gemfile

gem 'rack-timeout'

config/initializer/queue-fix.rb

Rack::Timeout.timeout = 0.5

Rails 3 apps, or 2.3 with Bundler, and Ruby 1.8

Gemfile

gem 'SystemTimer', :require => 'system_timer', :platforms => :ruby_18
gem 'rack-timeout'

config/initializers/queue-fix.rb

Rack::Timeout.timeout = 0.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment