Introduction to deployment with Ruby on Rails presented at JAX09 in Mainz by Jonathan Weiss.
Learn about the deployment architectures and setups (web and app tier) and using Capistrano/Webistrano.
2. Who am I?
Jonathan Weiss
â˘â Consultant for Peritor GmbH in Berlin
â˘â Specialized in Rails, Scaling, Deployment, and Code Review
â˘â Webistrano - Rails deployment tool
â˘â FreeBSD Rubygems and Ruby on Rails maintainer
http://www.peritor.com
http://blog.innerewut.de
http://twitter.com/jweiss
2
10. Typical Rails Setup
â˘â A load-balancer distributes the incoming requests
â˘â Some load-balancers will deliver static requests themselves
â˘â Several Rails instances handle all requests
â˘â Number of concurrent requests equals number of Rails instances
10
20. Mongrel
â˘â Very robust
â˘â Strict HTTP parser
â˘â Easy to debug (HTTP!)
â˘â Defacto standard deployment with Apache 2.2 and mod_proxy_balancer
â˘â Can be a bit difďŹcult to setup (mongrel_cluster, ports, Apache)
â˘â Not so easy on mass/virtual hosting
20
22. mod_rails a.k.a Phusion Passenger
â˘â Module for Apache 2.2 (and Nginx)
â˘â Allows Apache to control Rails instances
â˘â Apache starts and stops application instances depending on the application load
â˘â Able to run any RACK-compatible Ruby application (Merb & Co.)
â˘â Only manages Rails on one host - no remote instances
â˘â Combine with HTTP-Proxy / balancing solution
22
27. Phusion Passenger
â˘â Fairly new but ready for production
â˘â Makes setup easier â on the single machine level
â˘â Multiple servers still require load balancer
â˘â Suitable for mass-hosting
â˘â (upcoming) standard way of deploying Rails
27
29. â˘â Ruby Runtime on the Java Virtual Machine
â˘â Implemented in Java and Ruby
â˘â Compiles Ruby into Java-bytecode
â˘â Integrates with Java code and libraries
â˘â Javaâs promises of native threads and JIT
â˘â Allows for Ruby/Rails applications to be packaged as WAR ďŹles
â˘â WAR ďŹles deployable on any J2EE-container:
GlassďŹsh, JBoss, Tomcat, Jetty, âŚ
29
52. The Rest
â˘â Callbacks
â˘â Transactions
â˘â Capistrano Shell
â˘â Custom tasks and namespaces
â˘â Staging and multiple setups
â˘â Gem dependencies
â˘â Support for deploying through gateway servers
â˘â Server setup with deprec gem
52
55. Webistrano
â˘â Web-UI to Capistrano
â˘â Manages projects and their stages
â˘â Alerting and Accounting
â˘â Scriptable and extendable
â˘â BSD License
http://labs.peritor.com/webistrano
55
56. Macistrano
â˘â Mac-GUI to Webistrano
â˘â Fire and monitor deployments from your desktop
http://github.com/mattmatt/macistrano
56
58. Cloud Infrastructure
Servers come and go
â˘â You do not know your servers before deploying
â˘â Restarting is the same as introducing a new machine
You canât hardcode IPs
database.yml
58
59. Solution #1
Query and manually adjust
â˘â Servers do not change that often
â˘â New nodes probably need manual intervention
â˘â Use AWS ElasticIPs to ease the pain
Set servers dynamically AWS Elastic IP
59
60. Solution #2
Use a central directory service
â˘â A central place to manage your running instances
â˘â Instances query the directory and react
60
61. Solution #2
Use a central directory service
â˘â A central place to manage your running instances
â˘â Instances query the directory and react
61
63. Final words
Once understood the Rails infrastructure is quite simple
Passenger is very easy to setup and should be the default choice
Learn how to use Capistrano and Webistrano,
they will make your life much easier â even in non-Rails setups
63