Skip to content
iwhurtafly edited this page Jan 11, 2013 · 1 revision
This article only applies to apps on the [Bamboo](bamboo) stack. The most recent stack is [Cedar](cedar).
The backlog is the number of requests waiting to be processed. If you're using the default (one [dyno](dynos)), your application can only process one request at a time on the [Bamboo](bamboo) stack. This should be more than enough for a few simultaneous users; for example, if your app takes 100ms to serve a request, a single dyno can serve 10 requests per second.

However, imagine the case where you're getting 15 requests per second. Your single dyno can serve 10 per second (1000ms in a second / 100ms per request = 10 reqs/sec). After one second, you will have served 10 requests - but there will be 5 more in the backlog, waiting to be processed. This would be fine if no more requests came in, as those 5 requests would be served in the next half-second. However, if you have another 15 requests come in, at the end of the 2nd second you'll have 5 + 15 - 10 = 10 requests in your backlog. After 3 seconds, the backlog will be 15 deep, and so on.

If that volume keeps up, the backlog will just keep getting deeper. Eventually, the Heroku routing mesh will detect that you're increasingly behind, and will start turning away some of the requests. Refused requests will get the H11 (Backlog too deep) error message.

When you get this error, you have three options:

  1. Increase the number of dynos you have. You can calculate how many you need by taking your average time spent serving a request (100ms in the example above) and multiplying it by how many requests you wish to serve per second. 15 requests per second at 100ms per request would require two dynos. 30 requests per second would require 3 dynos, although you might to go with 4 or even 5 to give yourself a little headroom, since traffic often comes in spikes.
  2. Speed up your response time. A performance analysis tool like New Relic is invaluable here. If you're spending more than 100ms in your dyno processing the request, you probably have room for optimization.
  3. Ignore the problem, if you would prefer not to pay for additional dynos or take the time to optimize your code.
Clone this wiki locally