• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Ruby on the server
 

Ruby on the server

on

  • 640 views

slides from 25 Oct 2012 meetup (http://www.meetup.com/madruby/)

slides from 25 Oct 2012 meetup (http://www.meetup.com/madruby/)

Statistics

Views

Total Views
640
Views on SlideShare
639
Embed Views
1

Actions

Likes
0
Downloads
0
Comments
0

1 Embed 1

http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

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
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Ruby on the server Ruby on the server Presentation Transcript

  • Ruby on the Server Max out your rubies!
  • Ruby Version ManagerUse it on the server! Multiple isolated Rubies Easy environment variables Easy install with patch integrationsetup/rvm.rb: https://gist.github.com/3946908
  • Ruby Garbage Collection Mark and Sweep, more or less: Stop the world Traverse and mark reference tree Free all unused objects (lazy = free) Still no free slots? Allocate 1.8 times more slots than on previous alloc
  • Typical Web Applications Small variations in used slots 100,000 - 200,000 slots in total 2,000 - 10,000 objects per request Most memory occupied by eternal (never freed) objects (code, classes, etc...)
  • Ruby 1.9.3-p286Ruby 1.9.3 GC is not copy-on-write friendlyBy default, 10,000 slots are allocated onstartup1.8 growth rate means Ruby is likely toallocate a lot more memory than needed!
  • falcon patchCopy-on-write friendly GCPerformance++ for require and HashSupported in RVM (--patch falcon)
  • GC ConfigurationWe want to allocate enough memory, so that rubynever has to resize it’s heapTypically 100,000 to 200,000 initial slotsRUBY_HEAP_MIN_SLOTS environment variable/usr/bin/time -l rails r "User.first(2000); pp GC.stat"
  • RAINBOWSServes HTTP over a Unix socketDoes not need rootMaster preloads app and forks workersMultiple net concurrency modelsExample config: https://gist.github.com/3946921
  • FOREMANProcess launcherExports to Upstart, launchd and othersKeeps developers happy!
  • FOREMAN: PROCFILE Environment-specific config called Procfile Advanced example: https://gist.github.com/3946937# Simple (no rvm) Procfileweb: bundle exec rainbowsresque: bundle exec rake resque:work QUEUE=*scheduler: bundle exec rake resque:scheduler# Run with$ foreman start web# Export with$ sudo foreman export upstart /etc/init -u app_user -a app
  • Seamless deploymentsTell Rainbows master to restart (USR2)On spawning a new worker, kill an old oneExtra memory requirement:1 worker + 1 masterCode here: https://gist.github.com/3946921
  • CapistranoMostly “just works” with rvm-capistranorvm_run command + restart_web task here:https://gist.github.com/3947004