improving the performance of Rails web Applications


Published on

This presentation is the first in a series on Improving Rails application performance. This session covers the basic motivations and goals for improving performance, the best way to approach a performance assessment, and a review of the tools and techniques that will yield the best results. Tools covered include: Firebug, yslow, page speed, speed tracer, dom monster, request log analyzer, oink, rack bug, new relic rpm, rails metrics,, msfast, and

The upcoming sessions will focus on:
Improving sql queries, and active record use
Improving general rails/ruby code
Improving the front-end

And a final presentation will cover how to be a more efficient and effective developer!

This series will be compressed into a best of session for the 2010 conference

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

  • Question:
    How does performance matter for your app?
  • i took out a few words to make it fit
  • shopzilla
    8000 requests per second
    parallel downloads alone lead to a 0.5% increase in topline revenue
    info and graphs from

  • 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

  • performance is how long a singe job takes
    scalability is how many jobs you can handle
  • most performance issues are at the page level, though we tend to emphasize optimizing the app and DB first

  • empty cache
    primed cache
    time to load

  • Shows you all the browser’s actions
    requests, parsing, blocking, rendering, reflow, ajax

    Chrome tool
  • 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

  • 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

  • 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

  • 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

  • run it local
  • there are other tools like scout and fiveruns

  • work as a team to spread the knowledge and make sure performance issues don’t sneak back in

  • improving the performance of Rails web Applications

    1. 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. 2. Why does performance matter? • Revenue • Costs • Time • Competition • User satisfaction
    3. 3. 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. "
    4. 4. When should I start caring? • Capacity planning • Design • Growth • Development • Testing • Deployment • Monitoring
    5. 5. What am I tracking? Business Metrics • Page visits per day • Page visits per user per day • Time on site • Searches performed • Products views • Orders
    6. 6. SHOPZILLA Improving from 6 sec down to 1.2 seconds 6
    7. 7. Netflix: 43% drop in outbound traffic after enabling gzip 7
    8. 8. Making a business case
    9. 9. So we know that performance matters. Now what? 9
    10. 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. 11. 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
    12. 12. Eyeball it Processing UserSessionsController#new (for 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. 13. Log analyzer gem install request-log-analyzer request-log-analyzer log/development.log
    14. 14. Yslow
    15. 15. Page Speed
    16. 16. Speed Tracer
    17. 17. Microsoft tools – Dynatrace – MsFast – VRTA – Fiddler – Developer tools
    18. 18. Dom Monster 18
    19. 19. 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?
    20. 20. External tools – – – – – – –
    21. 21. 21
    22. 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. 23. Taking multiple measurements – Monitor performance over time – Manually keep an eye on your yslow/resp time – – Apache Bench, Httperf – Jmeter
    24. 24.
    25. 25. New Relic
    26. 26. New Relic
    27. 27. Rails Metrics 27
    28. 28. Rack Bug 28
    29. 29. 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
    30. 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. 31. Upcoming Presentations – Chicago Javascript – Improving Page performance – ChicagoRuby – Improving Rails app performance – Improving Developer performance! – WindyCityRails 2010 – Improving Rails Application Performance – twitter: @j_mccaffrey
    32. 32. References – (me) – Railslab – Steve Souders – – – – –
    33. 33. References • 33