SlideShare a Scribd company logo
Deploying Rails
It’s easier than it looks
!
Ben Dixon, @talkingquickly
@talkingquickly
About Me
• Rails Developer, author of “Reliably Deploying Rails Applications”
• Teach people to make stuff with Ruby at MakeItWithCode.com
• Make cool swim technology stuff with SwimIO helloswimio.com
(swim watches, the speedo app etc)
@talkingquickly
Overview
• “git push heroku” is awesome
• But “Server stuff” isn’t that scary
• Once you know it, you can do cool stuff with it
@talkingquickly
Terminology
• “PaaS” = Platform as a service = something like Heroku
• VPS = Virtual Private Server = A Linux Server in the “Cloud” = “Box”
@talkingquickly
Behind the scenes
• How does “rails server” become a production setup?
• how to go from Rails S on dev machine to a production application?
@talkingquickly
A Simple Configuration
Web Server

E.g. Nginx, Apache
App Server
E.g. Unicorn, Thin,
Webrick
Database Server
VPS
A Request
@talkingquickly
The Web Server
• Nginx/ Apache
• First point of contact when a request comes in
• If it’s for a static file (like a picture) then deals with it directly
• If it’s for part of our Rails app, sends it to the app server
@talkingquickly
The App Server
• When you run “rails server”, this is what you’re starting
• E.g. Webrick, Thin, Unicorn
• This is the “rails app”
• The web server passes requests to this and it returns responses to
the web server
@talkingquickly
The Database Server
• E.g. MySQL, PostgreSQL etc
@talkingquickly
Recap
Web Server

E.g. Nginx, Apache
App Server
E.g. Unicorn, Thin,
Webrick
Database Server
VPS
A Request
@talkingquickly
But Why?
• More bang for your buck
• Background Jobs you can have lots and lots of them
• It makes working with a PaaS easier
@talkingquickly
But Why?
• Your infrastructure becomes another one of your tools for making
cool stuff
@talkingquickly
Don’t Do It Like I Did
• Get a VPS, Google “How to Setup a Rails VPS”
• Type in a lot of commands by hand
@talkingquickly
Why Not?
• When you need to setup another one, you’ll be back to square one
@talkingquickly
How To Do it: Configuration Management
• Automates the commands you would type in to setup a server
• Once you’ve done it once, doing it again is trivial
@talkingquickly
Configuration Management Example
• 1m30 Video of setting up a server with chef
@talkingquickly
How To Do it: Configuration Management
• Configuration Management is “DRY” for setting up servers
@talkingquickly
What about deployment?
• But “git push heroku" is awesome!
@talkingquickly
How To Do It: Deployment Automation
• Automates the commands needed to copy a new version of your
code to the server
• You can still deploy with just one command e.g. “cap production
deploy”
@talkingquickly
Deployment Automation Example
• 2m30 video of setting up and deploying with Capistrano
@talkingquickly
What about when it breaks?
• If something breaks, it should self heal as much as possible, if it
can’t it should alert you
• Use “Monitoring” tools e.g. Monit
• Your configuration management is responsible for setting all this up
@talkingquickly
First Stack
• Suggested First Stack:
• NGinx (Web Server)
• Unicorn (App Server)
• PostgreSQL (Database Server)
• Monit (Monitoring)
@talkingquickly
Toolbox
• Chef Solo + Knife (Server Provisioning)
@talkingquickly
Toolbox
• Capistrano 3 (Deployment Automation)
@talkingquickly
Next Steps
• Get a VPS! (Digital Ocean, Linode)
• 1GB + (512Mb Not Worth the Hassle)
@talkingquickly
Next Steps
• http://www.talkingquickly.co.uk/deploying_rails
• More in depth, my book “Reliably Deploying Rails Applications”
• Come and talk to me (@talkingquickly on twitter)
@talkingquickly
Any Questions?
• Ben Dixon // @talkingquickly
• Resources: http://www.talkingquickly.co.uk/deploying_rails

More Related Content

Railsconf 2014 - Deploying Rails is Easier Thank It Looks