// Heroku

Competitors: Appfog and Dotcloud

Reasons why people use Heroku:

1. Free-tier usage: Heroku is also great for beginners since its free tier of 
   service covers everything newbies need. You can deploy as many apps as you 
   like on Heroku, so long as they’re not too large (in terms of the associated 
   data you’re hosting) and you don’t mind the possibility that Heroku might 
   randomly take them offline for what it calls “unscheduled downtime.”

2. Scale: What if your modest app suddenly goes viral? Heroku will automatically 
   devote extra servers to keep it from crumbling under the pressure. When Chris 
   Whong, a civic hacker, suddenly saw his data visualization app of New York 
   taxi drivers make the front page of Hacker News, Heroku adjusted it to 
   support a flood of new users.

How Heroku Works:

When you create an app on Heroku, it deploys to the Cedar Stack, an online 
runtime environment that supports apps built in Java, Node.js, Scala, Clojure, 
Python and PHP—all the programming languages that Heroku supports.

The current version of the Cedar Stack is Celadon Cedar. It supports hundreds of 
thousands of developer apps. When you deploy a new app, Heroku assigns it a 
unique name based on a natural theme, like “calm-springs3345” or 

Think of Heroku as home to a vast array of virtual computers, or “instances,” 
that can be powered up and down. Heroku calls these instances dynos; these are 
lightweight containers that each run a single command for your app.

It turns out that a lot of apps require the same actions. Heroku keeps 
developers from reinventing the wheel with the Addon Store, which provides 
actions you can assign to dynos for free or, sometimes, a fee. I am using a free 
addon called Heroku Scheduler, which prompts my apps to become active once every 

To create your Heroku account, all you need is an email and password. But if you 
want to do anything with your Heroku-hosted app, like take advantage of one of 
the many useful free addons, you need to put in a credit card number. Heroku 
says it’s for account verification. Though it obviously makes it easier for 
Heroku to tempt you with paid services as well.

If all you want to do with your Heroku account is test other people’s apps using 
the GitHub one-click-deploy button, you can stop here. But if you want to deploy 
your own apps from your desktop, you’ll also want to install the Heroku Toolbelt.

Heroku Toolbelt is a resource that bundles three tools: Heroku client, a command 
line interface tool for creating and managing Heroku apps; Foreman, which lets 
you run your apps locally; and Git, which we already know allows you to push 
apps to the Heroku stack.

With Heroku Toolbelt, you can easily create, manage, test, and deploy apps from 
your PC.

git init
heroku create projectName

The above commands assign us a Heroku URL and a Git repository.  It initializes 
the heroku remote repository in git for us.

// Heroku - Buildpacks:

Heroku projects are managed by "buildpacks", which are in essence instructions 
for fetching dependencies, building and running your project. There are 
officially supported buildpacks for Node.js, Ruby, Java, Clojure, Scala, PHP, 
Python, and Go. We won’t need to tell Heroku what we are using.  Heroku will 
guess what the project is, based on some conventions and heuristics regarding 
dependency management. For example, a requirements.txt file in your project 
directory, as exists in the example project above, indicates a Python project. 
Here are the dependency files that Heroku will use to automatically detect your 
platform for other platforms:

Node.js: package.json
Ruby: Gemfile
PHP: composer.json
Java: pom.xml
Scala: build.properties
Clojure: project.clj
Go: Godeps/Godeps.json

If we are using a different language, or using a different build tool for one 
of these languages, you can also use a third-party buildpack. Heroku maintains 
an extensive directory of these, so check there before giving up on your 
preferred language. You can set the buildpack using the git repository URL.  
For example, to use Upworthy’s Clojure Boot buildpack, you could run this 
command in your project directory:

heroku buildpacks:set https://github.com/upworthy/heroku-buildpack-boot

// Heroku - Procfile:

Heroku uses a file called Procfile to tell it what it should be running. For our 
getting started project, we'll probably just want to specify a web process, but 
we can also specify worker jobs.  Since we run our app with python app.py, we 
will put the following in our Procfile:

web: python app.py

Later, we might want to use something more performant; you can use Gunicorn by 
adding it to our requirements.txt and replacing our Procfile contents with:

web: gunicorn app:app -b$PORT

// Heroku - Deploying Our Project:

git add Procfile && git commit -m "added Procfile"
git push heroku master

To set a persistent config value (sseful for things like database passwords 
and other configuration):

heroku config:set MY_ENV_VARIABLE=some_value

To scale your process up to 5 web dynos in an instant if we experience traffic 
surge (this will cost you $125 at $25 per dyno, so use this with caution):

heroku ps:scale web=5

To scale back down after you fall off Reddit:

heroku ps:scale web=1

We can list your app’s releases with:

heroku releases

To roll back to a certain release:

heroku rollback <release identifier>

To undo the latest release:

heroku release
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License