SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Parallel Execution in a Web
Application
By Guy Bary
linkedin.com/in/bgauryy
Who am I
● Technical FED Guild Manager @ Wix
● Working as Software Engineer for 10 years on several
software domains
● Web development is my main focus
● Like Beers, Music and Snowboarding
Basic User Metrics
● Conversion Rate
○ percentage of visitors who did action on a site (purchase/click..)
● Bounce Rate
○ percentage of visitors who entered a web page page once
User metrics - Load Time To Conversion
Application Loading Flow
Application Loading Flow
5
4
3
2
1
Application Flow - CSR vs SSR
● Client Side Rendering (CSR)
○ Fetch HTML
○ Parse HTML
■ Execute scripts
■ Dynamically build DOM
○ Create DOM, CSSOM, Render Tree
○ Paint
○ User interactions
● Server Side Rendering (SSR)
● Static Site Generation (SSG)
○ Fetch HTML
○ Parse HTML
■ less code to parse
■ Content is calculated in the server
○ Create DOM, CSSOM, Render Tree
○ Paint
○ User interactions
The Challenges
Render Web Application soon as possible
Let Users Interact With the Web Application
As Soon As Possible
Let Users Use Web Applications Smoothly
Performance Bottlenecks
● Rendering
○ Critical Rendering Path
○ Reflow/Repaint
● Javascript
○ Main Thread
○ Blocking events
● Network
○ Blocking resources
○ Complex dependencies
Performance Bottlenecks - Rendering
● Screens refresh at 60Hz (historical standard)
● Browser should repaint at 60fps
○ Once every ~16.6ms (1000ms / 60hz)
○ < 60fps might look janky
● requestAnimationFrame
Performance Bottlenecks - Rendering
Critical Rendering Path
The flow of creating initial view on web application
● HTML Parsing (DOM)
● CSS Parsing (CSSOM)
● Create Render Tree
○ CSSOM + DOM
● calculate layout
○ Elements positions
● calculate Paint
● Render
Performance Bottlenecks - Rendering
● Repaint
○ Style changes
● Reflow
○ Calculation of elements position
○ Layout changes
○ Viewport changes
Performance Bottlenecks - Rendering
● Browser need to check render tree and update elements
● User blocking events
● Virtual DOM tries to minimize performance issues
Performance Bottlenecks - Javascript
● Event loop
○ Single main thread
○ User events, Network events, Timers
● Blocking Events
○ Long executions (>16.6 ms, >50ms)
○ synchronous network requests (XMLHttpRequest)
○ repaint/reflow
Event Loop
D
A
B
C
setTimeout UI event onLoad
Microtasks
then microtask microtask
then
● Heap
○ Objects allocations
○ Removed by GC
● Stack
● Tasks queue
● Microtask Queue
Event Loop Specification
Event Loop - Tasks
● Tasks
○ Timers (~4ms)
■ setTimeout
■ setInterval
○ Animation
■ requestAnimationFrame
○ Events
■ DOM/Network/Storage/User events
● Microtask
○ Promise fulfill
○ queueMicrotask
Browser Structure - Chromium
Browser Structure - Chromium
Multi-process architecture
● Process
○ Independent program that runs in OS
○ Dedicated memory space
● Thread
○ Lightweight executable within a process
○ Shares process memory
● IPC (Inter-Process Communication)
○ share data between processes
● Renderer (process)
○ Process that creating
Web page from HTML, JS, CSS
● Pros
○ Isolation (bugs)
○ Security
● Cons
○ CPU
○ Memory
Browser Structure - Chromium
● Renderer
○ Process
○ Chromium Tab
● Realm
○ Instance of the V8 JavaScript engine
○ Isolated JavaScript environment
○ Global and intrinsic objects (Web API)
■ Iframe alert example
○ Proposals
■ ShadowRealms
■ compartments
Browser Structure - V8 Javascript Engine
● JavaScript (ECMAScript) Runtime
● WASM Runtime
● Code parsing & Compilation
● Memory allocation & GC
● Main Thread & Threads allocation
Browser Structure - Workers
● Run Javascript outside main thread
● Has its own V8 instance and event loop
● Types:
○ Dedicated: accessible only to the script that created it
○ Shared worker: accessible to multiple scripts under the same origin
(protocol+host+port)
● No Access to DOM
● V8 Code
● Chromium Implementation Code
● Thread on the renderer process
● Limitations
○ navigator.hardwareConcurrency
● Creation
○ URL
○ Blob
Browser Structure - Workers
Browser Structure - Workers Communication
● Asynchronous Communication
● postMessage/onMessage
○ Example
● BroadcastChannel- cross-context communication
○ Example
Browser Structure - Worklets
● Experimental
● Lightweight Worker (Blink Implementation)
● Types
○ Animation
■ Enables high performance animations
■ Chrome flag: chrome://flags/#enable-experimental-web-platform-
features
○ Paint
■ Extend CSS
■ Allow Custom painting without extending the DOM
○ Layout
■ Allow creating custom layout algorithms
○ Audio
■ Offload Audio processing to high priority thread
Browser Structure - Service Worker
● Worker thread
○ background thread
○ Installed on the browser process
● offline support
○ PWA (manifest.json)
● Push notifications
○ Can be triggered when user is not on the site
● Background sync
○ Support offline user operations
Workers - PartyTown
● Worker library for running scripts on web worker thread synchronously
● Offload execution from the main thread
Workers - PartyTown
● The Trick
○ using synchronous http request to interact with worker thread
○ Execute code in web worker within the service worker
The goal is to maximize web performance by using browser processes
efficiently
How do we detect performance issues?
How do we monitor web application performance?
Monitoring
● Production
○ Monitor users
● Automated sessions
○ Lighthouse
○ Tests
○ …
● Development
○ devTools
Monitor performance metrics where you monitor your conversion
Monitoring Production - performance
● Window.performance
○ getEntries
■ PerformanceEntry
● performance metric
○ memory
○ Measure
○ ..
Monitoring Production - PerformanceObserver
● PerformanceObserver
○ observe performance measurement events
■ Paint
■ largest-contentful-paint
■ longTask
■ Resource
■ First-input
■ Layout-shift
Monitoring Production - Core Web Vitals
● Runtime monitoring
● Google metrics for web applications (focus on users)
● Using PerformanceObserver under the hood
● Metrics
○ FCP - First Contentful Paint
○ CLS - Cumulative Layout Shift
○ FID - First Input Delay
○ INP - Interaction to Next Paint
○ LCP - Largest Contentful Paint
○ TTFB - Time to First Byte
○ TTI - Time to Interactive
○ TBT - The Total Blocking Time
Monitoring Production - Core Web Vitals
Monitoring Automated sessions
● Lighthouse
● Pagespeed (using lighthouse)
● Automation
○ Chrome devtools API (Puppeteer implementation)
○ Puppeteer + Lighthouse
Pitfalls
● Not all websites behave the same for google user agents
● Automated sessions are done mostly on strong machines with strong network
● Not all browsers are covered (real mobile devices, tablets, TV...)
Monitoring with DevTools
● Lighthouse/Audit tab
● Performance tab
● Performance insights tab
● Javascript Profiler tab
● Rendering & Performance Monitors
Parallel programing in web applications - public.pptx

Weitere ähnliche Inhalte

Ähnlich wie Parallel programing in web applications - public.pptx

Understanding Page Load / Ziling Zhao (Google)
Understanding Page Load / Ziling Zhao (Google)Understanding Page Load / Ziling Zhao (Google)
Understanding Page Load / Ziling Zhao (Google)Ontico
 
Node.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleDmytro Semenov
 
HTML5 New Features and Resources
HTML5 New Features and ResourcesHTML5 New Features and Resources
HTML5 New Features and ResourcesRon Reiter
 
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...David Amend
 
From nothing to a video under 2 seconds / Mikhail Sychev (YouTube)
From nothing to a video under 2 seconds / Mikhail Sychev  (YouTube)From nothing to a video under 2 seconds / Mikhail Sychev  (YouTube)
From nothing to a video under 2 seconds / Mikhail Sychev (YouTube)Ontico
 
JavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web frameworkJavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web frameworkAlive Kuo
 
Chrome extensions
Chrome extensions Chrome extensions
Chrome extensions Ahmad Tahhan
 
Web performance optimization - MercadoLibre
Web performance optimization - MercadoLibreWeb performance optimization - MercadoLibre
Web performance optimization - MercadoLibrePablo Moretti
 
Web performance mercadolibre - ECI 2013
Web performance   mercadolibre - ECI 2013Web performance   mercadolibre - ECI 2013
Web performance mercadolibre - ECI 2013Santiago Aimetta
 
London Salesforce Developer January 2022
London Salesforce Developer January 2022London Salesforce Developer January 2022
London Salesforce Developer January 2022Keir Bowden
 
New Ranking Metrics by Google
New Ranking Metrics by GoogleNew Ranking Metrics by Google
New Ranking Metrics by GooglePhil Marx
 
What cloud changes the developer
What cloud changes the developerWhat cloud changes the developer
What cloud changes the developerSimon Su
 
WebCamp:Front-end Developers Day. Алексей Ященко, Сергей Руденко "Фронтенд-мо...
WebCamp:Front-end Developers Day. Алексей Ященко, Сергей Руденко "Фронтенд-мо...WebCamp:Front-end Developers Day. Алексей Ященко, Сергей Руденко "Фронтенд-мо...
WebCamp:Front-end Developers Day. Алексей Ященко, Сергей Руденко "Фронтенд-мо...GeeksLab Odessa
 
Electron JS | Build cross-platform desktop applications with web technologies
Electron JS | Build cross-platform desktop applications with web technologiesElectron JS | Build cross-platform desktop applications with web technologies
Electron JS | Build cross-platform desktop applications with web technologiesBethmi Gunasekara
 
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
 
Korea linuxforum2014 html5game-sangseoklim
Korea linuxforum2014 html5game-sangseoklimKorea linuxforum2014 html5game-sangseoklim
Korea linuxforum2014 html5game-sangseoklimSang Seok Lim
 
The Chromium/Wayland project (Web Engines Hackfest 2017)
The Chromium/Wayland project (Web Engines Hackfest 2017)The Chromium/Wayland project (Web Engines Hackfest 2017)
The Chromium/Wayland project (Web Engines Hackfest 2017)Igalia
 
Web App Prototypes with Google App Engine
Web App Prototypes with Google App EngineWeb App Prototypes with Google App Engine
Web App Prototypes with Google App EngineVlad Filippov
 
Tools and libraries for common problems (Early Draft)
Tools and libraries for common problems (Early Draft)Tools and libraries for common problems (Early Draft)
Tools and libraries for common problems (Early Draft)rc2209
 

Ähnlich wie Parallel programing in web applications - public.pptx (20)

Understanding Page Load / Ziling Zhao (Google)
Understanding Page Load / Ziling Zhao (Google)Understanding Page Load / Ziling Zhao (Google)
Understanding Page Load / Ziling Zhao (Google)
 
Node.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scale
 
HTML5 New Features and Resources
HTML5 New Features and ResourcesHTML5 New Features and Resources
HTML5 New Features and Resources
 
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
 
From nothing to a video under 2 seconds / Mikhail Sychev (YouTube)
From nothing to a video under 2 seconds / Mikhail Sychev  (YouTube)From nothing to a video under 2 seconds / Mikhail Sychev  (YouTube)
From nothing to a video under 2 seconds / Mikhail Sychev (YouTube)
 
JavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web frameworkJavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web framework
 
Chrome extensions
Chrome extensions Chrome extensions
Chrome extensions
 
Web Assembly
Web AssemblyWeb Assembly
Web Assembly
 
Web performance optimization - MercadoLibre
Web performance optimization - MercadoLibreWeb performance optimization - MercadoLibre
Web performance optimization - MercadoLibre
 
Web performance mercadolibre - ECI 2013
Web performance   mercadolibre - ECI 2013Web performance   mercadolibre - ECI 2013
Web performance mercadolibre - ECI 2013
 
London Salesforce Developer January 2022
London Salesforce Developer January 2022London Salesforce Developer January 2022
London Salesforce Developer January 2022
 
New Ranking Metrics by Google
New Ranking Metrics by GoogleNew Ranking Metrics by Google
New Ranking Metrics by Google
 
What cloud changes the developer
What cloud changes the developerWhat cloud changes the developer
What cloud changes the developer
 
WebCamp:Front-end Developers Day. Алексей Ященко, Сергей Руденко "Фронтенд-мо...
WebCamp:Front-end Developers Day. Алексей Ященко, Сергей Руденко "Фронтенд-мо...WebCamp:Front-end Developers Day. Алексей Ященко, Сергей Руденко "Фронтенд-мо...
WebCamp:Front-end Developers Day. Алексей Ященко, Сергей Руденко "Фронтенд-мо...
 
Electron JS | Build cross-platform desktop applications with web technologies
Electron JS | Build cross-platform desktop applications with web technologiesElectron JS | Build cross-platform desktop applications with web technologies
Electron JS | Build cross-platform desktop applications with web technologies
 
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
 
Korea linuxforum2014 html5game-sangseoklim
Korea linuxforum2014 html5game-sangseoklimKorea linuxforum2014 html5game-sangseoklim
Korea linuxforum2014 html5game-sangseoklim
 
The Chromium/Wayland project (Web Engines Hackfest 2017)
The Chromium/Wayland project (Web Engines Hackfest 2017)The Chromium/Wayland project (Web Engines Hackfest 2017)
The Chromium/Wayland project (Web Engines Hackfest 2017)
 
Web App Prototypes with Google App Engine
Web App Prototypes with Google App EngineWeb App Prototypes with Google App Engine
Web App Prototypes with Google App Engine
 
Tools and libraries for common problems (Early Draft)
Tools and libraries for common problems (Early Draft)Tools and libraries for common problems (Early Draft)
Tools and libraries for common problems (Early Draft)
 

Kürzlich hochgeladen

Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxPurva Nikam
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniquesugginaramesh
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 

Kürzlich hochgeladen (20)

Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptx
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniques
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 

Parallel programing in web applications - public.pptx

  • 1. Parallel Execution in a Web Application By Guy Bary linkedin.com/in/bgauryy
  • 2. Who am I ● Technical FED Guild Manager @ Wix ● Working as Software Engineer for 10 years on several software domains ● Web development is my main focus ● Like Beers, Music and Snowboarding
  • 3.
  • 4. Basic User Metrics ● Conversion Rate ○ percentage of visitors who did action on a site (purchase/click..) ● Bounce Rate ○ percentage of visitors who entered a web page page once
  • 5. User metrics - Load Time To Conversion
  • 8. Application Flow - CSR vs SSR ● Client Side Rendering (CSR) ○ Fetch HTML ○ Parse HTML ■ Execute scripts ■ Dynamically build DOM ○ Create DOM, CSSOM, Render Tree ○ Paint ○ User interactions ● Server Side Rendering (SSR) ● Static Site Generation (SSG) ○ Fetch HTML ○ Parse HTML ■ less code to parse ■ Content is calculated in the server ○ Create DOM, CSSOM, Render Tree ○ Paint ○ User interactions
  • 9. The Challenges Render Web Application soon as possible Let Users Interact With the Web Application As Soon As Possible Let Users Use Web Applications Smoothly
  • 10. Performance Bottlenecks ● Rendering ○ Critical Rendering Path ○ Reflow/Repaint ● Javascript ○ Main Thread ○ Blocking events ● Network ○ Blocking resources ○ Complex dependencies
  • 11. Performance Bottlenecks - Rendering ● Screens refresh at 60Hz (historical standard) ● Browser should repaint at 60fps ○ Once every ~16.6ms (1000ms / 60hz) ○ < 60fps might look janky ● requestAnimationFrame
  • 12. Performance Bottlenecks - Rendering Critical Rendering Path The flow of creating initial view on web application ● HTML Parsing (DOM) ● CSS Parsing (CSSOM) ● Create Render Tree ○ CSSOM + DOM ● calculate layout ○ Elements positions ● calculate Paint ● Render
  • 13. Performance Bottlenecks - Rendering ● Repaint ○ Style changes ● Reflow ○ Calculation of elements position ○ Layout changes ○ Viewport changes
  • 14. Performance Bottlenecks - Rendering ● Browser need to check render tree and update elements ● User blocking events ● Virtual DOM tries to minimize performance issues
  • 15. Performance Bottlenecks - Javascript ● Event loop ○ Single main thread ○ User events, Network events, Timers ● Blocking Events ○ Long executions (>16.6 ms, >50ms) ○ synchronous network requests (XMLHttpRequest) ○ repaint/reflow
  • 16. Event Loop D A B C setTimeout UI event onLoad Microtasks then microtask microtask then ● Heap ○ Objects allocations ○ Removed by GC ● Stack ● Tasks queue ● Microtask Queue
  • 18. Event Loop - Tasks ● Tasks ○ Timers (~4ms) ■ setTimeout ■ setInterval ○ Animation ■ requestAnimationFrame ○ Events ■ DOM/Network/Storage/User events ● Microtask ○ Promise fulfill ○ queueMicrotask
  • 19.
  • 21. Browser Structure - Chromium Multi-process architecture ● Process ○ Independent program that runs in OS ○ Dedicated memory space ● Thread ○ Lightweight executable within a process ○ Shares process memory ● IPC (Inter-Process Communication) ○ share data between processes ● Renderer (process) ○ Process that creating Web page from HTML, JS, CSS ● Pros ○ Isolation (bugs) ○ Security ● Cons ○ CPU ○ Memory
  • 22. Browser Structure - Chromium ● Renderer ○ Process ○ Chromium Tab ● Realm ○ Instance of the V8 JavaScript engine ○ Isolated JavaScript environment ○ Global and intrinsic objects (Web API) ■ Iframe alert example ○ Proposals ■ ShadowRealms ■ compartments
  • 23. Browser Structure - V8 Javascript Engine ● JavaScript (ECMAScript) Runtime ● WASM Runtime ● Code parsing & Compilation ● Memory allocation & GC ● Main Thread & Threads allocation
  • 24. Browser Structure - Workers ● Run Javascript outside main thread ● Has its own V8 instance and event loop ● Types: ○ Dedicated: accessible only to the script that created it ○ Shared worker: accessible to multiple scripts under the same origin (protocol+host+port) ● No Access to DOM ● V8 Code ● Chromium Implementation Code
  • 25. ● Thread on the renderer process ● Limitations ○ navigator.hardwareConcurrency ● Creation ○ URL ○ Blob Browser Structure - Workers
  • 26. Browser Structure - Workers Communication ● Asynchronous Communication ● postMessage/onMessage ○ Example ● BroadcastChannel- cross-context communication ○ Example
  • 27. Browser Structure - Worklets ● Experimental ● Lightweight Worker (Blink Implementation) ● Types ○ Animation ■ Enables high performance animations ■ Chrome flag: chrome://flags/#enable-experimental-web-platform- features ○ Paint ■ Extend CSS ■ Allow Custom painting without extending the DOM ○ Layout ■ Allow creating custom layout algorithms ○ Audio ■ Offload Audio processing to high priority thread
  • 28. Browser Structure - Service Worker ● Worker thread ○ background thread ○ Installed on the browser process ● offline support ○ PWA (manifest.json) ● Push notifications ○ Can be triggered when user is not on the site ● Background sync ○ Support offline user operations
  • 29. Workers - PartyTown ● Worker library for running scripts on web worker thread synchronously ● Offload execution from the main thread
  • 30. Workers - PartyTown ● The Trick ○ using synchronous http request to interact with worker thread ○ Execute code in web worker within the service worker
  • 31. The goal is to maximize web performance by using browser processes efficiently
  • 32. How do we detect performance issues? How do we monitor web application performance?
  • 33. Monitoring ● Production ○ Monitor users ● Automated sessions ○ Lighthouse ○ Tests ○ … ● Development ○ devTools Monitor performance metrics where you monitor your conversion
  • 34. Monitoring Production - performance ● Window.performance ○ getEntries ■ PerformanceEntry ● performance metric ○ memory ○ Measure ○ ..
  • 35. Monitoring Production - PerformanceObserver ● PerformanceObserver ○ observe performance measurement events ■ Paint ■ largest-contentful-paint ■ longTask ■ Resource ■ First-input ■ Layout-shift
  • 36. Monitoring Production - Core Web Vitals ● Runtime monitoring ● Google metrics for web applications (focus on users) ● Using PerformanceObserver under the hood ● Metrics ○ FCP - First Contentful Paint ○ CLS - Cumulative Layout Shift ○ FID - First Input Delay ○ INP - Interaction to Next Paint ○ LCP - Largest Contentful Paint ○ TTFB - Time to First Byte ○ TTI - Time to Interactive ○ TBT - The Total Blocking Time
  • 37. Monitoring Production - Core Web Vitals
  • 38. Monitoring Automated sessions ● Lighthouse ● Pagespeed (using lighthouse) ● Automation ○ Chrome devtools API (Puppeteer implementation) ○ Puppeteer + Lighthouse Pitfalls ● Not all websites behave the same for google user agents ● Automated sessions are done mostly on strong machines with strong network ● Not all browsers are covered (real mobile devices, tablets, TV...)
  • 39. Monitoring with DevTools ● Lighthouse/Audit tab ● Performance tab ● Performance insights tab ● Javascript Profiler tab ● Rendering & Performance Monitors