A pile up of long running requests is a sure way to bring our entire application to a screaming halt. When a web request to a Heroku application takes longer than 30 seconds to respond, Heroku will terminate the request and return an H12 error to the user. The problem with this is that this does not actually stop the request from being processed by our dynos. Even though the user will never receive a response, our dynos will keep working on the request until it is complete. This is an obvious waste of resources, but we can easily avoid this by adding Rack::Timeout to our applications.
To set up Rack::Timeout, we'll need to add a gem to our Gemfile and an initializer to our Rails app. Let's fire up a terminal and navigate to our blogger-app
directory by performing the following steps:
We can start by adding
rack-timeout
to our Gemfile:gem 'rack-timeout'
Then, install the gem by running
bundle install
:$ bundle install
Now, we'll need to...