EC2 for Rails Deployment
November 16, 2009
Once Upon A Time...
Deploying Ruby Web Apps was a
Pain in the Ass
Make VPS Deployment much easier:
Apache / Passenger,
Manage remote servers and automate remote tasks
Deploy versioned code from source control
Back up old versions (for roll-back)
Migrate database (optional)
Link shared assets, etc. Whatever you want!
gem install capistrano
* Remember to set up your ssh keys if deploying from GitHub!
This all makes deployment much more palatable.
Provisioning servers still takes time.
Configuring servers / services still takes time.
Horizontal scaling takes a lot of time, money, effort.
Amazon Elastic Compute Cloud
Enter: The Cloud (
Fire up a server with no waiting period.
Deploy a working systems image (AMI).
Scale at will, on-demand. Pay for what you use.
Plug in other AWS pieces (
It's not "Easy to Use"
But what we really need is scriptability (!)
Ruby tools (surprise) make this easier
Also: see commercial offerings like RightScale, Scalr.
Support for roles
Horizontally scale up and down
Single instance with everything
Or deploy roles to separate instances
(cuz instances can disappear)
gem install rubber
Sign up for EC2, get keypair
Optionally set up rubber-secret.yml
Rubber sets up EC2 security groups
script/generate vulcanize complete_passenger_mysql
Add keys, account info
List system packages, gems to install
Dynamic DNS config, etc
Create an Instant Staging Instance
Use RAILS_ENV to support multiple staging instances
cp config/environments/production.rb config/environments/nick.rb
RUBBER_ENV=nick cap rubber:create_staging
Surf to http://nick.mydomain.com
Rubber Admin Server
Web Admin UIs for Monit / HAProxy
Check server stats (Munin)
ALIAS=tools ROLES=web_tools cap rubber:create
Time to scale up?
Add an app server to handle increased load
Roles in default templates can scale by default
ALIAS=app02 ROLES=app cap rubber:create
Create custom roles (need background queue / workers?)
Config files are just ERB templates
More information at the
Insert Demo Here.
Rubber was created by