Runs your application across a preset number of virtual servers .

. Manages releases by rolling out your application to different environments.

by rolling out your application to different environments. Ensures your application automatically recovers from server failures.

from server failures. Handles load balancing across many application instances, allowing you to instantly scale your application to support millions of users.

across many application instances, allowing you to instantly scale your application to support millions of users. Allows you to quickly add and remove infrastructure blocks like caching servers and database servers.

Heroku supports the Ruby, Node.js, Python, Java, Go, PHP, and Scala programming languages. This provides easy deployment of existing technologies on Heroku with minimum modifications needed.

Building Blocks of Heroku

Dynos

Dynos, like AWS instances or Azure virtual machines, are individual virtual servers built on Ubuntu images. If your application runs on Ubuntu, it’ll be fine on Heroku. There are three types:

Web dynos : web instances running HTTP services.

: web instances running HTTP services. Worker dynos : instances launched to process asynchronous jobs.

: instances launched to process asynchronous jobs. One-off dynos: temporary instances that can be loaded with your latest code release and run detached, or with their input/output attached to your local terminal. They can be used to handle administrative tasks like database migrations.

As of now, you can choose from these dyno sizes:



Heroku is particularly well known for being able to instantly scale the number of dynos up or down, but they also provide automated load balancing for incoming HTTP requests and failover between hosts. You don’t even have to know there was a problem.

Add-ons



Heroku supports a very large collection of third-party add-ons for users to instantly provision as attachable resources for their applications. Provisioning an add-on (the Papertrail application logger, in this case) is no more complicated than running a single command from your command line interface (CLI):

heroku addons:create papertrail Each time you add an add-on to one of your applications, your application will automatically be assigned one or more environment variables, which specify any credentials you may need to interact with your new tool. In the case of Papertrail, you will have full access to your logs through the Heroku apps web interface.

Heroku database service



Heroku PostgreSQL, Heroku’s hosted, vertically scalable, database service that’s available in the cloud or on your local workstation, is similarly provisioned using:

heroku addons:create heroku-postgresql But of course, being a database, the Heroku PostgreSQL is significantly more complicated to configure.

Heroku also offers High Availability and Automatic Failover with its DB.

Heroku architectural principles

Based on Heroku founder Adam Wiggen’s Twelve Factor App, you should ideally keep these considerations in mind when designing your Heroku deployments (or, for that matter, any deployments):

Version control and store your application in Git.

Declare and isolate dependencies.

Store your application configuration profile data in environment variables.

Design infrastructure elements to work as attachable modular resources.

Separate your build and run stages.

Design your application to be stateless so it can be easily reused.

Export services via port bindings

Scale-out your application using concurrency

Keep your development, staging, and production images as similar as possible.

Think of your logs as event streams.

Run admin processes as one-off tasks.

How Heroku Pricing Works



One of the benefits of using a cloud provider like Heroku in the first place is that you pay only for what you use. In the case of Heroku, since they bill in increments of seconds, that’s pretty much exactly what you use.

Quick-start Demo

Create your own free Heroku account. You will get 512 MB RAM, 1 web/1 worker, which is enough to get started deploying prototype applications.

We’ll work with a Rails application. Refer to this link for help setting up Rails on your workstation.

Download and install the Heroku ToolKit. This will create a local Heroku CLI client for creating and managing your Heroku applications and Git.

Login using the email and password you used for your Heroku account:

Clone your application from git:

Now create an application on Heroku that will receive your Git source code:

Once complete, push your code:

git push "heroku master"

Each Heroku application is assigned a unique URL that automatically routes incoming HTTP requests to your application. Get your application using:

heroku open