KEMBAR78
improving the performance of Rails web Applications | KEY
Performance Monitoring
      John McCaffrey
1. Why does performance matter?
2. Know your Business Metrics
3. Quick ways assess application performance
4. Monitoring tools to help you track performance
Why does performance matter?
•   Revenue
•   Costs
•   Time
•   Competition
•   User satisfaction
Why does performance matter?
• Google cares!
• "Speeding up websites is important .. faster sites don't
  just improve user experience...improving site speed also
  reduces operating costs. Like us, our users place a lot of
  value in speed - that's why we've decided to take site
  speed into account in our search rankings. "
When should I start caring?
•   Capacity planning
•   Design
•   Growth
•   Development
•   Testing
•   Deployment
•   Monitoring
What am I tracking?
Business Metrics

•   Page visits per day
•   Page visits per user per day
•   Time on site
•   Searches performed
•   Products views
•   Orders
SHOPZILLA

            Improving
            from 6 sec
            down to
            1.2
            seconds




               6
Netflix:
43% drop in outbound traffic
after enabling gzip




                               7
Making a business case
So we know that performance matters.
Now what?




                                   9
Performance Terms
Latency    = seconds per job, or "how long it takes"
Throughput = jobs per second, or "how many workers"

Average Response time = average latency
Requests per second = average throughput

If 1 worker that can compute 1 job in .5 sec
       latency = .5 secs per job
       throughput = 2 jobs per sec
Quick ways to check your stats
• Eyeball the log files
• Use Log reading tool
• Use browser tools
  o Confirm your dev env vs staging
• External site tests
  o Compare values outside of your network
  o Repeatable tests
Eyeball it
 Processing UserSessionsController#new (for 127.0.0.1 at
2010-05-15 10:11:09) [GET]
  Parameters: {"action"=>"new", "controller"=>"user_sessions"}
Rendering template within layouts/login
Rendering user_sessions/new
Completed in 202ms (View: 105, DB: 42) | 200 OK [http://localhost/
login]
Log analyzer
gem install request-log-analyzer
request-log-analyzer log/development.log
Yslow
Page Speed
Speed Tracer
Microsoft tools
– Dynatrace
– MsFast
– VRTA
– Fiddler
– Developer tools
Dom Monster




http://javascriptrocks.com/performance/



                                          18
Are these numbers right?
•   Are they consistent?
•   Do they seem reasonable
•   How can we repeat the tests?
•   Can we reproduce them in all environments?
•   What should we investigate next?
External tools
– http://zoompf.com
– http://webo.name/
– http://tools.pingdom.com/
– http://gtmetrix.com
– http://www.webpagetest.org/
– http://www.site-perf.com/
– http://webwait.com
GtMetrix.com




               21
Don’t change anything!
– Resist the urge to change a bunch of stuff
– Test coverage
– repeatable perf tests
– don't break anything!
– focus on low hanging fruit first
– get your monitoring in place before you make any
  major changes
– don't make it less maintainable
– pair & share
Taking multiple measurements
– Monitor performance over time
– Manually keep an eye on your yslow/resp time
– http://loadimpact.com/
– Apache Bench, Httperf
– Jmeter
showslow.com




http://127.0.0.1/showslow/
New Relic
New Relic
Rails Metrics




                27
Rack Bug




           28
Now What?
– Summarize and describe your observations
– Prioritize based on ease of change and expected
  impact
– Make your changes in a branch
– Compare your results
– Look for patterns of optimization
– Work with your team
Nuggets of Wisdom
•   Gzip
•   Get very familiar with yslow
•   Look through your logs, analyze them
•   Turn on slow query logging for db
•   Upgrade your libraries (js, plugins)
•   Use RVM (try new plugins, rails, ruby)



                                             30
Upcoming Presentations
– Chicago Javascript
   – Improving Page performance

– ChicagoRuby
   – Improving Rails app performance
   – Improving Developer performance!

– WindyCityRails 2010
   – Improving Rails Application Performance

– twitter: @j_mccaffrey
References
– http://railsperformance.blogspot.com/ (me)
– Railslab http://railslab.newrelic.com/
– Steve Souders http://www.stevesouders.com/blog/
– http://velocityconference.blip.tv/
– http://code.google.com/events/io/2010/
–   http://speedgeeks-la.blip.tv/
–   http://developer.yahoo.com/performance/
–   http://code.google.com/speed/page-speed
References
• http://guides.rubyonrails.org/performance_testing.html




                                                           33

improving the performance of Rails web Applications

  • 1.
    Performance Monitoring John McCaffrey 1. Why does performance matter? 2. Know your Business Metrics 3. Quick ways assess application performance 4. Monitoring tools to help you track performance
  • 2.
    Why does performancematter? • Revenue • Costs • Time • Competition • User satisfaction
  • 3.
    Why does performancematter? • Google cares! • "Speeding up websites is important .. faster sites don't just improve user experience...improving site speed also reduces operating costs. Like us, our users place a lot of value in speed - that's why we've decided to take site speed into account in our search rankings. "
  • 4.
    When should Istart caring? • Capacity planning • Design • Growth • Development • Testing • Deployment • Monitoring
  • 5.
    What am Itracking? Business Metrics • Page visits per day • Page visits per user per day • Time on site • Searches performed • Products views • Orders
  • 6.
    SHOPZILLA Improving from 6 sec down to 1.2 seconds 6
  • 7.
    Netflix: 43% drop inoutbound traffic after enabling gzip 7
  • 8.
  • 9.
    So we knowthat performance matters. Now what? 9
  • 10.
    Performance Terms Latency = seconds per job, or "how long it takes" Throughput = jobs per second, or "how many workers" Average Response time = average latency Requests per second = average throughput If 1 worker that can compute 1 job in .5 sec latency = .5 secs per job throughput = 2 jobs per sec
  • 11.
    Quick ways tocheck your stats • Eyeball the log files • Use Log reading tool • Use browser tools o Confirm your dev env vs staging • External site tests o Compare values outside of your network o Repeatable tests
  • 12.
    Eyeball it ProcessingUserSessionsController#new (for 127.0.0.1 at 2010-05-15 10:11:09) [GET] Parameters: {"action"=>"new", "controller"=>"user_sessions"} Rendering template within layouts/login Rendering user_sessions/new Completed in 202ms (View: 105, DB: 42) | 200 OK [http://localhost/ login]
  • 13.
    Log analyzer gem installrequest-log-analyzer request-log-analyzer log/development.log
  • 14.
  • 15.
  • 16.
  • 17.
    Microsoft tools – Dynatrace –MsFast – VRTA – Fiddler – Developer tools
  • 18.
  • 19.
    Are these numbersright? • Are they consistent? • Do they seem reasonable • How can we repeat the tests? • Can we reproduce them in all environments? • What should we investigate next?
  • 20.
    External tools – http://zoompf.com –http://webo.name/ – http://tools.pingdom.com/ – http://gtmetrix.com – http://www.webpagetest.org/ – http://www.site-perf.com/ – http://webwait.com
  • 21.
  • 22.
    Don’t change anything! –Resist the urge to change a bunch of stuff – Test coverage – repeatable perf tests – don't break anything! – focus on low hanging fruit first – get your monitoring in place before you make any major changes – don't make it less maintainable – pair & share
  • 23.
    Taking multiple measurements –Monitor performance over time – Manually keep an eye on your yslow/resp time – http://loadimpact.com/ – Apache Bench, Httperf – Jmeter
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
    Now What? – Summarizeand describe your observations – Prioritize based on ease of change and expected impact – Make your changes in a branch – Compare your results – Look for patterns of optimization – Work with your team
  • 30.
    Nuggets of Wisdom • Gzip • Get very familiar with yslow • Look through your logs, analyze them • Turn on slow query logging for db • Upgrade your libraries (js, plugins) • Use RVM (try new plugins, rails, ruby) 30
  • 31.
    Upcoming Presentations – ChicagoJavascript – Improving Page performance – ChicagoRuby – Improving Rails app performance – Improving Developer performance! – WindyCityRails 2010 – Improving Rails Application Performance – twitter: @j_mccaffrey
  • 32.
    References – http://railsperformance.blogspot.com/ (me) –Railslab http://railslab.newrelic.com/ – Steve Souders http://www.stevesouders.com/blog/ – http://velocityconference.blip.tv/ – http://code.google.com/events/io/2010/ – http://speedgeeks-la.blip.tv/ – http://developer.yahoo.com/performance/ – http://code.google.com/speed/page-speed
  • 33.

Editor's Notes

  • #3 Question: How does performance matter for your app?
  • #4 i took out a few words to make it fit http://googlewebmastercentral.blogspot.com/2010/04/using-site-speed-in-web-search-ranking.html http://www.websiteoptimization.com/speed/tweak/page-speed-search-rankings/
  • #5 http://www.getelastic.com/when-to-performance-test/
  • #6 http://www.getelastic.com/when-to-performance-test/
  • #7 shopzilla 8000 requests per second parallel downloads alone lead to a 0.5% increase in topline revenue info and graphs from http://www.phpied.com/the-performance-business-pitch/
  • #9 its not just about making things fast for the developers enjoyment or pride it has to be worth it from a business point of view
  • #11  performance is how long a singe job takes scalability is how many jobs you can handle
  • #12 most performance issues are at the page level, though we tend to emphasize optimizing the app and DB first http://tools.pingdom.com/ http://www.site-perf.com/
  • #15 empty cache primed cache score time to load rules
  • #17 Shows you all the browser’s actions requests, parsing, blocking, rendering, reflow, ajax Chrome tool http://code.google.com/webtoolkit/speedtracer/get-started.html
  • #18 I would start with firefox and chrome tools first, even if your users are primarily IE, because there is more help with those tools check your site with the IE tools to see if the numbers match
  • #20 Use the external site tools, or the internal browser tools as a sniff test. Its a quick way to get you thinking about what you should be looking into, but don't make any changes yet. Document your findings
  • #21 http://tools.pingdom.com/ http://www.site-perf.com/
  • #24 run the tests a few times against multiple environments write down what numbers you got on which day (maybe iTunes free music day really kills the bandwidth in your office) add some load http://www.xenoclast.org/autobench/ httperf
  • #25 you can can fool it with a change to your hosts file you can store just your info locally, if you aren’t cool with sending your data to another site you want to customize
  • #26 run it local
  • #27 there are other tools like scout and fiveruns
  • #30 work as a team to spread the knowledge and make sure performance issues don’t sneak back in