SlideShare une entreprise Scribd logo
1  sur  32
Making Single Page Apps Faster
Manuel Alvarez
Enterprise Architect
@MD_A13
Boris Livshutz
Senior Enterprise Architect
@livshitz98
©2016 AKAMAI | FASTER FORWARDTM
• New way to build on the web
• Growing popularity
• Single HTML page
• Navigation using JavaScript, APIs
• Causes performance degradation
• We are here to help!
• Choosing the right framework for
Performance
• Make your SPA perform faster
• Monitor SPA’s performance
Builtwith Data
Why are we talking about SPA today?
©2016 AKAMAI | FASTER FORWARDTM
Choosing the Right Framework
©2016 AKAMAI | FASTER FORWARDTM
SPA and the MVC Architecture
Years of architecture evolution:
• SOFEA: Service-Oriented Front-End
Architecture (2007)
• JavaScript, flash, and AJAX
• MV-X architectures are designed to
separate the view from the model
• Server-side developer focus on business logic
• The client is developed separately, allowing
code reuse for SPA, native apps, SOA, etc.
Model View Controller
View
Model
Controller
Fires Event
(Updates)
Passes
Calls to
Modifies
Image from Rohit Ghatol
©2016 AKAMAI | FASTER FORWARDTM
Current SPA trends
Metric AngularJS Angular 2 Backbone.js Ember.js React.js
Stars on
Github
48k 10k 24k 16k 39k
Commits 7k 4k 3k 18k 6k
StackOverflow
Questions
174k 11k 19k 19k 18k
GitHub
Contributors
1,426 219 282 569 645
Compresses sizes if you are curious
©2016 AKAMAI | FASTER FORWARDTM
• Easy to start, great community support,
and does not have dependencies
• Not very good partnering with 3rd party
JavaScripts
• Great for “ambitious” web apps
• It has dependencies on handlebars and
jQuery
• Handlebars uses <script> tags as
markers, increasing DOM complexity
• It uses the Virtual DOM to minimize real
DOM changes
• React is only the view layer
• It has a minimalistic approach and it
has good compatibility with other JS
libraries
• Dependencies on Underscore.js and
jQuery
Current SPA trends
©2016 AKAMAI | FASTER FORWARDTM
What is the right framework?
Stefan Krause
©2016 AKAMAI | FASTER FORWARDTM
Angular 1 Angular 2 Ember.js React.js
Create 1k
rows (ms)
249.56 192.38 747.01 201.17
Append 1k
rows (ms)
826.88 679.67 729.01 344.25
Clear 10k
rows (ms)
840.63 436.54 1,182.97 2,027.88
Memory (on
load) MB
4.86 17.05 10.1 5.17
Benchmarks
Stefan Krause
Chris Harrington
How are you using tables if at all?
What are your top browsers?
©2016 AKAMAI | FASTER FORWARDTM
• Research them and read a little code
• Evaluate their capabilities; e.g. testing tools
• Implement them
• Play around http://todomvc.com/
• “Hello world” + common tasks in your top browser
• Can you start from an existing project?
• What you are doing is so unique that it is probably on github 
• Use a decision matrix
What is the right framework?
©2016 AKAMAI | FASTER FORWARDTM
AngularJS Ember React
Learn 10 6 8
Develop 9 8 9
Test 8 9 8
Secure 7 8 4
Build 9 10 9
Deploy 10 10 10
Debug 7 10 7
Scale 9 7 10
Maintain 3 5 4
Share 10 10 10
82 83 79
Filler by Matt Raible - http://akamai.me/1pRfU1g
Evaluate Frameworks
Yevgeniy Brikman’s Framework Scorecard
©2016 AKAMAI | FASTER FORWARDTM
Obstacles to Good Performance
©2016 AKAMAI | FASTER FORWARDTM
Does SPA Make Your Site Faster?
• Yes, for 2nd and subsequent pages (soft / virtual pages)
• No, for 1st page (homepage, landing page, deep link)
• 1st page ruins experience (“judge a book by its cover!”)
• Leads to user abandonment
• Frameworks try to do everything
for everybody, causing
“framework overhead”
©2016 AKAMAI | FASTER FORWARDTM
Framework Overhead - Example
Automatic Initialization in Angular
1. DOMContentLoaded event
triggers Initialization
2. Loads the module associated with
the directive
3. Creates the Application Injector
4. Compiles the DOM with ng-app as
root
5. Framework loads all dynamic
content
©2016 AKAMAI | FASTER FORWARDTM
Performance Dive – Waterfall Analysis
©2016 AKAMAI | FASTER FORWARDTM
Constant Reinstall
• Bootstrap process is equivalent to installation
• Visiting the page again (each new browser context) results on
“reinstalling”
• Deep links (search engines landing page) require bootstrap first and
then repaint the linked page (hard + soft navigation in one!)
©2016 AKAMAI | FASTER FORWARDTM
Mobile Magnifies the Problem
• Cellular network – high
latency on API calls
• Limited memory - large
framework
• Weak CPU – heavy JavaScript
processing
CPU = 800MHz dual-c
Memory = 512MB
SunSpider = ~1880ms
CPU = 2.6GHz quad-c
Memory = 16GB
SunSpider = ~145ms
Table from Ilya Grigorik
©2016 AKAMAI | FASTER FORWARDTM
SPA Performance Solutions
©2016 AKAMAI | FASTER FORWARDTM
Light First Visit
• First visit does not have the framework in cache
• Serve a “skeleton” that looks like the real page
but with a reduced version of the framework
• Execute the full framework later
• On the second page
• When user clicks
• Async execution
• Pre-render
©2016 AKAMAI | FASTER FORWARDTM
Server Side Rendering
• Isomorphic App - both Server and client rendering
• Step 1: Server renders page into HTML
• Step 2: Client Side rendering but no impact to perceived timing
• Framework Support
• React - Native support
• AngularJS - Version 2.0 has native support
• Backbone.js - Render library
• Ember.js - FastBoot feature
©2016 AKAMAI | FASTER FORWARDTM
Server Side Rendering: Angular
Step by step process in Angular
1. Process the JS on the Server Side
2. Result served to the client as the page HTML
3. Browser renders HTML as standard web page
4. Preboot starts to listen for user clicks since html is not interactive
5. Angular performs all client side bootstrapping in the background
6. As client side bootstrapping is done, it will redraw using new DOM
7. Preboot will now replay all user clicks captured previously.
©2016 AKAMAI | FASTER FORWARDTM
Server Side Rendering: React
Step by step process in React
1. Process the JS on the Server Side
2. Result served to the client as the page HTML
3. Browser renders HTML as standard web page
4. React performs all client side bootstrapping without affecting html page
5. Result is identical to what is already displayed on the page
6. React smartly identifies that no render change is needed
1. DOM is not touched (usually most expensive step)
2. Event Handler hooks are added to the current page
©2016 AKAMAI | FASTER FORWARDTM
Virtual DOM Library
• Direct DOM manipulation causes constant rerender and reflow
• Use Virtual DOM to avoid reflow and rerender
• React.js - builtin virtual DOM along with rendering engine
• 3rd party Virtual DOM libraries - Mercury, Elm, many more
©2016 AKAMAI | FASTER FORWARDTM
JavaScript Packaging
• Choose a Package Manager
• Fits DevOps build process
• Compromise: network
roundtrips vs caching
• Trial and Error to find
compromise
©2016 AKAMAI | FASTER FORWARDTM
Resource Deferment
• Defer and accelerate loading
Javascript
• AMD - Asynchronous Module
Definition API
• WebPack - Code splitting
• RequireJS - dynamic and async
module loader
• Defer images to future pages
• Use Minimized Libraries
©2016 AKAMAI | FASTER FORWARDTM
• Cache more! at browser and Edge
• Cache JSON responses
• Use advance caching features
• Normalize URL parameters
• Enforce uniform ordering of URL
parameters
/weather?lang=20&latitude=47.43&longitude=19.30
/weather?longitude=19.30&latitude=47.43&lang=20
/weather?zipcode=98122&lang=20
/weather?latitude=47.4&longitude=19.3&lang=20
Rationalize + Re-order
API Caching - Optimizations
©2016 AKAMAI | FASTER FORWARDTM
Monitoring and Testing SPA
©2016 AKAMAI | FASTER FORWARDTM
• The onload event no longer matters
• Soft navigations are not real navigations
• The browser won’t tell you when all resources have been downloaded
Monitoring the Wrong Metrics
* How to provide real user monitoring for single-page applications
©2016 AKAMAI | FASTER FORWARDTM
Misleading Metrics
Is that really
Load Time?
©2016 AKAMAI | FASTER FORWARDTM
Recommended SPA KPIs
Key Metrics
• Framework load time
• Interactive Time
• Load Complete time - first and
virtual pages
• Virtual Page Initial Request time
• API call timings
Trending Metrics
• Memory usage over time
• DOM size growth
• Javascript error rate
• Data Transfer rates (bytes fetched
per page/time)
©2016 AKAMAI | FASTER FORWARDTM
Monitoring and Testing Tools That Work
• User Timing API
• Mark and Measure in your code
• Soasta RUM
• Angular, Backbone, Ember
• Performance / Load Testing
• Webdriver Sampler with JMeter
©2016 AKAMAI | FASTER FORWARDTM
SPA Takeaways
• Before you build
• Does SPA make sense for you?
• Design SPA with performance in mind
• Agree on KPIs and SLAs early on
• As you build
• Evaluate Mobile performance
• Stay up to date
• HTTP/2 Server Push
• W3C Fetch Standard
©2016 AKAMAI | FASTER FORWARDTM
Q & A

Contenu connexe

Tendances

A Modern Approach to Performance Monitoring
A Modern Approach to Performance MonitoringA Modern Approach to Performance Monitoring
A Modern Approach to Performance MonitoringCliff Crocker
 
Single page application
Single page applicationSingle page application
Single page applicationArthur Fung
 
Automated Web App Performance Testing Using WebDriver
Automated Web App Performance Testing Using WebDriverAutomated Web App Performance Testing Using WebDriver
Automated Web App Performance Testing Using WebDriverseleniumconf
 
17 Web Performance Metrics You Should Care About
17 Web Performance Metrics You Should Care About17 Web Performance Metrics You Should Care About
17 Web Performance Metrics You Should Care AboutEvgeny Tsarkov
 
Measuring What Matters - Fluent Conf 2018
Measuring What Matters - Fluent Conf 2018Measuring What Matters - Fluent Conf 2018
Measuring What Matters - Fluent Conf 2018Cliff Crocker
 
Single page applications the basics
Single page applications the basicsSingle page applications the basics
Single page applications the basicsChris Love
 
Progressive Web Apps. What, why and how
Progressive Web Apps. What, why and howProgressive Web Apps. What, why and how
Progressive Web Apps. What, why and howRiza Fahmi
 
10 Things You Can Do to Speed Up Your Web App Today
10 Things You Can Do to Speed Up Your Web App Today10 Things You Can Do to Speed Up Your Web App Today
10 Things You Can Do to Speed Up Your Web App TodayChris Love
 
Decoupled Architecture and WordPress
Decoupled Architecture and WordPressDecoupled Architecture and WordPress
Decoupled Architecture and WordPressPantheon
 
EUGM 2014 - Eufrozina Hoffmann (ChemAxon): Smart Drawing with Marvin JS
EUGM 2014 - Eufrozina Hoffmann (ChemAxon): Smart Drawing with Marvin JS  EUGM 2014 - Eufrozina Hoffmann (ChemAxon): Smart Drawing with Marvin JS
EUGM 2014 - Eufrozina Hoffmann (ChemAxon): Smart Drawing with Marvin JS ChemAxon
 
Pump up the JAM with Gatsby
Pump up the JAM with GatsbyPump up the JAM with Gatsby
Pump up the JAM with GatsbyStefan Adolf
 
improving the performance of Rails web Applications
improving the performance of Rails web Applicationsimproving the performance of Rails web Applications
improving the performance of Rails web ApplicationsJohn McCaffrey
 
Windy cityrails performance_tuning
Windy cityrails performance_tuningWindy cityrails performance_tuning
Windy cityrails performance_tuningJohn McCaffrey
 
Next Generation Web Development Techniques with Cloud Foundry
Next Generation Web Development Techniques with Cloud FoundryNext Generation Web Development Techniques with Cloud Foundry
Next Generation Web Development Techniques with Cloud FoundryMalachi Smith
 
Super tools to boost productivity in React dev env!
Super tools to boost productivity in React dev env!Super tools to boost productivity in React dev env!
Super tools to boost productivity in React dev env!Souvik Basu
 
Website Performance
Website PerformanceWebsite Performance
Website PerformanceHugo Fonseca
 
An Angular developer moving to React
An Angular developer moving to ReactAn Angular developer moving to React
An Angular developer moving to ReactSouvik Basu
 
Angular meetup 2 2019-08-29
Angular meetup 2   2019-08-29Angular meetup 2   2019-08-29
Angular meetup 2 2019-08-29Nitin Bhojwani
 

Tendances (20)

A Modern Approach to Performance Monitoring
A Modern Approach to Performance MonitoringA Modern Approach to Performance Monitoring
A Modern Approach to Performance Monitoring
 
Single page application
Single page applicationSingle page application
Single page application
 
Automated Web App Performance Testing Using WebDriver
Automated Web App Performance Testing Using WebDriverAutomated Web App Performance Testing Using WebDriver
Automated Web App Performance Testing Using WebDriver
 
Progressive Web App
Progressive Web AppProgressive Web App
Progressive Web App
 
17 Web Performance Metrics You Should Care About
17 Web Performance Metrics You Should Care About17 Web Performance Metrics You Should Care About
17 Web Performance Metrics You Should Care About
 
Measuring What Matters - Fluent Conf 2018
Measuring What Matters - Fluent Conf 2018Measuring What Matters - Fluent Conf 2018
Measuring What Matters - Fluent Conf 2018
 
Single page applications the basics
Single page applications the basicsSingle page applications the basics
Single page applications the basics
 
Progressive Web Apps. What, why and how
Progressive Web Apps. What, why and howProgressive Web Apps. What, why and how
Progressive Web Apps. What, why and how
 
10 Things You Can Do to Speed Up Your Web App Today
10 Things You Can Do to Speed Up Your Web App Today10 Things You Can Do to Speed Up Your Web App Today
10 Things You Can Do to Speed Up Your Web App Today
 
Decoupled Architecture and WordPress
Decoupled Architecture and WordPressDecoupled Architecture and WordPress
Decoupled Architecture and WordPress
 
EUGM 2014 - Eufrozina Hoffmann (ChemAxon): Smart Drawing with Marvin JS
EUGM 2014 - Eufrozina Hoffmann (ChemAxon): Smart Drawing with Marvin JS  EUGM 2014 - Eufrozina Hoffmann (ChemAxon): Smart Drawing with Marvin JS
EUGM 2014 - Eufrozina Hoffmann (ChemAxon): Smart Drawing with Marvin JS
 
Pump up the JAM with Gatsby
Pump up the JAM with GatsbyPump up the JAM with Gatsby
Pump up the JAM with Gatsby
 
improving the performance of Rails web Applications
improving the performance of Rails web Applicationsimproving the performance of Rails web Applications
improving the performance of Rails web Applications
 
Windy cityrails performance_tuning
Windy cityrails performance_tuningWindy cityrails performance_tuning
Windy cityrails performance_tuning
 
Next Generation Web Development Techniques with Cloud Foundry
Next Generation Web Development Techniques with Cloud FoundryNext Generation Web Development Techniques with Cloud Foundry
Next Generation Web Development Techniques with Cloud Foundry
 
Super tools to boost productivity in React dev env!
Super tools to boost productivity in React dev env!Super tools to boost productivity in React dev env!
Super tools to boost productivity in React dev env!
 
Website Performance
Website PerformanceWebsite Performance
Website Performance
 
An Angular developer moving to React
An Angular developer moving to ReactAn Angular developer moving to React
An Angular developer moving to React
 
Angular meetup 2 2019-08-29
Angular meetup 2   2019-08-29Angular meetup 2   2019-08-29
Angular meetup 2 2019-08-29
 
Ajax
AjaxAjax
Ajax
 

En vedette

Ember.js internals backburner.js and rsvp.js
Ember.js internals  backburner.js and rsvp.jsEmber.js internals  backburner.js and rsvp.js
Ember.js internals backburner.js and rsvp.jsgavinjoyce
 
What I learned in my First 9 months of Ember
What I learned in my First 9 months of EmberWhat I learned in my First 9 months of Ember
What I learned in my First 9 months of EmberSara Raasch
 
electron for emberists
electron for emberistselectron for emberists
electron for emberistsAidan Nulman
 
Testing ember data transforms
Testing ember data transformsTesting ember data transforms
Testing ember data transformsSara Raasch
 
20120518 mssql table_schema_xml_namespace
20120518 mssql table_schema_xml_namespace20120518 mssql table_schema_xml_namespace
20120518 mssql table_schema_xml_namespaceLearningTech
 
Ember Community 2016 - Be the Bark
Ember Community 2016 - Be the BarkEmber Community 2016 - Be the Bark
Ember Community 2016 - Be the BarkMatthew Beale
 
LA Ember.js Meetup, Jan 2017
LA Ember.js Meetup, Jan 2017LA Ember.js Meetup, Jan 2017
LA Ember.js Meetup, Jan 2017Matthew Beale
 
Ember: Guts & Goals
Ember: Guts & GoalsEmber: Guts & Goals
Ember: Guts & GoalsBob Lail
 
Nest v. Flat with EmberData
Nest v. Flat with EmberDataNest v. Flat with EmberData
Nest v. Flat with EmberDataRyan M Harrison
 
Developing Single Page Apps with Ember.js
Developing Single Page Apps with Ember.jsDeveloping Single Page Apps with Ember.js
Developing Single Page Apps with Ember.jsLeo Hernandez
 
Intro to emberjs
Intro to emberjsIntro to emberjs
Intro to emberjsMandy Pao
 
Ember.js the Second Step
Ember.js the Second StepEmber.js the Second Step
Ember.js the Second StepDopin Ninja
 
Write Once, Run Everywhere - Ember.js Munich
Write Once, Run Everywhere - Ember.js MunichWrite Once, Run Everywhere - Ember.js Munich
Write Once, Run Everywhere - Ember.js MunichMike North
 
Parse Apps with Ember.js
Parse Apps with Ember.jsParse Apps with Ember.js
Parse Apps with Ember.jsMatthew Beale
 
Complex Architectures in Ember
Complex Architectures in EmberComplex Architectures in Ember
Complex Architectures in EmberMatthew Beale
 
Presentation react
Presentation reactPresentation react
Presentation reactismnoiet
 

En vedette (20)

Ember.js internals backburner.js and rsvp.js
Ember.js internals  backburner.js and rsvp.jsEmber.js internals  backburner.js and rsvp.js
Ember.js internals backburner.js and rsvp.js
 
Masa Israel Programs Overview
Masa Israel Programs OverviewMasa Israel Programs Overview
Masa Israel Programs Overview
 
Delivering with ember.js
Delivering with ember.jsDelivering with ember.js
Delivering with ember.js
 
What I learned in my First 9 months of Ember
What I learned in my First 9 months of EmberWhat I learned in my First 9 months of Ember
What I learned in my First 9 months of Ember
 
electron for emberists
electron for emberistselectron for emberists
electron for emberists
 
Testing ember data transforms
Testing ember data transformsTesting ember data transforms
Testing ember data transforms
 
20120518 mssql table_schema_xml_namespace
20120518 mssql table_schema_xml_namespace20120518 mssql table_schema_xml_namespace
20120518 mssql table_schema_xml_namespace
 
Ember Community 2016 - Be the Bark
Ember Community 2016 - Be the BarkEmber Community 2016 - Be the Bark
Ember Community 2016 - Be the Bark
 
LA Ember.js Meetup, Jan 2017
LA Ember.js Meetup, Jan 2017LA Ember.js Meetup, Jan 2017
LA Ember.js Meetup, Jan 2017
 
Ember: Guts & Goals
Ember: Guts & GoalsEmber: Guts & Goals
Ember: Guts & Goals
 
Nest v. Flat with EmberData
Nest v. Flat with EmberDataNest v. Flat with EmberData
Nest v. Flat with EmberData
 
Developing Single Page Apps with Ember.js
Developing Single Page Apps with Ember.jsDeveloping Single Page Apps with Ember.js
Developing Single Page Apps with Ember.js
 
Intro to emberjs
Intro to emberjsIntro to emberjs
Intro to emberjs
 
Ember.js the Second Step
Ember.js the Second StepEmber.js the Second Step
Ember.js the Second Step
 
Write Once, Run Everywhere - Ember.js Munich
Write Once, Run Everywhere - Ember.js MunichWrite Once, Run Everywhere - Ember.js Munich
Write Once, Run Everywhere - Ember.js Munich
 
Ember.js firebase HTML5 NYC
Ember.js firebase HTML5 NYCEmber.js firebase HTML5 NYC
Ember.js firebase HTML5 NYC
 
Parse Apps with Ember.js
Parse Apps with Ember.jsParse Apps with Ember.js
Parse Apps with Ember.js
 
Complex Architectures in Ember
Complex Architectures in EmberComplex Architectures in Ember
Complex Architectures in Ember
 
Intro to Ember.JS 2016
Intro to Ember.JS 2016Intro to Ember.JS 2016
Intro to Ember.JS 2016
 
Presentation react
Presentation reactPresentation react
Presentation react
 

Similaire à Velocity spa faster_092116

Isomorphic React Applications: Performance And Scalability
Isomorphic React Applications: Performance And ScalabilityIsomorphic React Applications: Performance And Scalability
Isomorphic React Applications: Performance And ScalabilityDenis Izmaylov
 
Edge 2016 measuring what matters
Edge 2016 measuring what mattersEdge 2016 measuring what matters
Edge 2016 measuring what mattersakamaidevrel
 
Boston Web Performance Meetup: The Render Chain and You
Boston Web Performance Meetup: The Render Chain and YouBoston Web Performance Meetup: The Render Chain and You
Boston Web Performance Meetup: The Render Chain and Youmattringel
 
Akamai company profile
Akamai company profileAkamai company profile
Akamai company profilerahulp9999
 
Performance and Scalability Art of Isomorphic React Applications
Performance and Scalability Art of Isomorphic React ApplicationsPerformance and Scalability Art of Isomorphic React Applications
Performance and Scalability Art of Isomorphic React ApplicationsDenis Izmaylov
 
Step by Step Mobile Optimization
Step by Step Mobile OptimizationStep by Step Mobile Optimization
Step by Step Mobile OptimizationGuy Podjarny
 
Rise and Fall of the Frontend Developer
Rise and Fall of the Frontend DeveloperRise and Fall of the Frontend Developer
Rise and Fall of the Frontend DeveloperRafael Casuso Romate
 
[Webinar] Expanding future mobile commerce with Magento PWA Studio
[Webinar] Expanding future mobile commerce with Magento PWA Studio[Webinar] Expanding future mobile commerce with Magento PWA Studio
[Webinar] Expanding future mobile commerce with Magento PWA StudioCedCommerce
 
Cloudflare Speed Week Recap
Cloudflare Speed Week RecapCloudflare Speed Week Recap
Cloudflare Speed Week RecapCloudflare
 
Where does Laravel fit in the Jamstack concept?
Where does Laravel fit in the Jamstack concept?Where does Laravel fit in the Jamstack concept?
Where does Laravel fit in the Jamstack concept?Tihomir Opačić
 
UI5 with Akamai - Introduction to the Content Delivery Network
UI5 with Akamai - Introduction to the Content Delivery NetworkUI5 with Akamai - Introduction to the Content Delivery Network
UI5 with Akamai - Introduction to the Content Delivery NetworkGokul Anand E, PMP®
 
20 tips for website performance
20 tips for website performance20 tips for website performance
20 tips for website performanceAndrew Siemer
 
WebDev Simplified React.js.pptx
WebDev Simplified React.js.pptxWebDev Simplified React.js.pptx
WebDev Simplified React.js.pptxSarikaPurohit1
 
Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!Jeremy Likness
 
Developing high performance and responsive web apps using web worker
Developing high performance and responsive web apps using web workerDeveloping high performance and responsive web apps using web worker
Developing high performance and responsive web apps using web workerSuresh Patidar
 

Similaire à Velocity spa faster_092116 (20)

Isomorphic React Applications: Performance And Scalability
Isomorphic React Applications: Performance And ScalabilityIsomorphic React Applications: Performance And Scalability
Isomorphic React Applications: Performance And Scalability
 
Edge 2016 measuring what matters
Edge 2016 measuring what mattersEdge 2016 measuring what matters
Edge 2016 measuring what matters
 
Boston Web Performance Meetup: The Render Chain and You
Boston Web Performance Meetup: The Render Chain and YouBoston Web Performance Meetup: The Render Chain and You
Boston Web Performance Meetup: The Render Chain and You
 
Akamai company profile
Akamai company profileAkamai company profile
Akamai company profile
 
Performance and Scalability Art of Isomorphic React Applications
Performance and Scalability Art of Isomorphic React ApplicationsPerformance and Scalability Art of Isomorphic React Applications
Performance and Scalability Art of Isomorphic React Applications
 
Step by Step Mobile Optimization
Step by Step Mobile OptimizationStep by Step Mobile Optimization
Step by Step Mobile Optimization
 
Optimizing your API to Perform at Scale
Optimizing your API to Perform at ScaleOptimizing your API to Perform at Scale
Optimizing your API to Perform at Scale
 
Rise and Fall of the Frontend Developer
Rise and Fall of the Frontend DeveloperRise and Fall of the Frontend Developer
Rise and Fall of the Frontend Developer
 
[Webinar] Expanding future mobile commerce with Magento PWA Studio
[Webinar] Expanding future mobile commerce with Magento PWA Studio[Webinar] Expanding future mobile commerce with Magento PWA Studio
[Webinar] Expanding future mobile commerce with Magento PWA Studio
 
Cloudflare Speed Week Recap
Cloudflare Speed Week RecapCloudflare Speed Week Recap
Cloudflare Speed Week Recap
 
Eureko frameworks
Eureko frameworksEureko frameworks
Eureko frameworks
 
Where does Laravel fit in the Jamstack concept?
Where does Laravel fit in the Jamstack concept?Where does Laravel fit in the Jamstack concept?
Where does Laravel fit in the Jamstack concept?
 
Web Performance Optimization (WPO)
Web Performance Optimization (WPO)Web Performance Optimization (WPO)
Web Performance Optimization (WPO)
 
UI5 with Akamai - Introduction to the Content Delivery Network
UI5 with Akamai - Introduction to the Content Delivery NetworkUI5 with Akamai - Introduction to the Content Delivery Network
UI5 with Akamai - Introduction to the Content Delivery Network
 
20 tips for website performance
20 tips for website performance20 tips for website performance
20 tips for website performance
 
WebDev Simplified React.js.pptx
WebDev Simplified React.js.pptxWebDev Simplified React.js.pptx
WebDev Simplified React.js.pptx
 
Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!
 
Refactoring to a SPA
Refactoring to a SPARefactoring to a SPA
Refactoring to a SPA
 
Ajax
AjaxAjax
Ajax
 
Developing high performance and responsive web apps using web worker
Developing high performance and responsive web apps using web workerDeveloping high performance and responsive web apps using web worker
Developing high performance and responsive web apps using web worker
 

Dernier

ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxNIMMANAGANTI RAMAKRISHNA
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxAndrieCagasanAkio
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119APNIC
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxmibuzondetrabajo
 
Cybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesCybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesLumiverse Solutions Pvt Ltd
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxMario
 

Dernier (9)

ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptx
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptx
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptx
 
Cybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesCybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best Practices
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptx
 

Velocity spa faster_092116

  • 1. Making Single Page Apps Faster Manuel Alvarez Enterprise Architect @MD_A13 Boris Livshutz Senior Enterprise Architect @livshitz98
  • 2. ©2016 AKAMAI | FASTER FORWARDTM • New way to build on the web • Growing popularity • Single HTML page • Navigation using JavaScript, APIs • Causes performance degradation • We are here to help! • Choosing the right framework for Performance • Make your SPA perform faster • Monitor SPA’s performance Builtwith Data Why are we talking about SPA today?
  • 3. ©2016 AKAMAI | FASTER FORWARDTM Choosing the Right Framework
  • 4. ©2016 AKAMAI | FASTER FORWARDTM SPA and the MVC Architecture Years of architecture evolution: • SOFEA: Service-Oriented Front-End Architecture (2007) • JavaScript, flash, and AJAX • MV-X architectures are designed to separate the view from the model • Server-side developer focus on business logic • The client is developed separately, allowing code reuse for SPA, native apps, SOA, etc. Model View Controller View Model Controller Fires Event (Updates) Passes Calls to Modifies Image from Rohit Ghatol
  • 5. ©2016 AKAMAI | FASTER FORWARDTM Current SPA trends Metric AngularJS Angular 2 Backbone.js Ember.js React.js Stars on Github 48k 10k 24k 16k 39k Commits 7k 4k 3k 18k 6k StackOverflow Questions 174k 11k 19k 19k 18k GitHub Contributors 1,426 219 282 569 645 Compresses sizes if you are curious
  • 6. ©2016 AKAMAI | FASTER FORWARDTM • Easy to start, great community support, and does not have dependencies • Not very good partnering with 3rd party JavaScripts • Great for “ambitious” web apps • It has dependencies on handlebars and jQuery • Handlebars uses <script> tags as markers, increasing DOM complexity • It uses the Virtual DOM to minimize real DOM changes • React is only the view layer • It has a minimalistic approach and it has good compatibility with other JS libraries • Dependencies on Underscore.js and jQuery Current SPA trends
  • 7. ©2016 AKAMAI | FASTER FORWARDTM What is the right framework? Stefan Krause
  • 8. ©2016 AKAMAI | FASTER FORWARDTM Angular 1 Angular 2 Ember.js React.js Create 1k rows (ms) 249.56 192.38 747.01 201.17 Append 1k rows (ms) 826.88 679.67 729.01 344.25 Clear 10k rows (ms) 840.63 436.54 1,182.97 2,027.88 Memory (on load) MB 4.86 17.05 10.1 5.17 Benchmarks Stefan Krause Chris Harrington How are you using tables if at all? What are your top browsers?
  • 9. ©2016 AKAMAI | FASTER FORWARDTM • Research them and read a little code • Evaluate their capabilities; e.g. testing tools • Implement them • Play around http://todomvc.com/ • “Hello world” + common tasks in your top browser • Can you start from an existing project? • What you are doing is so unique that it is probably on github  • Use a decision matrix What is the right framework?
  • 10. ©2016 AKAMAI | FASTER FORWARDTM AngularJS Ember React Learn 10 6 8 Develop 9 8 9 Test 8 9 8 Secure 7 8 4 Build 9 10 9 Deploy 10 10 10 Debug 7 10 7 Scale 9 7 10 Maintain 3 5 4 Share 10 10 10 82 83 79 Filler by Matt Raible - http://akamai.me/1pRfU1g Evaluate Frameworks Yevgeniy Brikman’s Framework Scorecard
  • 11. ©2016 AKAMAI | FASTER FORWARDTM Obstacles to Good Performance
  • 12. ©2016 AKAMAI | FASTER FORWARDTM Does SPA Make Your Site Faster? • Yes, for 2nd and subsequent pages (soft / virtual pages) • No, for 1st page (homepage, landing page, deep link) • 1st page ruins experience (“judge a book by its cover!”) • Leads to user abandonment • Frameworks try to do everything for everybody, causing “framework overhead”
  • 13. ©2016 AKAMAI | FASTER FORWARDTM Framework Overhead - Example Automatic Initialization in Angular 1. DOMContentLoaded event triggers Initialization 2. Loads the module associated with the directive 3. Creates the Application Injector 4. Compiles the DOM with ng-app as root 5. Framework loads all dynamic content
  • 14. ©2016 AKAMAI | FASTER FORWARDTM Performance Dive – Waterfall Analysis
  • 15. ©2016 AKAMAI | FASTER FORWARDTM Constant Reinstall • Bootstrap process is equivalent to installation • Visiting the page again (each new browser context) results on “reinstalling” • Deep links (search engines landing page) require bootstrap first and then repaint the linked page (hard + soft navigation in one!)
  • 16. ©2016 AKAMAI | FASTER FORWARDTM Mobile Magnifies the Problem • Cellular network – high latency on API calls • Limited memory - large framework • Weak CPU – heavy JavaScript processing CPU = 800MHz dual-c Memory = 512MB SunSpider = ~1880ms CPU = 2.6GHz quad-c Memory = 16GB SunSpider = ~145ms Table from Ilya Grigorik
  • 17. ©2016 AKAMAI | FASTER FORWARDTM SPA Performance Solutions
  • 18. ©2016 AKAMAI | FASTER FORWARDTM Light First Visit • First visit does not have the framework in cache • Serve a “skeleton” that looks like the real page but with a reduced version of the framework • Execute the full framework later • On the second page • When user clicks • Async execution • Pre-render
  • 19. ©2016 AKAMAI | FASTER FORWARDTM Server Side Rendering • Isomorphic App - both Server and client rendering • Step 1: Server renders page into HTML • Step 2: Client Side rendering but no impact to perceived timing • Framework Support • React - Native support • AngularJS - Version 2.0 has native support • Backbone.js - Render library • Ember.js - FastBoot feature
  • 20. ©2016 AKAMAI | FASTER FORWARDTM Server Side Rendering: Angular Step by step process in Angular 1. Process the JS on the Server Side 2. Result served to the client as the page HTML 3. Browser renders HTML as standard web page 4. Preboot starts to listen for user clicks since html is not interactive 5. Angular performs all client side bootstrapping in the background 6. As client side bootstrapping is done, it will redraw using new DOM 7. Preboot will now replay all user clicks captured previously.
  • 21. ©2016 AKAMAI | FASTER FORWARDTM Server Side Rendering: React Step by step process in React 1. Process the JS on the Server Side 2. Result served to the client as the page HTML 3. Browser renders HTML as standard web page 4. React performs all client side bootstrapping without affecting html page 5. Result is identical to what is already displayed on the page 6. React smartly identifies that no render change is needed 1. DOM is not touched (usually most expensive step) 2. Event Handler hooks are added to the current page
  • 22. ©2016 AKAMAI | FASTER FORWARDTM Virtual DOM Library • Direct DOM manipulation causes constant rerender and reflow • Use Virtual DOM to avoid reflow and rerender • React.js - builtin virtual DOM along with rendering engine • 3rd party Virtual DOM libraries - Mercury, Elm, many more
  • 23. ©2016 AKAMAI | FASTER FORWARDTM JavaScript Packaging • Choose a Package Manager • Fits DevOps build process • Compromise: network roundtrips vs caching • Trial and Error to find compromise
  • 24. ©2016 AKAMAI | FASTER FORWARDTM Resource Deferment • Defer and accelerate loading Javascript • AMD - Asynchronous Module Definition API • WebPack - Code splitting • RequireJS - dynamic and async module loader • Defer images to future pages • Use Minimized Libraries
  • 25. ©2016 AKAMAI | FASTER FORWARDTM • Cache more! at browser and Edge • Cache JSON responses • Use advance caching features • Normalize URL parameters • Enforce uniform ordering of URL parameters /weather?lang=20&latitude=47.43&longitude=19.30 /weather?longitude=19.30&latitude=47.43&lang=20 /weather?zipcode=98122&lang=20 /weather?latitude=47.4&longitude=19.3&lang=20 Rationalize + Re-order API Caching - Optimizations
  • 26. ©2016 AKAMAI | FASTER FORWARDTM Monitoring and Testing SPA
  • 27. ©2016 AKAMAI | FASTER FORWARDTM • The onload event no longer matters • Soft navigations are not real navigations • The browser won’t tell you when all resources have been downloaded Monitoring the Wrong Metrics * How to provide real user monitoring for single-page applications
  • 28. ©2016 AKAMAI | FASTER FORWARDTM Misleading Metrics Is that really Load Time?
  • 29. ©2016 AKAMAI | FASTER FORWARDTM Recommended SPA KPIs Key Metrics • Framework load time • Interactive Time • Load Complete time - first and virtual pages • Virtual Page Initial Request time • API call timings Trending Metrics • Memory usage over time • DOM size growth • Javascript error rate • Data Transfer rates (bytes fetched per page/time)
  • 30. ©2016 AKAMAI | FASTER FORWARDTM Monitoring and Testing Tools That Work • User Timing API • Mark and Measure in your code • Soasta RUM • Angular, Backbone, Ember • Performance / Load Testing • Webdriver Sampler with JMeter
  • 31. ©2016 AKAMAI | FASTER FORWARDTM SPA Takeaways • Before you build • Does SPA make sense for you? • Design SPA with performance in mind • Agree on KPIs and SLAs early on • As you build • Evaluate Mobile performance • Stay up to date • HTTP/2 Server Push • W3C Fetch Standard
  • 32. ©2016 AKAMAI | FASTER FORWARDTM Q & A