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

Measuring and Optimizing Front-End Web Performance

Measuring and Optimizing Front-End Web Performance

A quick tour through the tools, techniques and things to look out for in order to deliver a fast web experience. We will cover a broad range of topics including:

* Reporting the performance of users visiting your sites
* New browser primitives that provide incredible insight and diagnostics as well as upcoming specs to be aware of
* Testing for web performance
* Best practices around what to measure and how
* Practical hands-on examples with WebPageTest
* What it takes to deliver a visually fast experience
* Implications for mobile
* What changes with HTTP/2
* CDN's
* Third-Party code (Ads, Analytics, Social, etc)

DevOpsDays DC

June 11, 2015
Tweet

More Decks by DevOpsDays DC

Other Decks in Technology

Transcript

  1. Back-end DNS Lookup (28ms) Socket Connect (93ms) HTTP Request (85ms)

    Response Download (48ms) HTTP Request – Socket Connect = Back End Time Shoot for < 100ms
  2. Access Logs FTW! ▪ Tons of “free” data: ▪ Timestamp ▪ Region (IP

    Lookup) ▪ ISP (IP Lookup) ▪ OS ▪ Browser ▪ Mobile Device ▪ Page (Referer) ▪ Add metrics as URL query params
  3. Measurement best-practices ▪  Instrument the user experience ▪  onload (page

    load time) is a horrible metric ▪  window.performance.mark() ▪  Prefer user experience/visual metrics ▪  Speed Index ▪  Time to start render ▪  “Time to first tweet” ▪  “Time to first pin”
  4. In-flight W3C Specs ▪  Network Error Logging ▪  http://www.w3.org/TR/network-error-logging/ ▪ 

    Beacon failed requests (policy specified in headers) ▪  Server Timing ▪  http://www.w3.org/TR/server-timing/ ▪  Add metrics to HTTP response header ▪  Metrics exposed to javascript
  5. One Second Pages on Mobile ▪  300ms+ RTT ▪  DNS

    Lookup + Socket Connect + Request RTT = 900ms ▪  Payload to display above-the-fold content needs to be in first 15KB ▪  Assumes modern server with Initial Congestion Window of 10 ▪  No external resources in the head ▪  inline critical css for above-the-fold ▪  Load full external css later in the body ▪  Scripts at the end of the body (or async if possible)
  6. HTTP/2 ▪  Requires HTTPS (in practice) ▪  Multiplexes same-origin requests

    over single connection ▪  Coalesces connections if alt-name matches and DNS resolves to same IP ▪  Makes a few historical best-practices anti-patterns ▪  Domain sharding ▪  Script/css combining ▪  Image sprites ▪  Servers need to implement priotitization/dependencies ▪  Chrome disables all resource scheduling and sends all requests to server immediately
  7. Fast TLS Negotiation ▪  Can be done in 1 RTT

    ▪  OCSP Stapling (avoid revocation checks) ▪  Implement NPN/ALPN ▪  Even if not advertising HTTP/2 ▪  Enables TLS False Start in Chrome/Firefox ▪  Advertise PFS ciphers ▪  Enables TLS False Start in Safari ▪  Watch certificate chain sizes (relative to initial congestion window) ▪  Update your server (older versions of nginx/HAProxy are bad with > 4KB certs) ▪  Tune TLS buffer sizes https://istlsfastyet.com/
  8. Service workers ▪  Javascript-programmable site-wide MITM ▪  Sees every request

    from all pages on service-worker origin/scope ▪  Including cross-origin requests ▪  And the headers ▪  Can synthesize responses ▪  Supports fetch ▪  Has a programmable cache and Indexed DB ▪  HTTPS only