Introduction to By Michael Mottola
What is Heroku?
A Cloud Platform as a Service (PaaS)
- Lets you easily deploy, run and manage applications written in:
Company Info
- Based out of San Francisco
- Founded in 2007 by application developers, as part of Y Combinator
- Originally supported only Ruby
- Acquired by Salesforce.com in December 2010 (For $250 million dollars)
- Yukihiro "Matz" Matsumoto, joined the company as Chief Architect
How Heroku Works
- Heroku platform builds your application from your source code and dependency descriptions.
- Executes a command to run your application (ex: starting a server)
- How you define your application and dependencies varies:
- Ruby uses Gemfile
- Python uses requirements.txt
- Node.js uses package.json
- Java uses pcm.xml
How Heroku Runs Your Application
- If using an established framework, Heroku figures it how to run your application:
- Ruby is rails server
- Djano is python <app>/manage.py runserver
- Node.js uses main field in package.json
- Else you must explicitly declare how your app is executed:
- Create text file called Procfile
web: bundle exec rails server -p $PORT
Where Is Your Application Running
- Lightweight Linux containers that runs a single user-specified command, called a Dyno
- Single dyno can serve thousands of requests per second
- Types of Dynos:
- Web Dynos: only receive HTTP traffic from Heroku's routers
- Worker Dynos: used for background jobs, queueing and timed jobs
- One-off Dynos: temporary, runs detached or from terminal
- Under the hood, Heroku is using Amazon Web Services; EC2 instances
Heroku Router
- Inbound requests are received by a load balancer and passed to a set of routers
- Routers determine location of your application's web dynos and forward the HTTP request
Heroku Toolbelt
Heroku Command Line Interface (CLI) for managing and scaling applications and add-ons.
https://toolbelt.heroku.com/
$ heroku login
Enter your Heroku credentials.
Email: michael@example.com
Password (typing will be hidden):
Authentication successful.
Create a Heroku App
$ heroku create my-app
Creating my-app... done, stack is cedar-14
http://my-app.herokuapp.com/ | git@heroku.com:my-app.git
Deploying Your Application
- Heroku primarily uses git for deploying applications
- GitHub Integration, Dropbox Sync and an API are also options
Deploy command:
git push heroku master
Scaling Your Application
- Scaling Horizontally: add more dynos
- more web dynos means more concurrent HTTP requests
- Scaling Vertically: using bigger dynos (increase RAM)
Scaling with command line:
heroku ps:scale web=2
Other Heroku Toolbelt Commands
- General commands:
- heroku apps
- heroku keys
- heroku keys:add
- App Specific Commands
- heroku create
- heroku config
- heroku ps
- heroku info
- heroku logs
- heroku run
/