Your SlideShare is downloading. ×
Rails Performance Tricks and Treats
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Rails Performance Tricks and Treats

2,893

Published on

Published in: Technology
2 Comments
4 Likes
Statistics
Notes
  • exellent!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • rails
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
2,893
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
35
Comments
2
Likes
4
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

  • Tell a nice little story about how I got into optimizations
  • ASK: What is performance: take a survey
    group items on board between client and server metrics



  • ASK: What are your favorite client tools








  • ASK: What are your favorite server tools?
  • ASK: What are some other infrastructure tools
    more tools here than you can shake a stick at.

  • http://jeremy.zawodny.com/mysql/mytop/
    http://htop.sourceforge.net/
    http://code.google.com/p/memcache-top/

  • http://jeremy.zawodny.com/mysql/mytop/
    http://htop.sourceforge.net/
    http://code.google.com/p/memcache-top/

  • http://jeremy.zawodny.com/mysql/mytop/
    http://htop.sourceforge.net/
    http://code.google.com/p/memcache-top/








  • Rack-a-mole







  • check 37signals twitter and others for publicly posted gc settings








  • Transcript

    • 1. Rails Performance Tricks and Treats Marshall Yount Yount Labs
    • 2. Everything I really need to know about code optimization I learned by playing Quake
    • 3. The Big Picture • What is Performance? • How do we know we’re performant? • What tools do we use? • How do we fix problems? • Demonstration
    • 4. Different ways of looking at performance • Client perceived • Server
    • 5. Client • slow loading web page (latency) • slow executing webpage (javascript/css) http://www.flickr.com/photos/7423510@N06/2984486385/
    • 6. The Enemy Latency: It’s a bitch
    • 7. The Enemy http://www.flickr.com/photos/peterhaza/3492771467/ Latency: It’s a bitch
    • 8. Diagnostic Tools (Client) • Firebug • YSlow • PageSpeed • UserTime
    • 9. Diagnostic Tools (Client) • Firebug • YSlow • PageSpeed • UserTime
    • 10. Diagnostic Tools (Client) • Firebug • YSlow • PageSpeed • UserTime
    • 11. Diagnostic Tools (Client) • Firebug • YSlow • PageSpeed • UserTime
    • 12. Reducing Roundtrips • CSS Sprites • CSS Data URIs • Jammit • Rails *_link_tag http://www.flickr.com/photos/mezzoblue/3217540317/
    • 13. 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
    • 14. 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" />
    • 15. HTTP Hacking for Fun and Profit • Off with her <HEAD> • Expires: • Last-Modified: • ETag: • Content-Encoding:
    • 16. Server • registers • memory • network • database • disk • APIs http://www.flickr.com/photos/buro9/298998011/
    • 17. Infrastructure • squid 2.7 • varnish • memcached • redis / resque
    • 18. Top Clones • top • htop • mytop • memcache-top
    • 19. Top Clones • top • htop • mytop • memcache-top
    • 20. Top Clones • top • htop • mytop • memcache-top
    • 21. Top Clones • top • htop • mytop • memcache-top
    • 22. Monitoring -- free • nagios • cacti • zabbix • zenoss (core)
    • 23. Monitoring -- free • nagios • cacti • zabbix • zenoss (core)
    • 24. Monitoring -- free • nagios • cacti • zabbix • zenoss (core)
    • 25. Monitoring -- free • nagios • cacti • zabbix • zenoss (core)
    • 26. Monitoring -- paid • Pingdom Text • NewRelic • Scout
    • 27. Monitoring -- paid • Pingdom • NewRelic • Scout
    • 28. Monitoring -- paid • Pingdom • NewRelic • Scout
    • 29. Fixing Problems • Performance is a moving target! • Horizontal/ Vertical scaling http://www.flickr.com/photos/tpapi/2765541278/
    • 30. NewRelic Workflow • Web Transactions • Most Time Consuming • Slowest Average Response Time • Database
    • 31. And the Number One Ruby on Rails Performance Problem Is ...
    • 32. And the Number One Ruby on Rails Performance Problem Is ... N+1 Select
    • 33. 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?
    • 34. 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?
    • 35. Plugins/Gems • bullet • slim_scrooge • query_reviewer • ambitious_query_indexer • ActiveRecord::Extensions
    • 36. Still not fast enough for ya? • ruby-prof • memprof - where are objects being created • change interpreters • ree -- gc.enable stats • jruby • ruby 1.9
    • 37. 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
    • 38. Tools • http://documentcloud.github.com/jammit/ • http://jeremy.zawodny.com/mysql/mytop/ • http://htop.sourceforge.net/ • http://code.google.com/p/memcache-top/
    • 39. 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.
    • 40. Rails caching model
    • 41. Template rendering pain
    • 42. Database Model Fields • wasteful data types • varchars •
    • 43. Evented API calls

    ×