• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Rails Performance Tricks and Treats
 

Rails Performance Tricks and Treats

on

  • 3,330 views

 

Statistics

Views

Total Views
3,330
Views on SlideShare
3,191
Embed Views
139

Actions

Likes
4
Downloads
34
Comments
2

3 Embeds 139

http://yountlabs.com 131
http://www.yountlabs.com 6
http://www.linkedin.com 2

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

12 of 2 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • exellent!
    Are you sure you want to
    Your message goes here
    Processing…
  • rails
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • Tell a nice little story about how I got into optimizations <br />
  • ASK: What is performance: take a survey <br /> group items on board between client and server metrics <br />
  • <br />
  • <br />
  • <br />
  • ASK: What are your favorite client tools <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • ASK: What are your favorite server tools? <br />
  • ASK: What are some other infrastructure tools <br /> more tools here than you can shake a stick at. <br /> <br />
  • http://jeremy.zawodny.com/mysql/mytop/ <br /> http://htop.sourceforge.net/ <br /> http://code.google.com/p/memcache-top/ <br /> <br />
  • http://jeremy.zawodny.com/mysql/mytop/ <br /> http://htop.sourceforge.net/ <br /> http://code.google.com/p/memcache-top/ <br /> <br />
  • http://jeremy.zawodny.com/mysql/mytop/ <br /> http://htop.sourceforge.net/ <br /> http://code.google.com/p/memcache-top/ <br /> <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • Rack-a-mole <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • check 37signals twitter and others for publicly posted gc settings <br /> <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />

Rails Performance Tricks and Treats Rails Performance Tricks and Treats Presentation Transcript

  • Rails Performance Tricks and Treats Marshall Yount Yount Labs
  • Everything I really need to know about code optimization I learned by playing Quake
  • The Big Picture • What is Performance? • How do we know we’re performant? • What tools do we use? • How do we fix problems? • Demonstration
  • Different ways of looking at performance • Client perceived • Server
  • Client • slow loading web page (latency) • slow executing webpage (javascript/css) http://www.flickr.com/photos/7423510@N06/2984486385/
  • The Enemy Latency: It’s a bitch
  • The Enemy http://www.flickr.com/photos/peterhaza/3492771467/ Latency: It’s a bitch
  • Diagnostic Tools (Client) • Firebug • YSlow • PageSpeed • UserTime
  • Diagnostic Tools (Client) • Firebug • YSlow • PageSpeed • UserTime
  • Diagnostic Tools (Client) • Firebug • YSlow • PageSpeed • UserTime
  • Diagnostic Tools (Client) • Firebug • YSlow • PageSpeed • UserTime
  • Reducing Roundtrips • CSS Sprites • CSS Data URIs • Jammit • Rails *_link_tag http://www.flickr.com/photos/mezzoblue/3217540317/
  • Reducing Roundtrips • CSS Sprites ul.checklist li.complete { margin-left: 20px; background: • CSS Data URIs url('data:image/ png;base64,AAAAFGGFyjOXZtQAAAAAElFT...') • Jammit top left no-repeat; } • Rails *_link_tag
  • Reducing Roundtrips <%= stylesheet_link_tag "main", "nav", • CSS Sprites "blog", :cache => “pagename_all” %> • CSS Data URIs <link href="/stylesheets/ • Jammit pagename_all.css?1234567890" media="screen" rel="stylesheet" • Rails *_link_tag type="text/css" />
  • HTTP Hacking for Fun and Profit • Off with her <HEAD> • Expires: • Last-Modified: • ETag: • Content-Encoding:
  • Server • registers • memory • network • database • disk • APIs http://www.flickr.com/photos/buro9/298998011/
  • Infrastructure • squid 2.7 • varnish • memcached • redis / resque
  • Top Clones • top • htop • mytop • memcache-top
  • Top Clones • top • htop • mytop • memcache-top
  • Top Clones • top • htop • mytop • memcache-top
  • Top Clones • top • htop • mytop • memcache-top
  • Monitoring -- free • nagios • cacti • zabbix • zenoss (core)
  • Monitoring -- free • nagios • cacti • zabbix • zenoss (core)
  • Monitoring -- free • nagios • cacti • zabbix • zenoss (core)
  • Monitoring -- free • nagios • cacti • zabbix • zenoss (core)
  • Monitoring -- paid • Pingdom Text • NewRelic • Scout
  • Monitoring -- paid • Pingdom • NewRelic • Scout
  • Monitoring -- paid • Pingdom • NewRelic • Scout
  • Fixing Problems • Performance is a moving target! • Horizontal/ Vertical scaling http://www.flickr.com/photos/tpapi/2765541278/
  • NewRelic Workflow • Web Transactions • Most Time Consuming • Slowest Average Response Time • Database
  • And the Number One Ruby on Rails Performance Problem Is ...
  • And the Number One Ruby on Rails Performance Problem Is ... N+1 Select
  • N+1 Select photos.each do |photo| puts photo.rating.id puts photo.user.email puts photo.camera.name end How many queries does this execute?
  • N+1 Select photos = Photo.find(:all, :include => [:rating, :user, :email]) photos.each do |photo| puts photo.rating.id puts photo.user.email puts photo.camera.name end How many queries does this execute?
  • Plugins/Gems • bullet • slim_scrooge • query_reviewer • ambitious_query_indexer • ActiveRecord::Extensions
  • Still not fast enough for ya? • ruby-prof • memprof - where are objects being created • change interpreters • ree -- gc.enable stats • jruby • ruby 1.9
  • Readings • Mark Nottingham’s HTTP caching tutorial • http://www.mnot.net/cache_docs/ • YSlow Best Practices • http://developer.yahoo.com/performance/rules.html • http://delicious.com/marshall.yount/performance
  • Tools • http://documentcloud.github.com/jammit/ • http://jeremy.zawodny.com/mysql/mytop/ • http://htop.sourceforge.net/ • http://code.google.com/p/memcache-top/
  • Appendix • The following incomplete slides were suggested by audience members at the Dallas Ruby Brigade. I’ll be fleshing these out and adding them to a future version of the presentation.
  • Rails caching model
  • Template rendering pain
  • Database Model Fields • wasteful data types • varchars •
  • Evented API calls