1. Heroku
The platform for your next awesome app.
1
Monday, October 3, 11
2. In a nutshell
Platform as Service
Ruby on Rails & lately NodeJS, Java, Clojure on top of AWS.
Founded 2007 - Bought in 2010 from Salesforce ($212M)
194.000 apps NOW.
~30% from mobile applications. RESTful services. Special deal with Facebook for FB app hosting.
Jul 2011, Matz (Yukihiro Matsumoto) joined heroku as Chief
Architect, Ruby [1]
Remember: MRI stands for Matz’s Ruby Interpreter
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 2
Monday, October 3, 11
3. Summary - Index
Infrastructure Deploying
Hardware - Parking. Git - Rollback - Migrating.
Network Interface Scaling
Routing Mesh = Magic Easier than ever.
Database Monitoring
Postgresql, NoSQL solutions Logging - Exception Tracking
Process Model & Dyno
Zooming in the heart of Heroku Effective Cloud Hosting
Stacks & Frameworks Taking advantage of Pricing /
process model
Add ons AutoScale web processes
A sweet surprise
AutoScale background jobs
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 3
Monday, October 3, 11
4. Infrastructure
Build atop of Amazon Web Services
Cedar Stack: on High Memory Double Extra Large
Instances [2]
35 GB Ram
13 EC2 Compute Units.
maybe ~ 120 Dynos per Instance
Database on EC2 - EB storage
mhhh (see April’s outage incident)
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 4
Monday, October 3, 11
5. Infrastructure
Not in Cedar Stack
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 5
Monday, October 3, 11
6. Network Interface
DNS
Seems to be 6 nginx reverse proxies + any dedicated IP/proxy ($100 / month)
(proxy.heroku.com)
Routing Mesh
Routing software written in Erlang. (seems to have some secret sauce)
If no live dyno is found for this app’s route, a new dyno is spawned.
HTTP Caching
< Stack Cedar: Varnish Reverse Proxy Caching via HTTP headers, HTTP 1.0
compatible.
>= Cedar: No Reverse Proxy Caching, HTTP 1.1 Compatible, Routes directly to
dynos:
Non-blocking servers (Goliath / EventMaching) - Long Polling
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 6
Monday, October 3, 11
7. Heroku Dyno
A dyno is a single (isolated) process of any type, running on
the Heroku platform
Mongrel, Thin, Delayed Job, Resque, Workers...
Dyno Manifold manages the resources.
Any number of dynos / application w/ the latest code compiled and deployed.
Crashed dynos are closed and restarted automatically.
Dynos are isolated: LXC & Chroot for isolated user space / resources / filesystem. [4]
512 Mb Ram.
Cost per Dyno (dyno-hour)
1 Dyno for Free.
$ 0.05 / hour = $ 35 / month / dyno --- 6 minutes = 0.1 dyno-hour = $ 0.005
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 7
Monday, October 3, 11
8. Dyno’s Process Model of Cedar
Dyno Manifold does the Process Management
Starts / Stops / Restarts / Idles the processes / Sets config Vars / Applies Code Releases
All the possible Process Types (servers, workers,..) are
described in a procfile.
Procfile is a file on the root of your app and describes any needed process that you
want to run (and scale)
web: bundle exec rails server -p $PORT
worker: bundle exec rake jobs:work
scraper: bundle exec ruby scraper.rb
Foreman is a ruby Gem handling profiles for the Development Environment.
Scale Preview
$ heroku scale web=3 worker=2 scraper=2
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 8
Monday, October 3, 11
9. Database - SQL solutions.
PostgreSQL
Shared database PostgreSQL 8.3 - Dedicated database uses PostgreSQL 9.
Continues Backups [3]
Storing on EBS volumes of AmazonWS
(“With this information in hand, we'll be taking a hard look on how to reduce our
dependence on EBS”) [3]
External Connections are NOT allowed
Goodies
Backups - psqldump
Database Sync with TAPS
Is currently a DaaS for Heroku - encouraging polyglot
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 9
Monday, October 3, 11
10. Database - noSQL solutions
DaaS is (maybe) the future of complex web applications
Heroku Supports encourages the polyglot concept
Redis for your Ad Service / counters etc.
Hadoop for your big data tables
S3 for your Assets
Memcache for transient data such as Sessions
CouchDB for data that need to be replicated (your separate mobile app database)
Neo4j for your super clever recommendation engine
Currently most of theses DaaS offer an add-on for
HEROKU.
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 10
Monday, October 3, 11
12. Add ons
Services Implement Heroku’s Add-ons API for automate
provisioning
MYSQL_URL=mysql://user:pass@mysqlhost.net/database
Dyno Manifold will Restart all the running Dynos, including the
new ENV variables.
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 12
Monday, October 3, 11
13. Deploying.
Based on Git.
Heroku is a git remote for your code.
$ git remote add heroku git@heroku.com:myapp.git
When receiving a push (git push heroku master) starts the deployment process
bundle install
Remove unused files, including the .git directory, anything in log and tmp, .gem
files in the bundled gems directory, and anything specified in .slugignore.
Write the environment into the slug. (The slug is rebuilt any time a config var or
add-on is changed)
Package into the final slug archive.
Slug Size Matters: Larger Slug == slower distribution
< 30 MB
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 13
Monday, October 3, 11
14. Scaling
Concept: More Dynos = Better Concurrency
Unlimited Number of Dynos / Application.
Command Line $ heroku scale web=3 worker=2 scraper=2
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 14
Monday, October 3, 11
15. Scaling
Concept: More Dynos = Better Concurrency
Unlimited Number of Dynos / Application.
Command Line
Web Interface
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 15
Monday, October 3, 11
16. Scaling
Concept: More Dynos = Better Concurrency
Unlimited Number of Dynos / Application.
Command Line
Web Interface
Ruby Script (wait for it...)
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 16
Monday, October 3, 11
17. Scaling
Concept: More Dynos = Better Concurrency
Unlimited Number of Dynos / Application.
Command Line $ heroku scale web=3 worker=2 scraper=2
Web Interface
Ruby Script (wait for it...)
Mobile App (Nazumi App)
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 17
Monday, October 3, 11
18. Scaling
Concept: More Dynos = Better Concurrency
Unlimited Number of Dynos / Application.
Command Line $ heroku scale web=3 worker=2 scraper=2
Web Interface
Ruby Script (wait for it...)
Mobile App (Nazumi App)
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 18
Monday, October 3, 11
19. Scaling
Concept: More Dynos = Better Concurrency
Unlimited Number of Dynos / Application.
Command Line
Web Interface
Ruby Script (wait for it...)
Mobile App (Nazumi App)
Database Scaling
Ika: $800/month, 50 connections, 7.5 GB of RAM, 4 compute units
PostgreSQL 9 Baku: $3200/month, 128 connections, 34 GB of RAM, 13 cu
Mecha: $6400/month, 256 connections, 68 GB of RAM, 26 cu
Amazon RDS addon
NoSQL solutions
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 19
Monday, October 3, 11
21. Heroku Billing Model
100% Based on it’s process model
Dynos are billed per second at a rate of 0.05$ / hour
First Dyno is FREE (Watch out: single Dyno Idling Policy can cause delays)
Add-ons are billed per second.
Databases are billed per hour.
1 web server + 1 worker + Shared Database (20GB) = 1x36 + 1x36 + 15 = 87$ /month
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 21
Monday, October 3, 11
22. Heroku can be even more elastic
Dyno #1
1 Dyno #2
Large Dyno #3
Elastic Dyno #4
Dyno #5
Dyno #6
~ Dyno #7
Dyno #8
4.7 GB Dyno #9
ram Dyno #10
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 22
Monday, October 3, 11
23. Heroku can be even more elastic
Dyno #1
1 Dyno #2
Large Dyno #3
Elastic Dyno #4
Dyno #5
Dyno #6
~ Dyno #7
Dyno #8
4.7 GB Dyno #9
ram Dyno #10
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 23
Monday, October 3, 11
24. Heroku can be even more elastic
Dyno #1
1 Dyno #2
Large Dyno #3
Elastic Dyno #4
Dyno #5
Dyno #6
~ Dyno #7
Dyno #8
4.7 GB Dyno #9
ram Dyno #10
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 24
Monday, October 3, 11
25. Heroku can be even more elastic
Dyno #1
1 Dynos => $ 0.5/h
10 Dyno #2
Large
1 LARGE => $ 0.35/h Dyno #3
Elastic
HEROKU = 42% more expensive
Dyno #4
Dyno #5
Dyno #6
~ Dyno #7
Dyno #8
4.7 GB Dyno #9
ram Dyno #10
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 25
Monday, October 3, 11
26. Heroku can be even more elastic
Dyno #1
110 Dynos => $ 0.5/h Dyno #2
Large
1 LARGE => $ 0.35/h Dyno #3
Elastic Dyno #4
HEROKU = 42% more expensive Dyno #5
Dyno #6
~ Dyno #7
Dyno #8
4.7 GB
0.33*1/2+0.33*1/5+0.33*1 = 56% dynamic Dyno #9
ram Dyno #10
usage
10 DYNAMIC Dynos => $ 0.28/h
1 LARGE => $ 0.35/h
HEROKU = 25% cheaper
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 26
Monday, October 3, 11
27. Use Heroku because:
It’s free
You can have a look at almost everything without spending a penny.
It’s fast
Rapid prototyping meets heroku
It support open source solutions
Scaling needs can show up any day
You are better developer than administrator
CloudCamp.org/Athens | 2011 | Savvas Georgiou | presenting Heroku 27
Monday, October 3, 11
28. Code
For dynamic Dyno management
28
Monday, October 3, 11
29. Thank you
Savvas Georgiou
@savvasgeorgiou
contact@savvas.me
http://savvas.me
29
Monday, October 3, 11