owning web performance

49
Owning Web Performance @wesleyhales

Upload: wesley-hales

Post on 11-Apr-2017

303 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Owning Web Performance

Owning Web Performance@wesleyhales

Page 2: Owning Web Performance

How long does it take the page to load?

@wesleyhales

Page 3: Owning Web Performance

What are we measuring?

@wesleyhales

Page 4: Owning Web Performance

The Perception of (Load) TimeSpeedperception.org

Page 5: Owning Web Performance

@wesleyhales

How the web perf industry “thinks” users interact with our page.

Page 6: Owning Web Performance

The average attention span of a human being dropped from 12 seconds in 2000 to 8.25 seconds in 2015.

- National Center for Biotechnology Information at the US National Library of Medicine

Page 7: Owning Web Performance

//Chromewindow.chrome.loadTimes().startLoadTime;

//IEwindow.performance.timing.msFirstPaint

Start render is measured by capturing video of the page load and looking at each frame for the first time the browser displays something other than a blank page.

Or…

Start Render / First Paint

Page 8: Owning Web Performance

Document Complete

What it means depends highly on what the page actually does. For example:

“The page was completely blank at onloadand the content was all rendered afterward in JavaScript”

https://www.webpagetest.org/forums/showthread.php?tid=13266

Page 9: Owning Web Performance

Critical ResourcesThe main blockers to fast rendering are stylesheets and synchronous scripts.

Stylesheets block all rendering in the page until they finish loading.

Synchronous scripts (e.g., <script src="main.js">) block rendering for all following DOM elements.

Synchronous scripts in the HEAD of the page block the entire page from rendering until they finish loading.

https://www.stevesouders.com/blog/2016/02/10/critical-metric-critical-resources/

Page 10: Owning Web Performance

a bug:fire drill when things are broken

a criteria at all stages:UX → development → production

a continuous process:Monitoring → learning → improvement

Performance is…

Page 11: Owning Web Performance

Fast is good… Faster is better

Google Dev Summit

@wesleyhales

Page 12: Owning Web Performance

Performance Reality

@wesleyhales

Page 13: Owning Web Performance

@wesleyhales

Happy Place

Page 14: Owning Web Performance

We can’t get to a happy place without monitoring…

@wesleyhales

Page 15: Owning Web Performance

Local vs. Remote Monitoring

@wesleyhales

Page 16: Owning Web Performance

Local vs. Remote Monitoring

@wesleyhales

Real User Monitoring (RUM)

• Provides a restricted subset of performance API’s and metrics.

• It’s restricted because such data may reveal private or sensitive information about the visitor.

Page 17: Owning Web Performance

Local vs. Remote Monitoring

@wesleyhales

Just because something is possible to measure, and perhaps is even highly desirable and useful to many developers, does not mean that it can be exposed as a RUM API.

Page 18: Owning Web Performance

http://bit.ly/29obv1d

Page 19: Owning Web Performance

What can we measure (remotely)?

@wesleyhales

Performance Timing APIs

• Performance Timeline• HR Time• Navigation Timing• Resource Timing• User Timing• Frame Timing• Server Timing

Page 20: Owning Web Performance

Navigation Timing API(The starting point of Web

Performance APIs)

@wesleyhales

Page 21: Owning Web Performance

@wesleyhales

Browser Support

Page 22: Owning Web Performance

http://www.w3.org/2015/10/webperf-all.html

Advance Browser Support

Page 23: Owning Web Performance

Navigation is about how user agents convert the requested

HTML, CSS, and JavaScript into rendered pixels, which is one of the most critical steps for users

to navigate a document.

@wesleyhales

From the spec…

Page 24: Owning Web Performance

window.performance.timingsimple-new.html

@wesleyhales

Page 25: Owning Web Performance

Measurements are in HRT

• All measurements are at microsecond precision.

• Does not depend on system clock or DOM processing

• Example: perf.now.html

performance.now()

@wesleyhales

Page 26: Owning Web Performance

window.performance.timing process model

@wesleyhales

Page 27: Owning Web Performance

Loadreport.js (2012-2015)

Page 28: Owning Web Performance

Same Pattern?

@wesleyhales

Page 29: Owning Web Performance

Browser without a UI

Able to run in a server environment

Intended for testing and automation

Headless Mode

@wesleyhales

Page 30: Owning Web Performance

Released Early 2015

Headless Web Browser

Based on WebKit

PhantomJS 2

@wesleyhales

Page 31: Owning Web Performance

Pros/Cons

Limited support for modern web features

No auto updates

Great for Continuous Integration!

PhantomJS 2

@wesleyhales

Page 32: Owning Web Performance

PhantomJS 2 Feature Detect

Page 33: Owning Web Performance

What About Headless Chrome?

https://www.youtube.com/watch?v=GivjumRiZ8c

Page 34: Owning Web Performance

Basic PhantomJS Scripts

@wesleyhales

Page 35: Owning Web Performance

@wesleyhales

Page 36: Owning Web Performance

Rewrite of loadreport.js

Leverages all implemented Navigation Timing APIs

(shims resource timing)

Speedgun.js

Page 37: Owning Web Performance

Speedgun.jsDemo normal and spider

@wesleyhales

Page 38: Owning Web Performance

@wesleyhales

Speedgun.io

Speedgun.js

Wrapper runs script on System out

Page 39: Owning Web Performance

@wesleyhales

Speedgun.io

Speedgun.js

Wrapper provides API

/go

/report

/beacon

/nodes

Page 40: Owning Web Performance

@wesleyhales

Speedgun.io

Speedgun.js

Wrapper provides API

/rest/performance/go?url=www.google.com

/rest/performance/report?uuid=629901

/rest/beacon/init

/rest/beacon/getlist

Page 41: Owning Web Performance

@wesleyhales

Speedgun.io

Speedgun.js

API Wrapper/go

/report

/beacon

/nodes

Docker Container

Page 42: Owning Web Performance

@wesleyhales

Speedgun.io

Speedgun.js

API Wrapper

Docker Container Docker Container

Postgres

Page 43: Owning Web Performance

@wesleyhales

Speedgun.jsDemo

Page 44: Owning Web Performance

Synthetic RUM

• Use Speedgun.io as centralized server

• All docker nodes send beacon with:• Current container CPU and

memory usage

• API demo...

http://wesleyhales.com/blog/2015/04/24/Speedgun/

Page 45: Owning Web Performance

Continuous Perf Monitoring

• Use Speedgun.io as centralized server

• All docker nodes send beacon with:• Current container CPU and

memory usage

• API demo...

Page 46: Owning Web Performance

Continuous Perf Monitoring - Local

Page 47: Owning Web Performance

Continuous Perf Monitoring - Remote

Page 48: Owning Web Performance

Thanks!!• speedgun.io (github)• Navigation Timing API• Navigation Timing 2• Resource Timing API• http://w3c.github.io/perf-timing-primer/

@wesleyhales

Page 49: Owning Web Performance

Perf Side Note: Browser Interventions

• Removing active scroll listeners• Blocking document.write• Throttling timers in background frames• Immediately fallback to system fonts on slow

connections• Lazy load images