9
Heroku and Rails Applications Great platform for great applications

Heroku and Rails Applications

Embed Size (px)

Citation preview

Page 1: Heroku and Rails Applications

Heroku and Rails ApplicationsGreat platform for great applications

Page 2: Heroku and Rails Applications

What is Heroku?Heroku is a cloud platform that lets build, deliver, monitor and scale web applications.

Developer-centric / App-centric / Production-centric

Ruby Python PHP Node.js Java Go Scala Clojure

Page 3: Heroku and Rails Applications

Why use Heroku?

8 Billion Requests per Day 5+ Million Apps Created 150+ Add-on Services

Easy to start, easy to use Scalability out of the box Manageable expenses

Page 4: Heroku and Rails Applications

Getting startedInstall Heroku Toolbelt It’s a cross-platform Command Line Interface

Prepare your app:

Create Heroku application: `heroku create` command

Define a Procfile: let Heroku know, how to run the app

Fix app dependencies: a few additional line in your Gemfile

Run app locally: `heroku local web` command

Deploy to Heroku cloud: `git push heroku master` command

Full guide at Heroku Dev Center

Page 5: Heroku and Rails Applications

ProcfileA Procfile is a mechanism for declaring what commands are run on the Heroku platform.

Example of Procfile

web: bundle exec puma -C config/puma.rbworker: bundle exec rake jobs:work

Tip: Use Puma web server for your apps on Heroku.

Page 6: Heroku and Rails Applications

The Twelve-Factor AppThe twelve-factor app a methodology for building software-as-a-service apps.

I. CodebaseOne codebase tracked in revision control, many deploys

II. DependenciesExplicitly declare and isolate dependencies

III. ConfigStore config in the environment

IV. Backing ServicesTreat backing services as attached resources

V. Build, release, runStrictly separate build and run stages

VI. ProcessesExecute the app as one or more statelessprocesses

VII. Port bindingExport services via port binding

VIII. ConcurrencyScale out via the process model

IX. DisposabilityMaximize robustness with fast startup and graceful shutdown

X. Dev/prod parityKeep development, staging, and production as similar as possible

XI. LogsTreat logs as event streams

XII. Admin processesRun admin/management tasks as one-off processes

Page 7: Heroku and Rails Applications

DeploymentHeroku supports 3 major ways to deploy your application to the cloud:

Heroku Git Deploy the application with a simple command: `git push heroku master`

GitHub Connect GitHub repository to your Heroku app. Whenever somebody pushesto GitHub, apps will be updated.

DropBox Connect Dropbox folder. Initiate deploys from Heroku Dashboard.

Page 8: Heroku and Rails Applications

Dynos limitationsFree dyno is great for development and testing: It goes to sleep after 30 minutes of inactivity. Should sleep at least 6 hours a day.

Hobby dyno is great small projects: It costs $7 per month, never sleeps, but not scalable.

If you want more - use professional dynos. Price starts from $25 per month. Full set of features: scalability, metrics, fast builds, etc.

Tip: Use `heroku-deflater` gem on production to enable compression and other optimizations.