Skip to main content

Peek Under the Hood of Heroku

Learning Objectives

After completing this unit, you'll be able to:

  • Explain what a dyno is.
  • Distinguish between languages, buildpacks, and slugs.
  • Describe how add-ons are useful, and name one that you can provision from the Heroku Elements Marketplace.
  • Identify a Heroku CLI command.

Heroku Under the Hood

So far we've discussed Heroku at a high level: what it is and when you'd want to use it. You also learned about different deployment methods. But what exactly is Heroku? What's under the hood? Let's look!

Dynos

Your application's code runs on the Heroku Platform inside of structures that we call dynos. Heroku's dynos are just managed runtime containers with a Linux operating system underneath. These containers run the processes that allow your custom application code to run.

Runtime Containers??

Don't be intimidated by the terminology! Containerization is just a mechanism for keeping running processes isolated from one another. Think of it like this: Containers keep the strawberry jam from mingling with the mustard in your refrigerator so that your breakfast toast always tastes right. Runtime containers are the same thing, except they keep your code and configuration from touching any others. That way your app always tastes just how it should.

Containers also provide separation between two or more dynos running identical instances of your app, accepting client requests, and serving up responses. Even though one request might be served by Dyno A and another by Dyno B, your users won't know the difference. All they see is your application giving them quick responses. When you scale up your app to run on several dynos (or even dozens or hundreds), you've got extra peace of mind. If something goes wrong with your app code on one dyno, all the others can continue serving your customers.

Slugs & Buildpacks

Slugs are compressed and pre-packaged copies of your application optimized for distribution to the dyno manager. When you push code to Heroku, your code is received by the slug compiler which transforms it into a slug. At the heart of the slug compiler is a collection of scripts called a buildpack that handle different languages. All applications written in Ruby, Python, Java, Clojure, Node.js, Scala, Go and PHP are implemented and compiled using buildpacks. Scaling an application then downloads and expands the slug to a dyno for execution.

Custom buildpacks can be used to support languages or frameworks that are not covered by Heroku’s officially supported buildpacks.

Application Traffic Control: The Heroku Router

The Heroku router is the key to all this multi-dyno magic. Whenever a new web dyno starts up, it registers itself with the router, letting it know which application the dyno is running. After a dyno is registered, the Heroku router begins distributing incoming requests across all the available dynos for an application, the app's "dyno formation" — that's what we call the size and number of dynos running your app (for example, a formation of seven Performance-L dynos).

Do you find the Heroku router as fascinating as we do? To read more about how it works and what you can expect from it, check out the Heroku Dev Center documentation on routing.

Add-ons

Add-ons are another essential piece of the Heroku platform. These elements give you the ability to add complex functionality to your application without having to manage the underlying software or infrastructure.

A great example of a useful add-on is the Heroku Postgres database. Postgres is an enterprise-class database that's fast, reliable, and has a ton of capabilities. Best of all, when you provision a Postgres database as an add-on, the underlying infrastructure is completely managed by Heroku.

In addition to several Heroku-managed add-ons, third parties offer dozens of add-ons — data stores, email servers, monitoring tools, and just about anything else you can imagine. Developers can plug in back-end functionality, like the ability to send email or texts, with as little as one click. Many have free options that you can try and use as long as you like.

Check out the Add-ons page of the Heroku Elements Marketplace to explore all the add-ons you can incorporate into your Heroku Enterprise apps.

Condividi il tuo feedback su Trailhead dalla Guida di Salesforce.

Conoscere la tua esperienza su Trailhead è importante per noi. Ora puoi accedere al modulo per l'invio di feedback in qualsiasi momento dal sito della Guida di Salesforce.

Scopri di più Continua a condividere il tuo feedback