Beyond Heroku: Hosting Your Rails App Yourself


Published on

These are the slides from my presentation at CPOSC 2013.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • {"5":"Comparable to Thin, WEBrick, Puma\nThe no-multithreading part is important. It’s not just your code that needs to be thread-safe, but any Gems that you use as well. Pay a higher price in memory, but get single threaded code. This is in contrast to Puma which runs your code in a multithreaded environment and works best on a Ruby implementation that supports it (Rubinius, JRuby)\nExisting workers can continue to serve requests while a new master is being started. Then the new master takes over spawning new workers. Not perfect since you may have DB changes, etc., but still nice.\nConfigured via a Ruby DSL. So you can write actual code as part of the configuration.\n","6":"nginx keeps getting more popular. June 2013 Netcraft survey has nginx ahead of Microsoft IIS in market share of active sites.\nOfficial documentation is good - lots written elsewhere, too (blogs, etc.)\nEasy to install - nginx is available in most distros package managers, built with a reasonable set of defaults (compression, SSL). nginx uses modules that must be included at compile-time (unlike Apache modules that are added at runtime). Compiling is pretty easy if necessary.\nConfiguration is straightforward - just configuring the reverse proxy to Unicorn and whatever you want for static files (far-future expires)\n","7":"Uses tasks (like Rake). So individual steps can be executed separately.\nCan deploy from public source code hosts (Github, Bitbucket). Can also deploy via copying files, upload of directories. When the source code is accessible to the web server, incremental updates are possible.\nVersions are deployed into separate directories with the current version symlinked to a known location. Rollbacks are as easy as updating the symlink (at least if there aren’t conflicting DB changes).\nDB migrations can be executed as part of the deployment (or separately).\nLike Unicorn, uses a Ruby DSL for configuration. So code can be written to control Capistrano. You can also add your own tasks.\n","2":"Cost for dynos: $35/month - need a dyno for a worker\nCost for SSL: $20/month\nDB’s are expensive: $50/month for “production” quality\nYou trade flexibility for infrastructure expertise\nYou can choose to run Redis or Memcached on the same machine\nYou need to handle configuration\nSingle dynos are idled - take a long time to start up\n","3":"Lots of options for Linux hosting. Digital Ocean is only $5/month for 512 MB of RAM, $10/month for 1GB\nConfiguration management: Chef, Puppet, Ansible\nYou do need to be comfortable enough to build and deploy a server - it’s not that hard and it’s cheap to experiment with different configurations\nSet up your config management software, then throw away the VM, create a new one, and try it out\n","4":"nginx handles the web serving (static files, compression, SSL) and hands off the request to one or more Unicorn workers\nCapistrano is a deployment tool written in Ruby targeted for Rails\n"}
  • Beyond Heroku: Hosting Your Rails App Yourself

    1. 1. Beyond Heroku: Hosting Your Rails App Yourself Sean Carpenter @scarpenter
    2. 2. Why not Heroku? • Cost • Lack of control • Dyno idling
    3. 3. How can you do it? • Many affordable Linux hosts: Amazon (free tier), Windows Azure (with MSDN), Digital Ocean, Linode • Lots of open source configuration management software
    4. 4. Hosting a Rails Application • Unicorn as the app server • nginx as a reverse proxy • Deployment via Capistrano
    5. 5. Unicorn • Rack HTTP server • Multiple workers - concurrency without multithreading • Graceful restarts • Ruby for configuration
    6. 6. nginx • Fast and reliable • Well documented • Available in most distros • Straightforward configuration
    7. 7. Capistrano • Deploys code directly from source control • Easy rollback • Executes DB migrations • Ruby for configuration
    8. 8. Demo
    9. 9. Questions? @scarpenter
    10. 10. Questions? @scarpenter