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

Preface

As developers, we want to spend our time focusing on building our applications. We're not interested in setting up load balancers or endlessly tweaking firewalls. We just want to easily deploy and scale our code.

Heroku has made this possible by automating and hiding the dirty details of application deployment. This has resulted in a giant leap in developer productivity, making it easier to deploy code than it was earlier.

Even though Heroku has dramatically simplified the entire process, there is still a lot that we need to know before we launch a production-level application on Heroku.

The goal of this book is to teach developers how to use Heroku effectively. You'll learn exactly what it takes to deploy and support a production-level application on Heroku. Along the way, we will learn how Heroku works behind the scenes. The more we understand, the better we will be equipped to take decisions on how our applications should be designed and written.

What this book covers

Chapter 1, Getting Started with Heroku, will teach you how to set up all the tools we need to get our applications ready and deployed to Heroku.

Chapter 2, Managing Heroku from the Command Line, informs us that Heroku's CLI is the backbone of all our interactions with our Heroku application. Here, we'll get comfortable with administering our apps from the CLI.

Chapter 3, Setting Up a Staging Environment, specifies how to set up a staging environment for our Heroku applications. We need a place to test our application before deploying it to production.

Chapter 4, Production-ready with Heroku, covers the steps needed to get a Heroku application ready to handle production-level traffic.

Chapter 5, Error Monitoring and Logging Tools, specifies how to set up logging and alerts to keep us informed about any problems with our application. We can never have too much information about our application's usage and performance.

Chapter 6, Load Testing a Heroku Application, specifies how to simulate massive spikes of traffic and get insight into our application's performance bottlenecks. The first step to improving our application's performance is being able to measure it.

Chapter 7, Optimizing Ruby Server Performance on Heroku, specifies how to choose and configure our Ruby web server for maximum performance on a Heroku dyno.

Chapter 8, Optimizing a Rails Application on Heroku, tells us how to introduce caching and reduce load times throughout our Rails applications.

Chapter 9, Using and Administrating Heroku Postgres, specifies how to pick the right plan, administer it from the CLI, and keep it healthy with various Postgres health checks, as our database is the most critical piece of our application.

Chapter 10, The Heroku Platform API, specifies how to create, scale, and manage our applications, all through the API, thus preparing us to write our own programs to interact with Heroku for us.

What you need for this book

To complete the recipes in this book, you'll need an OS X and a Linux or Windows machine. Specific setup and installation instructions for all software and applications that are needed are detailed step by step in each chapter.

Who this book is for

This book is intended for developers who want to learn what it takes to deploy and manage production-level applications on Heroku. You might have already deployed applications to Heroku or might be entirely new to the platform. This book will get you up to speed quickly with all the information needed to run real-world web applications on Heroku. When using the recipes in this book, it will be helpful to have some prior experience in working with Git and command-line applications.

Sections

In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also). To give clear instructions on how to complete a recipe, we use these sections as follows:

Getting ready

This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.

How to do it…

This section contains the steps required to follow the recipe.

How it works…

This section usually consists of a detailed explanation of what happened in the previous section.

There's more…

This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.

See also

This section provides helpful links to other useful information for the recipe.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Make sure the log-runtime-metrics plugin is installed and the application was restarted."

A block of code is set as follows:

worker_processes Integer(ENV['WEB_CONCURRENCY'] || 2)
timeout Integer(ENV['WEB_TIMEOUT'] || 15)
listen ENV['PORT'], backlog: Integer(ENV['UNICORN_BACKLOG'] || 50)
preload_app true

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

worker_processes Integer(ENV['WEB_CONCURRENCY'] || 2)
timeout Integer(ENV['WEB_TIMEOUT'] || 15)
listen ENV['PORT'], backlog: Integer(ENV['UNICORN_BACKLOG'] || 50)
preload_app true

Any command-line input or output is written as follows:

# cp /usr/src/asterisk-addons/configs/cdr_mysql.conf.sample
     /etc/asterisk/cdr_mysql.conf

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "We will need to fill in our applications URL and then click on Load test execution plan."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the color images of this book

We also provide you a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/7944OT_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.