DiUS Computing Lca Rails Final
-
Upload
robert-postill -
Category
Technology
-
view
1.056 -
download
0
Transcript of DiUS Computing Lca Rails Final
Technical Lecture Series
Rails Deployment in the Enterprise:
Transmitting a Little ExperienceRobert Postill
What Can He Say About This?
Who is this bloke?The end of Java as we know itThe Rails you need to knowThe use of some cool toolsSummaryQuestions
Page #
Who am I?
Solaris SA who crossed over to developmentSpent time doing Java then RailsLots of integration projects and then greenfields developmentSpent 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?
FragmentationRuby and scripting languages
Groovy (JVM variants)
PHP
Haskell and functional languages
Polyglot solutionsWeb Services become a reality
Page #
The end of Java: What did we learn?
Partitioning our infrastructureNot everyone is our friendDatabases are a facade for storageBlowing business logic across the platform is a recipe for disasterTurns 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 peopleHow 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 projectGood patterns of development are enforced by being baked into the frameworkRuby is a great object-oriented language with a lot of perl-ish goodnessJruby 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 specificationRESTful 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 memoryIt'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:
Page #Name Language Elapsed LoC
wf10 C++ 00:04:41537
WFII.java Java (Kolja) 00:13:26126 (Report) + 2000 (WFII Framework)
stats_irumiha.pl Perl 00:19:56292
parallel_2.py Python 00:22:37124
stats.rb Ruby 25:24:4178
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 memoryIt'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 stateDatabases are slow (especially remote databases)Caching assetsAction, page and fragment cachingMemcached 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/webappsPush towards Postgresql/MySQL they're the most tested driversRails apps that use more than 150MB of mem probably need killingBudget on roughly 100MB of memory per processThe log directory can get full fast, so use logrotate with a truncate strategyCache 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
Page #You need a machine for the puppetmaster daemonEach client has a little daemon that talks to the serverPuppet 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 machinesPuppet has files called manifests
Deployment: Puppet - Example
Page #class sudo { package { sudo: ensure => latest } file { "/etc/sudoers": owner => root, group => root, mode => 440, source => "puppet:///sudo/sudoers", require => Package["sudo"], }}
Deployment: Puppet - Review
Page #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
Deployment: Capistrano
Page #Capistrano is closely aligned to Rails, but its use is much broader than thatCapistrano applies commands to sets of serversCapistrano also has recipes that it appliesThe syntax is Ruby-basedYou can call shell commands and inspect the results
Deployment:Capistrano - Example
Page #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
Deployment:Capistrano - Rails
Page #Capistrano was basically developed to deploy rails apps like basecamp and highrise so it knows railscapify will create config/deploy.rb and Capfile in your rails projectcap deployCapistrano will take a copy of what's in your source control and push it onto the server
Deployment: Capistrano - Review
Page #Upsides:Knows Rails intimately
Is sudo-aware
Downsides:Is much more project focussed
The documentation is not so good
Can be difficult to debug
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 ideaRuby 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 architecturePush the REST ideas, they benefit everyoneUse mongrel to host the apps and monit to control the mongrelsUse Capistrano or Puppet, to push the Rails apps to production, you'd be mad not toIntegrate 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/Resultshttp://shootout.alioth.debian.org/u32/ruby.phpREST: http://en.wikipedia.org/wiki/Representational_State_TransferPuppet: http://reductivelabs.com/trac/puppetCapistrano: http://www.capify.orgMongrel: http://mongrel.rubyforge.org/mod_rails/passenger: http://www.modrails.comMonit: http://mmonit.com/monit/
Page #
Contact
I'll be here all week :)But just in case:[email protected]
Page #
2 August 2005
Governance Framework Layers
2 August 2005
Governance Framework Layers
2 August 2005
Governance Framework Layers
2 August 2005
Governance Framework Layers
2 August 2005
Governance Framework Layers
2 August 2005
Governance Framework Layers
2 August 2005
Governance Framework Layers
2 August 2005
Governance Framework Layers
2 August 2005
Governance Framework Layers
2 August 2005
Governance Framework Layers
2 August 2005
Governance Framework Layers
2 August 2005
Governance Framework Layers
2 August 2005
Governance Framework Layers
2 August 2005
Governance Framework Layers
SpeedMemory Use
binary-trees1.31.6
fannkuch-1.5-1.2
k-nucleotide-3.62.4
mandelbrot-2.71.4
n-body-2.31.2
pidigits-7-4.4
regex-dna-1.1-1.3
reverse-complement3.3-1