Book Image

Heroku Cookbook

By : Mike Coutermarsh
Book Image

Heroku Cookbook

By: Mike Coutermarsh

Overview of this book

Heroku is a Platform as a Service that enables developers to rapidly deploy and scale their web applications. Heroku is designed for developer happiness, freeing developers from doing system administrative tasks such as configuring servers and setting up load balancers. Developers are able to focus on what they do best, building web applications, while leaving the details of deployment and scaling to the experts at Heroku. This practical guide is packed with step-by-step solutions to problems faced by every production-level web application hosted on Heroku. You'll quickly get comfortable with managing your Heroku applications from the command line and then learn everything you need to know to deploy and administer production-level web applications.
Table of Contents (17 chapters)
Heroku Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Tuning Unicorn's backlog for Heroku


A single dyno that runs Unicorn can serve as many concurrent requests as it has Unicorn workers available. A dyno that runs four Unicorn workers can serve a maximum of four requests at a time. If our dyno receives more than four concurrent requests, it will add the extra requests to a queue and process them once a worker is available.

This can be problematic on Heroku due to how Heroku routes requests to dynos. Heroku's router sends requests randomly to any dyno that does not have a full backlog. Ideally, we'd like Heroku to route requests to the dyno that is most capable of serving the request quickly. The default setting for Unicorn's backlog is 1024 requests. This means that a Unicorn dyno can have a queue of 1,024 requests before Heroku will stop sending requests to it.

In this recipe, we will learn how to reduce our Unicorn backlog to keep requests from piling up on a single dyno and have Heroku reroute our requests to a dyno with available capacity...