DiUS  Computing Lca Rails Final
Upcoming SlideShare
Loading in...5
×
 

DiUS Computing Lca Rails Final

on

  • 1,504 views

The presentation I did for LinuxConf.au around rails in the enterprise.

The presentation I did for LinuxConf.au around rails in the enterprise.

Statistics

Views

Total Views
1,504
Views on SlideShare
1,492
Embed Views
12

Actions

Likes
0
Downloads
3
Comments
0

4 Embeds 12

http://coderwall.com 5
http://www.linkedin.com 4
https://www.linkedin.com 2
http://www.slideshare.net 1

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

DiUS  Computing Lca Rails Final DiUS Computing Lca Rails Final Presentation Transcript

  • Rails Deployment in the Enterprise: Transmitting a Little Experience Robert Postill
  • 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 #
  • 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 #
  • Windows is badly broken Page #
  • 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 #
  • 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 #
  • PHP – More harmful than bird flu
  • 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 #
  • 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 #
  • 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 #
  • 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 #
  • 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 #
  • 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 #
  • 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 #
  • 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 #
  • How slow is Ruby vs Perl? Page #
  • How slow is it? Here's Sun's Widefinder project results: Name Language Elapsed LoC wf10 C++ 00:04:41 537 WFII.java Java (Kolja) 00:13:26 126 (Report) + 2000 (WFII Framework) stats_irumiha.pl Perl 00:19:56 292 parallel_2.py Python 00:22:37 124 stats.rb Ruby 25:24:41 78 Page #
  • 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 #
  • 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 #
  • 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 #
  • Are we ever going to talk deployment? Page #
  • Deployment Architecture Page #
  • Hang on a minute! Page #
  • Deployment Architecture Page #
  • Deployment Architecture Page #
  • 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 #
  • 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 #
  • Puppet, more than just fun... Page #
  • Deployment: Puppet 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 Page #
  • Deployment: Puppet - Example class sudo { package { sudo: ensure => latest } file { "/etc/sudoers": owner => root, group => root, mode => 440, source => "puppet:///sudo/sudoers", require => Package["sudo"], } } Page #
  • Deployment: Puppet - Review 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
    Page #
  • Deployment: Capistrano 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 Page #
  • Deployment:Capistrano - Example 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 Page #
  • Deployment:Capistrano - Rails 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 Page #
  • Deployment: Capistrano - Review Upsides:
    • Knows Rails intimately
    • Is sudo-aware
    Downsides:
    • Is much more project focussed
    • The documentation is not so good
    • Can be difficult to debug
    Page #
  • Touchy Feely Ahoy! Page #
  • 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 #
  • 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 #
  • 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 #
  • So what do I need to remember? Page #
  • 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 #
  • 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 #
  • Questions? Page #
  • 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 #
  • Contact I'll be here all week :) But just in case: [email_address] Page #