SlideShare a Scribd company logo
2:20 – 3:00pm
Quick ‘n‘ Lazy:
How we keep things speedy
and stay out of your way
Mark & Eoghan
Mark Lynch
CTO & Co-Founder
mark.lynch@learnosity.com
Eoghan McIlwaine
Software Engineer
eoghan.mcilwaine@learnosity.com
Presenters
What is performance?
Using resources (CPU,
memory, bandwidth)
as efficiently as
possible - at all levels
of our architecture.
● Why care about performance?
● Some specifics
● What’s next?
● So what can you do?
● Questions
Performance Deep Dive
● Keep engagement high
● Poor performance causes real pain:
○ Distraction for users
○ Battery drain
● We need to work on all hardware
● We’re guests on your page
Why care about performance?
https://blog.optimizely.com/2016/07/13/how-does-page-load-time-impact-engagement/
https://blog.kissmetrics.com/loading-time/
https://www.soasta.com/blog/mobile-web-
performance-monitoring-conversion-rate/
https://twitter.com/igrigorik/status/300226402496704512
Why care about performance?
http://adage.com/article/digital/google-amp-launch-
looms-search-engine-scores-follow/302599/
But computers are powerful now, right?
But battery is limited...
Performance Challenges
Tradeoff
Efficiency
Numbers for context
24M
Users in last
12 months
2M
Tablets1M
Phones
9M
Chromebooks
● Rendering speed
● Jank
● Download size
● Memory usage
● CPU usage
●
● Bandwidth
● Reliability
● Global latency
● Response Time
● DB query time
● Capacity
Backend
Where performance happens
Network Frontend
● Fastest part of every page
● Speed through laziness
● Keep it simple
Summarizing our attitude to performance...
Powerful
Flexible
Extensible
Simple
Product attributes
Easy Fixes
● Remove unused CSS & JS
● Know what’s on your page
● CDN’s - Cloudfront
● HTTP2
● Nginx/Apache GZIP
● Long Expires Headers
● CSS & JS Versioning
● Have enough servers!
● Slow Query Logs
● Static Assets from S3/CDN
● Read only db’s
● Rendering speed
● Jank
● Download size
● Memory usage
● CPU usage
●
● Bandwidth
● Reliability
● Global latency
● Response Time
● DB query time
● Capacity
Backend Network Frontend
High Impact
Low Impact
High EffortLow Effort
Do these first!
Then do these1
Prioritise Fixes
Focus on the important things!
Image rights: alessio mazzocco (https://tinyurl.com/l73gv5c)
Just a few specific
things we’ve looked at
recently
● Defer
○ Be asynchronous
○ Assess lazy loading
● Shrink
○ Behind the scenes
○ Bundle optimization
○ Font subset
● Curly ones
○ Memory leaks
○ Event delegation
○ Loader animation
Some specifics
● Be more asynchronous
● Queue longer tasks
Do Less
Confirm
Saved
Do All
Questions
API
Save
Request
Do Scoring
Store
Response
and Score
Confirm
Saved
Do Less (aka Defer)
Questions
API
Store Score
Save
Request
Do Scoring
Store
Response
Queue
For
Scoring
Do Less (extended)
Questions
API
Store Score
Save
Request
Do Scoring
Store
Response
Queue
For
Scoring
Queue
For Sub
Scoring
Do Sub
Scores
Confirm
Saved
Just a few specific
things we’ve looked at
recently
● Defer
○ Be asynchronous
○ Assess lazy loading
● Shrink
○ Behind the scenes
○ Bundle optimization
○ Font subset
● Curly ones
○ Memory leaks
○ Event delegation
○ Loader animation
Some specifics
Our Assess API lets
students take tests by
moving through a series of
pages of questions.
Some tests can have lots of
pages.
Lazy-loading items
Image rights: https://pixabay.com/en/beach-blue-sky-clouds-coconut-trees-
1868047//
Educate 2017: Quick 'n Lazy: How we keep things speedy while staying out of your way
Non-lazy
Download
item 1
Download all
other items
Render
Wait for everything to download before rendering.
Render as soon as you have what you need. Other downloads continue in the background.
Download
item 1
Download all
other items
Render
Lazy loading
Educate 2017: Quick 'n Lazy: How we keep things speedy while staying out of your way
Just a few specific
things we’ve looked at
recently
● Defer
○ Be asynchronous
○ Assess lazy loading
● Shrink
○ Behind the scenes
○ Bundle optimization
○ Font subset
● Curly ones
○ Memory leaks
○ Event delegation
○ Loader animation
Some specifics
● Response Time
● DB query time
● Capacity
Backend
Measure Things
● Nginx/Apache GZIP
● Long Expires Headers
● CSS & JS Versioning
● Have enough servers :-)
● Slow Query Logs
● Static Assets from S3/CDN
● Read only db’s
~20msAverage Latency reduction
● Bandwidth
● Reliability
● Global latency
Just use a CDN
● CDN’s - Cloudfront
● HTTP2
7.5TBdelivered
589MRequests
$1,310
4.4 daysLess waiting every day
Learnosity Cloudfront CDN bill for March 2017
Network
Just a few specific
things we’ve looked at
recently
● Defer
○ Be asynchronous
○ Assess lazy loading
● Shrink
○ Behind the scenes
○ Bundle optimization
○ Font subset
● Curly ones
○ Memory leaks
○ Event delegation
○ Loader animation
Some specifics
Bundle optimization
Each question has its own self-
contained bundle.
We ran a dependency analysis
tool to work out the level of
duplication between questions.
Association question
Drag and drop
Old bundling strategy
…and other
question types
using drag and
drop
● Single bundle for each question type (shared vendor libs though)
● Internal components (drag and drop etc.) duplicated for each question
● 23 times in some cases!
Classification question
Drag and drop
Sharing is caring
● Sharing internal components
reduces total JS download by
almost 20%
Drag and drop
bundle
Association question Classification question
Just a few specific
things we’ve looked at
recently
● Defer
○ Be asynchronous
○ Assess lazy loading
● Shrink
○ Behind the scenes
○ Bundle optimization
○ Font subset
● Curly ones
○ Memory leaks
○ Event delegation
○ Loader animation
Some specifics
Do we need that
symbol?
We include a special font,
Symbola, with math symbols.
The font file was quite large
(890k) so we took a look at what
glyphs it contains, and how many
of those we actually use.
Educate 2017: Quick 'n Lazy: How we keep things speedy while staying out of your way
Just a few specific
things we’ve looked at
recently
● Defer
○ Be asynchronous
○ Assess lazy loading
● Shrink
○ Behind the scenes
○ Bundle optimization
○ Font subset
● Curly ones
○ Memory leaks
○ Event delegation
○ Loader animation
Some specifics
● Zombie data left behind when
you don’t clean up after yourself
● Single-page app will eventually
run out of memory
● Fixing leaks and detecting
regressions is hard!
Memory leaks
Image rights: https://pixabay.com/en/corpse-dead-death-evil-1296043/,
https://pixabay.com/en/brain-lobes-colour-medical-2180593/
Memory leaks
When we stop
using an object we
need to remove
all references to it.
This is very easy
to overlook
though. Used
object
Used
object
Used
object
Unused
object
Used
object
Used
object
Example: formula keypad
Looks like a leak
Keypads aren’t getting cleaned up.
Eventually you’ll run out of memory.
All references to the keypad and
everything it contains are completely
removed on cleanup.
After fixing the leaks
Demo:
Formula keypad memory leaks
http://docs.learnosity.com/demos/isolation/formula-keyboard-memory.php
Just a few specific
things we’ve looked at
recently
● Defer
○ Be asynchronous
○ Assess lazy loading
● Shrink
○ CDN
○ Bundle optimization
○ Font subset
● Curly ones
○ Memory leaks
○ Event delegation
○ Loader animation
Some specifics
Event delegation
// Bind events on individual dropzones
$('.question .dropzone').on('click', function () {
// handle click
});
// Use delegation
$('.question').on('click', '.dropzone', function () {
// handle click
});
Educate 2017: Quick 'n Lazy: How we keep things speedy while staying out of your way
Just a few specific
things we’ve looked at
recently
● Defer
○ Be asynchronous
○ Assess lazy loading
● Shrink
○ CDN
○ Bundle optimization
○ Font subset
● Curly ones
○ Memory leaks
○ Event delegation
○ Loader animation
Some specifics
A little story about CSS
animations
Sometimes things backfire...
What we plan to
improve
● React / redux
● Dehydration / rehydration
● Web workers
What’s next?
React / redux
Simple, self-contained ui
components.
React’s Virtual DOM lets us to
do more efficient re-
rendering.
Redux forces us to maintain
state in a single JS object, not
spread between DOM, view
and model.
Currently Redux way
Model
View
DOM Element
Data
Actions / Reducers
View Components
State spread over various
layers.
Unidirectional data flow.
One source of truth for state.
What we plan to
improve
● React / redux
● Dehydration / rehydration
● Web workers
What’s next?
Dehydrate / rehydrate
Only create components and DOM
elements for questions that are
visible on screen.
Dehydrate (remove everything
except for a minimal data
representation) when not visible.
Much better performance for pages
with lots of invisible questions.
Image rights: Amblin Entertainment (Production) Robert Zemeckis (Director).
(1989) Back to the Future Part II [Motion picture] USA: Universal Pictures
What we plan to
improve
● React / redux
● Dehydration / rehydration
● Web workers
What’s next?
Web workers
Javascript that runs in the
background without interrupting
the user interface.
Use cases:
● Audio processing (already in use)
● Virtual DOM (diffing algorithm)
● Scoring
There are some drawbacks - e.g.
sending and receiving data is
asynchronous.
● Use flagged features
○ Lazy load assess
○ Lazy load formula keypad
○ Use mathquill to render math (sometimes)
● Take advantage of our APIs
● Optimize your media
● Question and test everything
● Keep libraries up to date
So what can you do?
● Performance is super important
● Solve the problem at the right level
● Don’t sweat the small stuff (especially when micro-
optimization brings in complexity)
● Measure things and ask questions
● Understand the trade-offs
● We’re continuing to make things faster
Summing up...
Questions?
2:20 – 3:00pm
Quick ‘n‘ Lazy:
How we keep things speedy
and stay out of your way
Mark & Eoghan

More Related Content

PPTX
Learnosity @ ASU+GSV 2017
PPTX
Educate 2017: Evolving APIs & audio with the changing web
PPTX
Educate 2017: Neverending Story: Exploring Learnosity's ongoing product evolu...
PDF
Tips For User Stories And Backlog Management
PDF
AbdulBasit
PDF
AB Testing and UX - a love story with numbers and people (by Craig Sullivan a...
PDF
DevOps Indonesia - What is DevOps? Why do we need it?
PDF
I Love APIs 2015: MasterClass Developer Programs and Marketing Workshop
Learnosity @ ASU+GSV 2017
Educate 2017: Evolving APIs & audio with the changing web
Educate 2017: Neverending Story: Exploring Learnosity's ongoing product evolu...
Tips For User Stories And Backlog Management
AbdulBasit
AB Testing and UX - a love story with numbers and people (by Craig Sullivan a...
DevOps Indonesia - What is DevOps? Why do we need it?
I Love APIs 2015: MasterClass Developer Programs and Marketing Workshop

What's hot (18)

PPTX
OOiP_in 5 minutes_2011
PDF
Nordic api
PDF
Lean Software Development Is for Everyone
PDF
DevOps Indonesia - DevOps Toolchain and Technology
PDF
A Brave New World of Delivering IT
PPTX
Tracking DevOps Changes In the Enterprise @paulpeissner
PDF
What Can Software Updates Do For You?
PPTX
The secret life of an Agile Business Analyst - Sydney Agile Meetup group - 13...
PPTX
Project : DuckPad
PDF
NCPL Inc Reviews
PPTX
User Experience: Building with Hypermedia for Other Folks
PPTX
DevOps-the-fire-of-business-innovation
PDF
eCommerce & Accessibility Webinar: How Accessibility can Boost Conversion Rates
PDF
Demystifying UX – A toolkit approach to better, cheaper & faster experience d...
PPTX
Using the Product Wall Release Workshop – Alignment From Vision to Sprint Bac...
PPTX
Managed vs Unmanaged Solution- Dynamics 365 CE (CRM)
PPTX
[DevRelCon Earth 2020] Developers, be the evangelist
PPTX
Product Management Auckland 15 Oct 2015 - Having Visions – The Deep Dive
OOiP_in 5 minutes_2011
Nordic api
Lean Software Development Is for Everyone
DevOps Indonesia - DevOps Toolchain and Technology
A Brave New World of Delivering IT
Tracking DevOps Changes In the Enterprise @paulpeissner
What Can Software Updates Do For You?
The secret life of an Agile Business Analyst - Sydney Agile Meetup group - 13...
Project : DuckPad
NCPL Inc Reviews
User Experience: Building with Hypermedia for Other Folks
DevOps-the-fire-of-business-innovation
eCommerce & Accessibility Webinar: How Accessibility can Boost Conversion Rates
Demystifying UX – A toolkit approach to better, cheaper & faster experience d...
Using the Product Wall Release Workshop – Alignment From Vision to Sprint Bac...
Managed vs Unmanaged Solution- Dynamics 365 CE (CRM)
[DevRelCon Earth 2020] Developers, be the evangelist
Product Management Auckland 15 Oct 2015 - Having Visions – The Deep Dive
Ad

Similar to Educate 2017: Quick 'n Lazy: How we keep things speedy while staying out of your way (20)

PDF
Using React for the Mobile Web
PDF
10 Web Performance Lessons For the 21st Century
PPTX
Client Side Performance for Back End Developers - Cambridge .NET User Group -...
PDF
Fast mobile web apps
KEY
Optimization of modern web applications
PPTX
Building high performance web apps.
PDF
Building performance into the new yahoo homepage presentation
PDF
20 tips for website performance
PDF
Performance on the Yahoo! Homepage
PPTX
Velocity NY 2013 - From Slow to Fast: Improving Performance on Intuit Website...
PDF
High Performance JavaScript Build Faster Web Application Interfaces 1st Editi...
KEY
A rough guide to JavaScript Performance
KEY
Developing High Performance Web Apps - CodeMash 2011
PPTX
10 Things You Can Do to Speed Up Your Web App Today
PDF
Front-End Performance Checklist 2020
PDF
Content-Driven Apps with React
PDF
Front-end optimisation & jQuery Internals
PPT
Smarr Oscon 2007
PPT
Os Smarr
PPTX
JS Fest 2019/Autumn. Eyal Eizenberg. Tipping the Scale
Using React for the Mobile Web
10 Web Performance Lessons For the 21st Century
Client Side Performance for Back End Developers - Cambridge .NET User Group -...
Fast mobile web apps
Optimization of modern web applications
Building high performance web apps.
Building performance into the new yahoo homepage presentation
20 tips for website performance
Performance on the Yahoo! Homepage
Velocity NY 2013 - From Slow to Fast: Improving Performance on Intuit Website...
High Performance JavaScript Build Faster Web Application Interfaces 1st Editi...
A rough guide to JavaScript Performance
Developing High Performance Web Apps - CodeMash 2011
10 Things You Can Do to Speed Up Your Web App Today
Front-End Performance Checklist 2020
Content-Driven Apps with React
Front-end optimisation & jQuery Internals
Smarr Oscon 2007
Os Smarr
JS Fest 2019/Autumn. Eyal Eizenberg. Tipping the Scale
Ad

More from Learnosity (19)

PPTX
Learnosity & CenterPoint on Accessibility: The Challenge of Inclusion
PPTX
Product Spotlight Webinar: Your Guide to Analytics and Reporting
PPTX
UNIwise Presentation @ Educate 2017
PPTX
Educate 2017: Today’s Special: Item versioning and dynamic content
PPTX
Educate 2017: Customizing Authoring: How our APIs let you create powerful sol...
PPTX
Educate 2017: Customizing Assessments: Why extending the APIs is easier than ...
PPTX
Educate 2017: Mining for Gold: Using advanced analytics to get more value fro...
PPTX
Educate 2017: Q & A Session
PPTX
Educate 2017: Enhancing edtech - why together is better
PPTX
Educate 2017: In their own words - Learnosity client success stories
PPTX
Educate 2017: Inclusivity Means Opportunity: Why accessibility is a priority
PPTX
Educate 2017: A formula for success: developing Learnosity’s auto-scoring mat...
PPTX
Educate 2017 Hello World - reach new markets with localized and personalized...
PPTX
Educate 2017 (Learnosity Developer Conference) Opening Keynote
PPTX
Company Presentation for ASU GSV 2016
PPTX
The API-ification of Education
PPTX
CloudBound K12 Presentation 2016
PDF
Creating Technology Enhanced Items: An Assessment Authoring Workshop
PDF
Atp 2016 autograding of open ended math questions
Learnosity & CenterPoint on Accessibility: The Challenge of Inclusion
Product Spotlight Webinar: Your Guide to Analytics and Reporting
UNIwise Presentation @ Educate 2017
Educate 2017: Today’s Special: Item versioning and dynamic content
Educate 2017: Customizing Authoring: How our APIs let you create powerful sol...
Educate 2017: Customizing Assessments: Why extending the APIs is easier than ...
Educate 2017: Mining for Gold: Using advanced analytics to get more value fro...
Educate 2017: Q & A Session
Educate 2017: Enhancing edtech - why together is better
Educate 2017: In their own words - Learnosity client success stories
Educate 2017: Inclusivity Means Opportunity: Why accessibility is a priority
Educate 2017: A formula for success: developing Learnosity’s auto-scoring mat...
Educate 2017 Hello World - reach new markets with localized and personalized...
Educate 2017 (Learnosity Developer Conference) Opening Keynote
Company Presentation for ASU GSV 2016
The API-ification of Education
CloudBound K12 Presentation 2016
Creating Technology Enhanced Items: An Assessment Authoring Workshop
Atp 2016 autograding of open ended math questions

Recently uploaded (20)

PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Current and future trends in Computer Vision.pptx
PPT
Mechanical Engineering MATERIALS Selection
PPTX
Artificial Intelligence
PPTX
web development for engineering and engineering
PPTX
additive manufacturing of ss316l using mig welding
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
Well-logging-methods_new................
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
OOP with Java - Java Introduction (Basics)
CH1 Production IntroductoryConcepts.pptx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Current and future trends in Computer Vision.pptx
Mechanical Engineering MATERIALS Selection
Artificial Intelligence
web development for engineering and engineering
additive manufacturing of ss316l using mig welding
CYBER-CRIMES AND SECURITY A guide to understanding
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
UNIT-1 - COAL BASED THERMAL POWER PLANTS
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Well-logging-methods_new................
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
R24 SURVEYING LAB MANUAL for civil enggi
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
OOP with Java - Java Introduction (Basics)

Educate 2017: Quick 'n Lazy: How we keep things speedy while staying out of your way

  • 1. 2:20 – 3:00pm Quick ‘n‘ Lazy: How we keep things speedy and stay out of your way Mark & Eoghan
  • 2. Mark Lynch CTO & Co-Founder mark.lynch@learnosity.com Eoghan McIlwaine Software Engineer eoghan.mcilwaine@learnosity.com Presenters
  • 4. Using resources (CPU, memory, bandwidth) as efficiently as possible - at all levels of our architecture. ● Why care about performance? ● Some specifics ● What’s next? ● So what can you do? ● Questions Performance Deep Dive
  • 5. ● Keep engagement high ● Poor performance causes real pain: ○ Distraction for users ○ Battery drain ● We need to work on all hardware ● We’re guests on your page Why care about performance?
  • 7. https://twitter.com/igrigorik/status/300226402496704512 Why care about performance? http://adage.com/article/digital/google-amp-launch- looms-search-engine-scores-follow/302599/
  • 8. But computers are powerful now, right?
  • 9. But battery is limited...
  • 11. Numbers for context 24M Users in last 12 months 2M Tablets1M Phones 9M Chromebooks
  • 12. ● Rendering speed ● Jank ● Download size ● Memory usage ● CPU usage ● ● Bandwidth ● Reliability ● Global latency ● Response Time ● DB query time ● Capacity Backend Where performance happens Network Frontend
  • 13. ● Fastest part of every page ● Speed through laziness ● Keep it simple Summarizing our attitude to performance... Powerful Flexible Extensible Simple Product attributes
  • 14. Easy Fixes ● Remove unused CSS & JS ● Know what’s on your page ● CDN’s - Cloudfront ● HTTP2 ● Nginx/Apache GZIP ● Long Expires Headers ● CSS & JS Versioning ● Have enough servers! ● Slow Query Logs ● Static Assets from S3/CDN ● Read only db’s ● Rendering speed ● Jank ● Download size ● Memory usage ● CPU usage ● ● Bandwidth ● Reliability ● Global latency ● Response Time ● DB query time ● Capacity Backend Network Frontend
  • 15. High Impact Low Impact High EffortLow Effort Do these first! Then do these1 Prioritise Fixes
  • 16. Focus on the important things! Image rights: alessio mazzocco (https://tinyurl.com/l73gv5c)
  • 17. Just a few specific things we’ve looked at recently ● Defer ○ Be asynchronous ○ Assess lazy loading ● Shrink ○ Behind the scenes ○ Bundle optimization ○ Font subset ● Curly ones ○ Memory leaks ○ Event delegation ○ Loader animation Some specifics
  • 18. ● Be more asynchronous ● Queue longer tasks Do Less
  • 20. Confirm Saved Do Less (aka Defer) Questions API Store Score Save Request Do Scoring Store Response Queue For Scoring
  • 21. Do Less (extended) Questions API Store Score Save Request Do Scoring Store Response Queue For Scoring Queue For Sub Scoring Do Sub Scores Confirm Saved
  • 22. Just a few specific things we’ve looked at recently ● Defer ○ Be asynchronous ○ Assess lazy loading ● Shrink ○ Behind the scenes ○ Bundle optimization ○ Font subset ● Curly ones ○ Memory leaks ○ Event delegation ○ Loader animation Some specifics
  • 23. Our Assess API lets students take tests by moving through a series of pages of questions. Some tests can have lots of pages. Lazy-loading items Image rights: https://pixabay.com/en/beach-blue-sky-clouds-coconut-trees- 1868047//
  • 25. Non-lazy Download item 1 Download all other items Render Wait for everything to download before rendering. Render as soon as you have what you need. Other downloads continue in the background. Download item 1 Download all other items Render Lazy loading
  • 27. Just a few specific things we’ve looked at recently ● Defer ○ Be asynchronous ○ Assess lazy loading ● Shrink ○ Behind the scenes ○ Bundle optimization ○ Font subset ● Curly ones ○ Memory leaks ○ Event delegation ○ Loader animation Some specifics
  • 28. ● Response Time ● DB query time ● Capacity Backend Measure Things ● Nginx/Apache GZIP ● Long Expires Headers ● CSS & JS Versioning ● Have enough servers :-) ● Slow Query Logs ● Static Assets from S3/CDN ● Read only db’s
  • 29. ~20msAverage Latency reduction ● Bandwidth ● Reliability ● Global latency Just use a CDN ● CDN’s - Cloudfront ● HTTP2 7.5TBdelivered 589MRequests $1,310 4.4 daysLess waiting every day Learnosity Cloudfront CDN bill for March 2017 Network
  • 30. Just a few specific things we’ve looked at recently ● Defer ○ Be asynchronous ○ Assess lazy loading ● Shrink ○ Behind the scenes ○ Bundle optimization ○ Font subset ● Curly ones ○ Memory leaks ○ Event delegation ○ Loader animation Some specifics
  • 31. Bundle optimization Each question has its own self- contained bundle. We ran a dependency analysis tool to work out the level of duplication between questions.
  • 32. Association question Drag and drop Old bundling strategy …and other question types using drag and drop ● Single bundle for each question type (shared vendor libs though) ● Internal components (drag and drop etc.) duplicated for each question ● 23 times in some cases! Classification question Drag and drop
  • 33. Sharing is caring ● Sharing internal components reduces total JS download by almost 20% Drag and drop bundle Association question Classification question
  • 34. Just a few specific things we’ve looked at recently ● Defer ○ Be asynchronous ○ Assess lazy loading ● Shrink ○ Behind the scenes ○ Bundle optimization ○ Font subset ● Curly ones ○ Memory leaks ○ Event delegation ○ Loader animation Some specifics
  • 35. Do we need that symbol? We include a special font, Symbola, with math symbols. The font file was quite large (890k) so we took a look at what glyphs it contains, and how many of those we actually use.
  • 37. Just a few specific things we’ve looked at recently ● Defer ○ Be asynchronous ○ Assess lazy loading ● Shrink ○ Behind the scenes ○ Bundle optimization ○ Font subset ● Curly ones ○ Memory leaks ○ Event delegation ○ Loader animation Some specifics
  • 38. ● Zombie data left behind when you don’t clean up after yourself ● Single-page app will eventually run out of memory ● Fixing leaks and detecting regressions is hard! Memory leaks Image rights: https://pixabay.com/en/corpse-dead-death-evil-1296043/, https://pixabay.com/en/brain-lobes-colour-medical-2180593/
  • 39. Memory leaks When we stop using an object we need to remove all references to it. This is very easy to overlook though. Used object Used object Used object Unused object Used object Used object
  • 41. Looks like a leak Keypads aren’t getting cleaned up. Eventually you’ll run out of memory.
  • 42. All references to the keypad and everything it contains are completely removed on cleanup. After fixing the leaks
  • 43. Demo: Formula keypad memory leaks http://docs.learnosity.com/demos/isolation/formula-keyboard-memory.php
  • 44. Just a few specific things we’ve looked at recently ● Defer ○ Be asynchronous ○ Assess lazy loading ● Shrink ○ CDN ○ Bundle optimization ○ Font subset ● Curly ones ○ Memory leaks ○ Event delegation ○ Loader animation Some specifics
  • 45. Event delegation // Bind events on individual dropzones $('.question .dropzone').on('click', function () { // handle click }); // Use delegation $('.question').on('click', '.dropzone', function () { // handle click });
  • 47. Just a few specific things we’ve looked at recently ● Defer ○ Be asynchronous ○ Assess lazy loading ● Shrink ○ CDN ○ Bundle optimization ○ Font subset ● Curly ones ○ Memory leaks ○ Event delegation ○ Loader animation Some specifics
  • 48. A little story about CSS animations Sometimes things backfire...
  • 49. What we plan to improve ● React / redux ● Dehydration / rehydration ● Web workers What’s next?
  • 50. React / redux Simple, self-contained ui components. React’s Virtual DOM lets us to do more efficient re- rendering. Redux forces us to maintain state in a single JS object, not spread between DOM, view and model.
  • 51. Currently Redux way Model View DOM Element Data Actions / Reducers View Components State spread over various layers. Unidirectional data flow. One source of truth for state.
  • 52. What we plan to improve ● React / redux ● Dehydration / rehydration ● Web workers What’s next?
  • 53. Dehydrate / rehydrate Only create components and DOM elements for questions that are visible on screen. Dehydrate (remove everything except for a minimal data representation) when not visible. Much better performance for pages with lots of invisible questions. Image rights: Amblin Entertainment (Production) Robert Zemeckis (Director). (1989) Back to the Future Part II [Motion picture] USA: Universal Pictures
  • 54. What we plan to improve ● React / redux ● Dehydration / rehydration ● Web workers What’s next?
  • 55. Web workers Javascript that runs in the background without interrupting the user interface. Use cases: ● Audio processing (already in use) ● Virtual DOM (diffing algorithm) ● Scoring There are some drawbacks - e.g. sending and receiving data is asynchronous.
  • 56. ● Use flagged features ○ Lazy load assess ○ Lazy load formula keypad ○ Use mathquill to render math (sometimes) ● Take advantage of our APIs ● Optimize your media ● Question and test everything ● Keep libraries up to date So what can you do?
  • 57. ● Performance is super important ● Solve the problem at the right level ● Don’t sweat the small stuff (especially when micro- optimization brings in complexity) ● Measure things and ask questions ● Understand the trade-offs ● We’re continuing to make things faster Summing up...
  • 59. 2:20 – 3:00pm Quick ‘n‘ Lazy: How we keep things speedy and stay out of your way Mark & Eoghan

Editor's Notes

  • #8: Facebook A/B test with reduced scrolling frame rate https://twitter.com/igrigorik/status/300226402496704512 http://www.youtube.com/watch?list=SPNYkxOF6rcICCU_UD67Ga0qLvMjnBBwft&v=3-WYu_p5rdU&feature=player_detailpage#t=2149s “And, crucially, Google favors faster* sites over others with the same search score in the results it shows consumers, said Richard Gingras, senior director, news and social products at Google.” http://adage.com/article/digital/google-amp-launch-looms-search-engine-scores-follow/302599/
  • #10: https://www.slideshare.net/QualcommDeveloperNetwork/69-minimize-powerconsumptioninappsschwartz918gg67
  • #11: The core challenges on mobile Performance - we have high expectations - it needs to be fast so harder to be performant compared to desktop Battery life - if we waste battery then no learning can be done. These two are highly correlated because if we are inefficient we waste battery. We’ll be talking about these in more detail in the next session so will skip over for now but keep them in mind.
  • #12: 1M users on phones 2M users on tablets 9M users on chromebooks 10M users on windows 1.7M on osx
  • #13: https://en.wikipedia.org/wiki/Server_(computing)#/media/File:Wikimedia_Foundation_Servers-8055_35.jpg
  • #14: Goal: mobile first
  • #17: Trimming the spoiler on this car isn’t going to make it go faster until you fix the tire :-)
  • #36: We use 345 symbols out of 5081 in the original font Subset tool: Pyftsubset (command line tool from fonttools python package)
  • #37: Font reduced to 1/32nd of its original size.
  • #39: Memory use just keeps increasing over time
  • #42: They keep using more: Memory (blue) DOM nodes (green) Listeners (yellow)
  • #43: The leak could be reintroduced with one careless line of code.
  • #44: Author could close and open keypad http://docs.learnosity.com/demos/isolation/formula-keyboard-memory.php
  • #46: JSON for example question { "possible_responses": ["Sacramento", "Albany"], "stimulus_list": ["New York", "California"], "type": "association", "validation": { "scoring_type": "exactMatch", "valid_response": { "score": 1, "value": ["Albany", "Sacramento"] } } }
  • #47: Effect adds up when there’s lots of dragdrop questions
  • #49: 3 little dots animation We were following standard advice to do less requests and less images etc, added CSS animation which reduces network load. After experimenting with large numbers of questions we notice high CPU and tried to track it down Saw large numbers of repaints Despite no change in dimensions the css animation was causing reflow calculation for every item on the page. Replacing with an animated GIF dropped CPU When we remove that animation in CSS the CPU dropped from 5% at 20 questions (100% at 200 questions) to basically 0.
  • #57: Use mathquill instead of mathjax if (a) you’re already using formula questions or (b) you just want to render math inside question content, not on the whole page - esp. on a large page Mathquill = smaller download, less symbols rendered, slower rendering (forced layout), scoped to individual question if requested Mathjax = renders everything on page, larger download Question/test - CSS animation issue Libraries - jQuery memory leak issue in v1.10.2