Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Basics of Web Performance Measurement

Ankit Solanki
September 15, 2016

Basics of Web Performance Measurement

Ankit Solanki

September 15, 2016
Tweet

More Decks by Ankit Solanki

Other Decks in Technology

Transcript

  1. Cheatsheet for the talk 1. Knowing your user 2. Understanding

    what you are measuring 3. DIY – you and your devtools 4. “Real User Monitoring”, 
 or actually measuring in the real world
  2. Networking • First page load • DNS lookup for your

    hostname • TCP connection handshake (40-500ms) • SSL negotiation (40-500ms)
  3. Networking • What you can do for performance • Host

    in India! • Use CDNs • Reduce re-directs
  4. Backend • (Homework assignment) • Main suggestion: look at distribution

    of response times. • Look at outliers: 90percentile, 95p, 99p
 (averages are a lie)
  5. Not a linear process • DOM processing starts as soon

    as response bytes come in • Any CSS or synchronous scripts will cause other resources to be loaded, while stalling the page load process • Browser may render parts of your page before any of these events fire (may lead to flash of unstyled text)
  6. Parse HTML Execute Scripts Build DOM Build CSS OM Layout

    Paint (loading resources as required) JavaScript Layout Paint
  7. What to look for • First, look at content sizes

    • Optimise images, reduce no. of images if possible • Gzip is your friend (just a flag, enable it!) • Cache headers • Fonts, External JavaScript, Size of CSS / JS
  8. Your Critical Rendering Path • Basically, time to first paint

    • Skip what you can, defer if possible • Hard (fun) problem for SPA
  9. • Supported on all modern browsers 
 [caniuse.com/#feat=nav-timing] • Enabled

    by default by Google Analytics • But it’s in sampling mode by default (1% of sessions only) • You can set to 100% if need be
 
 ga('create', 'UA-XXX-Y', {'siteSpeedSampleRate':100});
  10. • Looking at your distribution, not averages • Averages skew

    your data • Focus on percentiles to get real insights
  11. • Limitations of Google Analytics • Aggregate data • Sampled

    data • Difficult to debug individual cases (follow a single user’s journey) • Sometimes best to get on a remote desktop session with the user, if at all possible
  12. • Some recommendations • Build dashboards • Set up alerts

    • Look at historical performance • Study performance impact of changes
  13. • Other RUM tools • New Relic • Pingdom •

    Open source, or building your own?
  14. User Timings • Timings for events after page load •

    Especially critical if you are building a frontend app • Options • W3 standard: User Timing API • Tool specific: Google Analytics API, for example
  15. User Timings in GA • ga('send',
 'timing',
 [timingCategory],
 [timingVar],
 [timingValue]);

    • Example:
 
 ga('send', 'timing', 'ChatBox', 'connect', 3549);
  16. • Know your user, know your application, and you should

    be able to figure out what you actually need to focus on • Tackle problems as you can see them – different mindsets for a 2-person startup (optimise for development speed) vs. a mature product • It’s an art, being informed lets you make the tradeoffs deliberately • Performance is critical, but not the end goal. 
 Usage is the end goal.
  17. Q&A

  18. Resources • W3 Navigation Timing API • Performance section on

    Google Web Fundamentals site • Ilya Grigorik’s blog, and various talks, and books. • User Timings in Google Analytics