Download presentation
Presentation is loading. Please wait.
Published byPenelope Cameron Modified over 8 years ago
1
Rails Deployment in the Enterprise: Transmitting a Little Experience Robert Postill
2
What Can He Say About This? Who is this bloke? The end of Java as we know it The Rails you need to know The use of some cool tools Summary Questions Page # 2
3
Who am I? Solaris SA who crossed over to development Spent time doing Java then Rails Lots of integration projects and then greenfields development Spent a lot of time working with infrastructure departments Page # 3
4
Windows is badly broken Page # 4
5
Why Linux? Performance, you will notice the difference (so long as you don't use the Ubuntu-supplied ruby!) Because you can easily get supporting tools (e.g. Apache, Postgres, git) Because some gems require C to be compiled (bless the gcc) Because of the community Page # 5
6
The end of Java: How we got here When we were young we thought things could be simple: One language could be used for everything Vendors could help We could still be flexible What went wrong? The learning curve :( How expensive is this? This is so slowwww to develop Page # 6
7
PHP – More harmful than bird flu
8
The end of Java: What's happening now? Fragmentation Ruby and scripting languages Groovy (JVM variants) PHP Haskell and functional languages Polyglot solutions Web Services become a reality Page # 8
9
The end of Java: What did we learn? Partitioning our infrastructure Not everyone is our friend Databases are a facade for storage Blowing business logic across the platform is a recipe for disaster Turns out open source rocks :) Page # 9
10
Rant:Who are we employing? We need to find a question we can answer by saying “employ a small number of smart people” How do we get junior infrastructure guys to become senior guys? Why aren't there patterns for deploying applications? Why is infrastructure so driven by development? Page # 10
11
So sell me this rails stuff Web Development is quick – my guess is a 3x development speed improvement for a 3 month project Good patterns of development are enforced by being baked into the framework Ruby is a great object-oriented language with a lot of perl-ish goodness Jruby is an excellent gateway drug ;) REST is encouraged Page # 11
12
REST – I'm Excited! It's an architecture of development conceived by Roy Fielding – one of the founders of the Apache Software Foundation and the HTTP specification RESTful applications try to model themselves on the web, which means: Applications are modeled around resources You can put caches at multiple levels Page # 12
13
The basics of Rails: Structure Every project is contained in a directory: tmp – holds temporary files log holds logs public – static files like images, CSS and like script – commands for starting and stopping the application config – holds database credentials and performance settings mostly app – the source code lives here Page # 13
14
The basics of Rails: Deployment Three deployment options: Webrick – I wouldn't with yours :) Mongrel – most analogous to Tomcat, a specialised daemon written in Ruby and C mod_rails/passenger – the new kid on the block. Apache module with some cute tricks in it. My attitude is that Mongrel is the safe option for right now. However mod_rails is shaping up to be ace Page # 14
15
Pitfalls of Rails Speed of execution: Scaling rails is not going to work the Java way Rails and Ruby are not the answer for large batch operations Rails apps leak memory It's the best AJAX integration that I know of: We haven't had The Great AJAX Security Disaster yet but we will Clients of AJAX applications (I'm looking at you Firefox...) leak memory, lots of it. Page # 15
16
How slow is Ruby vs Perl? Page # 16
17
How slow is it? Here's Sun's Widefinder project results: Page # 17
18
Pitfalls of Rails Speed of execution: Scaling rails is not going to work the Java way Rails and Ruby are not the answer for large batch operations Rails apps leak memory It's the best AJAX integration that I know of: We haven't had The Great AJAX Security Disaster yet but we will Clients of AJAX applications (I'm looking at you Firefox...) leak memory, lots of it. Page # 18
19
Scaling Rails Rails doesn't need a bigger box it needs another instance (possibly on another box) Rails apps don't share state Databases are slow (especially remote databases) Caching assets Action, page and fragment caching Memcached Indexing engines versus RDBMS Page # 19
20
Securing Rails Wrapping Rails in your onion: Front Rails with Apache or something else Proxy requests (push for RESTful apps to help with this) config/database.yml stores your db credentials so protect it (maybe move it out of source control?). mod_rewrite can be dangerous Never ever use in_place editor Page # 20
21
Are we ever going to talk deployment? Page # 21
22
Deployment Architecture Page # 22
23
Hang on a minute! Page # 23
24
Deployment Architecture Page # 24
25
Deployment Architecture Page # 25
26
Deployment Tips Deploy to a common location – I like /var/webapps Push towards Postgresql/MySQL they're the most tested drivers Rails apps that use more than 150MB of mem probably need killing Budget on roughly 100MB of memory per process The log directory can get full fast, so use logrotate with a truncate strategy Cache gems on a server, all you need is Apache! Page # 26
27
Deployment Tools A couple of really helpful deployment aids that come right out of the ruby and rails community: Capistrano – a tool for simultaneous execution of commands on an SSH server Deprec and Sprinkle – tools that use Capistrano as their base. Puppet – a configuration management tool, so cunning you could cast it in Blackadder Page # 27
28
Puppet, more than just fun... Page # 28
29
Deployment: Puppet Page # 29 You need a machine for the puppetmaster daemon Each client has a little daemon that talks to the server Puppet works with your OS package management so you use pbuilder or erm the rpm thingy... Puppet allows you to take control of large populations of machines Puppet has files called manifests
30
Deployment: Puppet - Example Page # 30 class sudo { package { sudo: ensure => latest } file { "/etc/sudoers": owner => root, group => root, mode => 440, source => "puppet:///sudo/sudoers", require => Package["sudo"], }
31
Deployment: Puppet - Review Page # 31 Upsides: Works in a heterogeneous environment Check out the recipes... nice Puppet makes provision for config of files and apps Puppet works continuously Downsides: There's only one puppetmaster supported. The recipe syntax is not as powerful as it could bez
32
Deployment: Capistrano Page # 32 Capistrano is closely aligned to Rails, but its use is much broader than that Capistrano applies commands to sets of servers Capistrano also has recipes that it applies The syntax is Ruby-based You can call shell commands and inspect the results
33
Deployment:Capistrano - Example Page # 33 task :search_libs, :hosts => "www.capify.org" do run "ls -x1 /usr/lib | grep -i xml" end task :as_root, :hosts => "r.postill.com" do sudo "useradd robert" end
34
Deployment:Capistrano - Rails Page # 34 Capistrano was basically developed to deploy rails apps like basecamp and highrise so it knows rails capify will create config/deploy.rb and Capfile in your rails project cap deploy Capistrano will take a copy of what's in your source control and push it onto the server
35
Deployment: Capistrano - Review Page # 35 Upsides: Knows Rails intimately Is sudo-aware Downsides: Is much more project focussed The documentation is not so good Can be difficult to debug
36
Touchy Feely Ahoy! Page # 36
37
Deployment Attitude Stop being a victim of development: Set expectations for metrics like code coverage Make a link between Continuous Integration tools (e.g. CC.rb or Hudson) and deployment. For example don't allow broken builds to be deployed Try and make the deployment an output of the build process. Page # 37
38
Deployment:Development Interface Get into the habit of being part of the project ceremony. Particularly in XP teams be a part of: Iteration open and close Retrospectives Showcases Stand-ups (for practitioners) Put resources into the development team, in particular: Get a System Admin and DBA in early and don't let them leave Build test environments with load balancers/proxies Page # 38
39
Where Next? We need to improve post deployment: Dynamic provisioning, can we scale like Amazon? SNMP integration We should assume that the One Language To Rule Them All is a bad idea Ruby needs to stomp on those memory leaks (watch for Ruby 2/1.9/Rubinius) Page # 39
40
So what do I need to remember? Page # 40
41
Summary Ruby and Rails are ace :) Try and use a simple three-tier architecture Push the REST ideas, they benefit everyone Use mongrel to host the apps and monit to control the mongrels Use Capistrano or Puppet, to push the Rails apps to production, you'd be mad not to Integrate with the development teams Page # 41
42
Photo credits All photos courtesy of flickr's creative commons: nathansnostalgia, broken windows, page 4 - http://www.flickr.com/photos/nathansnostalgia/2098210283/ kaymoshusband, chicken sign, page 8- http://www.flickr.com/photos/thegaffneys/365119725/ big loggy missus, sleepy guy, page 21 - http://www.flickr.com/photos/natsgrant/501293610/ pt, puppet, page 28- http://www.flickr.com/photos/pmtorrone/9845799/ dunechaser, pirate attitude, page 36 - http://www.flickr.com/photos/dunechaser/253066484/ tyla75, new year resolutions, page 40 - http://www.flickr.com/photos/tyla/3159840057/ Page # 42
43
Questions? Page # 43
44
Links Language comparisons: http://wikis.sun.com/display/WideFinder/Results http://shootout.alioth.debian.org/u32/ruby.php REST: http://en.wikipedia.org/wiki/Representational_State_Transfer Puppet: http://reductivelabs.com/trac/puppet Capistrano: http://www.capify.org Mongrel: http://mongrel.rubyforge.org/ mod_rails/passenger: http://www.modrails.com Monit: http://mmonit.com/monit/ Page # 44
45
Contact I'll be here all week :) But just in case: r.postill@diuscomputing.com.au Page # 45
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.