Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

RVA JS '18 - Measuring Latency in SPAs

RVA JS '18 - Measuring Latency in SPAs

This talk will introduce the hurdles of application performance measurement and why this topic is important. We'll compare & contrast multiple options, pointing out the pitfalls along the way. Finally, we'll touch on how to implement latency tracking using real-world applications and leave the audience with the tools to confidently gather the data they need to optimize their applications.

Jordan Hawker

November 02, 2018
Tweet

More Decks by Jordan Hawker

Other Decks in Technology

Transcript

  1. November 2018 Jordan Hawker 2 Performance: Why Do We Care?

    Poor performance impacts business metrics – Bounce Rates – Conversions – Feature Throughput – Revenue Impact – User Satisfaction
  2. November 2018 Jordan Hawker 3 Instrumentation Before Optimization • You

    don’t know what to optimize without data • Backend Instrumentation – Mature instrumentation options – Detailed information about services – Doesn’t provide the full picture • Can we track performance across the whole stack?
  3. November 2018 Jordan Hawker 4 Web Application Performance • Response

    Time • Throughput • Availability • Responsiveness • Rate of Requests • Resource Consumption • Efficiency • Latency What does that even mean?
  4. November 2018 Jordan Hawker 6 Priority: User Experience • Each

    metric has its own use, but... • Real-world performance impact is paramount – Know what your users are seeing – Gather data on different devices and browsers – Understand variance across global regions • Improvements across the stack will be reflected
  5. November 2018 Jordan Hawker 7 Time To Interactivity The time

    it takes for the critical content of a page to load such that the user believes they can engage in their primary purpose visiting that page.
  6. November 2018 Jordan Hawker 12 Evaluating Third-Party Tools • They

    give great overviews of app performance • Detailed suggestions for optimization • They don’t understand how SPAs render • Data is a rough approximation at best • How can we leverage framework internals?
  7. November 2018 Jordan Hawker 14 Critical Path • Each page

    has primary activities • Components related to that content are “critical” • Secondary components – Also rendered on the page – Not tied to the primary activity – Don’t need to finish rendering
  8. November 2018 Jordan Hawker 15 DOM Is A Tree •

    ...and so are your apps! • Pages are nested layers of components • Each route or component has direct children • Components with no children are “leafs” • Each component waits on its children to render
  9. November 2018 Jordan Hawker 16 Subscriber-Reporter Relationship • Subscriber –

    Relies on child components (reporters) to render – Complex conditions for interactivity • Reporter – Reports its own render times – Child of a subscriber – May also be a subscriber itself
  10. November 2018 Jordan Hawker 18 Approach • Leverage hooks to

    approximate rendering • Account for async behavior (e.g. requests, images) • Capture per-component events & roll up to page • Tie parents to their children to bubble data – Working up from the bottom of the tree is optimal – When child reports, check parent for interactivity • Common method to check complex conditions
  11. November 2018 Jordan Hawker 19 React • componentDidMount – Invoked

    immediately after a component is mounted • Create a higher-order component (HOC) – Provides components with this latency behavior • Parent/Child relationship – this.props.children gives access to child components – Pass a parent reference down to children
  12. November 2018 Jordan Hawker 20 Ember • Routes: didTransition •

    Components: didInsertElement • Leverage Runloop – run.scheduleOnce('afterRender', this, this.reportInteractive) • Parent/Child Relationship – this.parentView is a direct reference to the parent • Ember-Interactivity: jhawk.co/interactivity-demo
  13. November 2018 Jordan Hawker 21 Angular • ngAfterContentInit – Called

    after Angular fully initializes all content of a directive • Parent/Child Relationship – this.parentInjector.view.component
  14. November 2018 Jordan Hawker 22 Vue • mounted – Called

    after the instance has been mounted • this.$nextTick – Called after all children have been rendered • Parent/Child Relationship – this.$parent
  15. November 2018 Jordan Hawker 24 Performance API • Browser interface

    that provides performance info • performance.mark – Creates a timestamp in the performance buffer • performance.measure – Creates a measure between two timestamps • Data can be inspected, tracked, and visualized
  16. November 2018 Jordan Hawker 29 What We Learned • Define

    Critical Path • Identify Bottleneck Components • Defer Non-Critical Components • Holistic user-centric metrics reflect improvements across the stack
  17. November 2018 Jordan Hawker 30 The Path Forward • Leverage

    multiple tools for instrumentation • Measuring each layer of the stack is useful • Capture real user metrics to understand impact • Virtual machines are insufficient simulations • Use framework-aware tools for granular data • Be cognizant of the performance impact of leveraging framework internals