Heroku and Rails Applications

  • Published on
    14-Apr-2017

  • View
    478

  • Download
    0

Embed Size (px)

Transcript

  • 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

    https://devcenter.heroku.com/articles/getting-started-with-ruby

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

    http://puma.io

  • 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

    http://12factor.net

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

    https://github.com/romanbsd/heroku-deflater

  • Whats next?Getting Started with Ruby on Heroku

    Getting Started with Rails 4.x on Heroku

    How Heroku Works

    Heroku Dev Center: Reference

    https://devcenter.heroku.com/articles/getting-started-with-rubyhttps://devcenter.heroku.com/articles/getting-started-with-rails4https://devcenter.heroku.com/articles/how-heroku-workshttps://devcenter.heroku.com/categories/reference