title: Random timeout exceptions in Rails app on Heroku
body: <p>I host a Rails 3.2 app on Heroku and get 2-3 timeouts within the Rails application each day. These are <em>not</em> H12 request timeouts, but rather timeouts that occur somewhere within the Rails stack. Thus, they actually generate exceptions on the site and appear in my Airbrake logs.</p>
  
  <p>It seems to be completely random where the timeout occurs; sometimes it's within a gem like Formtastic, or within a HAML view, or within the ActiveRecord code. You can see examples of some of the backtraces here: <a href="https://gist.github.com/dpmccabe/5238273" rel="noreferrer">https://gist.github.com/dpmccabe/5238273</a></p>
  
  <p>This site doesn't get much traffic and runs well on two dynos (though they automatically scale up thanks to the Adept Scale add-on). The HTTP_X_HEROKU_QUEUE_WAIT_TIME header is usually low or zero, so I don't think it's a routing issue.  I even tried switching from Thin to Unicorn with no effect (my unicorn.rb is shown in the above gist).</p>
  
  <p>The fact that these timeout exceptions seem to occur randomly throughout the application doesn't give me much to go on. I do have New Relic, but I'm not sure how to go about debugging this. Any ideas?</p>