Heroku and Rails Applications

  • Published on

  • View

  • Download

Embed Size (px)


  • Heroku and Rails ApplicationsGreat platform for great 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

  • 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

  • Getting startedInstall Heroku Toolbelt Its a cross-platform Command Line Interface

    Prepare your app:

    Create Heroku application: `heroku create` commandDefine a Procfile: let Heroku know, how to run the appFix app dependencies: a few additional line in your GemfileRun app locally: `heroku local web` command

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

    Full guide at Heroku Dev Center


  • 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.


  • 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


  • 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.

  • 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.


  • Whats next?Getting Started with Ruby on Heroku

    Getting Started with Rails 4.x on Heroku

    How Heroku Works

    Heroku Dev Center: Reference