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

Setting up and running Puma on Heroku


Puma is a lightweight Ruby web server that was built for concurrency. It is a great alternative to Unicorn and works well on Heroku. Like Unicorn, Puma allows us to get more performance out of our dynos by responding to multiple requests simultaneously. It does this while maintaining a smaller memory footprint than Unicorn and has shown very impressive benchmarks when load tested.

The primary difference between Puma and Unicorn is that Puma will run multiple threads within a single process. This is an important distinction, because while processes have their own unique memory space, threads do not. This means our application's code must be thread safe.

The danger of code that is not thread safe is that separate web requests could be reading and writing from the same memory. This can cause errors or, worse, display data that was intended for another user.

How to do it…

To start, we'll need an existing Rails application running on Heroku. We'll modify it here...