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

Viewing and stopping database processes


One option to diagnose database performance issues is by looking at the database's currently running processes. This will give us insight into exactly what is taking up resources and potentially causing problems. In this recipe, you will be learning how to use the Heroku CLI to view and stop processes running on your database.

How to do it…

To begin, let's open up a terminal; we'll be using the Heroku CLI in this recipe:

  1. To view the currently running processes on our database, we can use the pg:ps command. We'll see an output of what is currently running. Each process has its own unique ID (PID, or process ID):

    $ heroku pg:ps
    pid |  state |      source    | running_for |
    ----+--------+----------------+--------------
    343 | active | /app/bin/rails | 00:04:23.0286
    

    Note

    This example has been condensed for readability.

  2. In this example, we have a query that has been running for over 4 minutes. We can stop this query with the pg:kill command. We use the pid found...