SlideShare a Scribd company logo
1 of 83
Conditional
Modules
&
Dynamic Bundling
A NETFLIX
ORIGINAL
Conditional Modules & Dynamic
Bundling : A NETFLIX
Original
Rajat Kumar
rajatk@netflix.com | @rajatkumar
Contents
I. The Problem
II. Conditional Dependencies
III. Bundling as a Service
IV. The Future
data driven
product development
AB tests gives each subscriber a
unique and different User Experience
User Experience can also vary based
on many other dimensions
app.js
currentSearch
newSearch
sub-dep1
sub-dep2
sub-dep3
sub-dep4
sub-dep5
sub-dep6
sub-dep7
sub-dep8
dep1
dep2
dep3
dep4
dep5
dep6
app.js
currentSearch
newSearch
sub-dep1
sub-dep2
sub-dep3
sub-dep4
sub-dep5
sub-dep6
sub-dep7
sub-dep8
dep1
dep2
dep3
dep4
dep5
dep6
app.js
currentSearch
newSearch
sub-dep1
sub-dep2
sub-dep3
sub-dep4
sub-dep5
sub-dep6
sub-dep7
sub-dep8
dep1
dep2
dep3
dep4
dep5
dep6
....
import currentSearch from 'currentSearch';
import newSearch from 'newSearch';
....
export ...
app.js
app.js
currentSearch
newSearch
sub-dep1
sub-dep2
sub-dep3
sub-dep4
sub-dep5
sub-dep6
sub-dep7
sub-dep8
dep1
dep2
dep3
dep4
dep5
dep6
The Problem
Our Apps are huge
WebUI ~ 10 MB
TVUI ~ 30 MB
Slower Performing Apps
Longer Time-to-interactive (TTI)
Slower Performing Apps
Longer Time-to-interactive (TTI)
Summary : Poor User Experience
How can we improve the User
Experience?
Can we build “smaller” packages that
are very specific to the user’s AB tests?
But is that it?
Unfortunately, No!
Netflix runs hundreds of AB tests
ATest
1
B
ATest
1
B C D
ATest
1
B C D
ATest
2
B C D
ATest
3
B C D
ATest
4
B C D
ATest
5
B C D
ATest
6
B C D
ATest
1
B C D
ATest
2
B C D
ATest
3
B C D
ATest
4
B C D
ATest
5
B C D
ATest
6
B C D
Netflix runs hundreds of AB tests
How many packages do we need to
serve?
Netflix runs hundreds of AB tests
How many packages do we need to
serve?
|S1| · |S2| ··· |Sn| = | S1 x S2 x ··· x
Sn|
Netflix runs hundreds AB tests
|S1| · |S2| ··· |S15| = | S1 x S2 x ··· x
S15|
Netflix runs hundreds AB tests
|S1| · |S2| ··· |S15| = | S1 x S2 x ··· x
S15|
4 15 = 1,073,741,824
Netflix runs hundreds AB tests
|S1| · |S2| ··· |S15| = | S1 x S2 x ··· x
S15|
4 15 = 1,073,741,824
that’s over a
Billion!
Netflix runs hundreds of AB tests
|S1| · |S2| ··· |Sn| = | S1 x S2 x ··· x
Sn|
Netflix runs hundreds of AB tests
|S1| · |S2| ··· |Sn| = | S1 x S2 x ··· x
Sn|
4 100 = ~ 1.606938e+60
Netflix runs hundreds of AB tests
How many packages do we need to
serve?
Billions
The Problem
Serve billions of smaller packages
that are very specific to the User’s AB
tests
app.js
newSearch
sub-dep1
sub-dep2
sub-dep3
sub-dep4
sub-dep5
sub-dep6
sub-dep7
sub-dep8
dep1
dep2
dep3
dep4
dep5
dep6
newSearchExp is false
newSearchExp is true
currentSearch
app.js
newSearch
sub-dep1
sub-dep2
sub-dep3
sub-dep4
sub-dep5
sub-dep6
sub-dep7
sub-dep8
dep1
dep2
dep3
dep4
dep5
dep6
newSearchExp is false
newSearchExp is true
currentSearch
Build Request
Build Request
Build
git artifact
user artifact
Request
Conditional Dependencies
Build
git artifact
artifact
artifact
artifact
Webpack
Build
app.js
newSearch
sub-dep2
sub-dep3
sub-dep6
sub-dep7
sub-dep8
dep3
dep4
dep5
dep6
newSearchExp is true
Conditio
n
Conditional Modules
How do we mark a module as
conditional?
// @condition newSearchExp
import React, { Component } from 'react';
...
// rest of the code
...
export ...
newSearch.js
app.js
...
if ($$conditions$$.newSearchExp === true) {
search = require('./newSearch');
}
else {
search = require('./currentSearch');
}
...
export ...
How do we build a
conditional dependency graph
with Webpack?
We built a Webpack plugin and worked
with Abstract Syntax Trees (ASTs)
● Hook: parser.hooks.program
● Works for both :
○ @condition syntax
○ $$conditions$$ syntax
Then...
● Hook: compiler.hooks.emit
○ Generate conditional dependency
graph
○ Serialize it as a JSON file
Build
artifact
Bundling as a Service
tv
web
https://codex.nflx.com/webui/v3/app.js/newSearchExp,smartPlayback
https://codex.nflx.com/tvui/v7/home.js/newSearchExp,smartSession
codex
How do we resolve the
conditional dependencies
at runtime?
https://codex.nflx.com/webui/v3/app.js/newSearchExp,smartPlayback
https://codex.nflx.com/ {team} / {version} / {entrypoint} / {conditions}
codex
https://codex.nflx.com/webui/v3/app.js/newSearchExp,smartPlayback
https://codex.nflx.com/ {team} / {version} / {entrypoint} / {conditions}
codex
v3
webui
https://codex.nflx.com/webui/v3/app.js/newSearchExp,smartPlayback
https://codex.nflx.com/ {team} / {version} / {entrypoint} / {conditions}
codex
v3
webui
{
newSearchExp: true
smartPlayback: true
}
https://codex.nflx.com/webui/v3/app.js/newSearchExp,smartPlayback
https://codex.nflx.com/ {team} / {version} / {entrypoint} / {conditions}
codex
v3
webui
{
newSearchExp: true
smartPlayback: true
}
app.js
https://codex.nflx.com/webui/v3/app.js/newSearchExp,smartPlayback
https://codex.nflx.com/ {team} / {version} / {entrypoint} / {conditions}
codex
v3
webui
{
newSearchExp: true
smartPlayback: true
}
app.js
{
newSearchExp: true
smartPlayback: true
}
currentSearchExpnewSearchExp
{
newSearchExp: true
smartPlayback: true
}
newSearchExp
smartPlayback
smartSession
{
newSearchExp: true
smartPlayback: true
}
newSearchExp
smartPlayback
https://codex.nflx.com/webui/v3/app.js/newSearchExp,smartPlayback
https://codex.nflx.com/ {team} / {version} / {entrypoint} / {conditions}
codex
v3
webui
{
newSearchExp: true
smartPlayback: true
}
app.js
Slow?
https://codex.nflx.com/webui/v3/app.js/newSearchExp,smartPlayback
https://codex.nflx.com/ {team} / {version} / {entrypoint} / {conditions}
codex
v3
webui
{
newSearchExp: true
smartPlayback: true
}
app.js
response time < 70ms
https://codex.nflx.com/webui/v3/app.js/newSearchExp,smartPlayback
https://codex.nflx.com/ {team} / {version} / {entrypoint} / {conditions}
codexCDN
Summary
// @condition newSearchExp
import React, { Component } from 'react';
...
// rest of the code
...
if ($$conditions$$.newSearchExp === true) {
search = require('./newSearch');
}
else {
search = require('./currentSearch');
}
// rest of the code
webui/v3
codex
webui/v3
codex
webui/v3
CDN
The Future
Developer experience and Webpack
Thank you
Rajat Kumar
rajatk@netflix.com | @rajatkumar
ReactWeek 2019 Conditional Modules & Dynamic Bundling: A Netflix Original
ReactWeek 2019 Conditional Modules & Dynamic Bundling: A Netflix Original

More Related Content

What's hot

Running Flink in Production: The good, The bad and The in Between - Lakshmi ...
Running Flink in Production:  The good, The bad and The in Between - Lakshmi ...Running Flink in Production:  The good, The bad and The in Between - Lakshmi ...
Running Flink in Production: The good, The bad and The in Between - Lakshmi ...Flink Forward
 
KubeFlow + GPU + Keras/TensorFlow 2.0 + TF Extended (TFX) + Kubernetes + PyTo...
KubeFlow + GPU + Keras/TensorFlow 2.0 + TF Extended (TFX) + Kubernetes + PyTo...KubeFlow + GPU + Keras/TensorFlow 2.0 + TF Extended (TFX) + Kubernetes + PyTo...
KubeFlow + GPU + Keras/TensorFlow 2.0 + TF Extended (TFX) + Kubernetes + PyTo...Chris Fregly
 
Infrastructure as code
Infrastructure as codeInfrastructure as code
Infrastructure as codeAakash Singhal
 
Kube Your Enthusiasm - Paul Czarkowski
Kube Your Enthusiasm - Paul CzarkowskiKube Your Enthusiasm - Paul Czarkowski
Kube Your Enthusiasm - Paul CzarkowskiVMware Tanzu
 
State in stateless serverless functions
State in stateless serverless functionsState in stateless serverless functions
State in stateless serverless functionsAlex Pshul
 
XebiCon'18 - Passage à l'échelle de mes applications Kafka-Streams
XebiCon'18 - Passage à l'échelle de mes applications Kafka-StreamsXebiCon'18 - Passage à l'échelle de mes applications Kafka-Streams
XebiCon'18 - Passage à l'échelle de mes applications Kafka-StreamsPublicis Sapient Engineering
 
Graphs: Fabric of DevOps
Graphs: Fabric of DevOpsGraphs: Fabric of DevOps
Graphs: Fabric of DevOpsNeo4j
 
Jenkins vs. AWS CodePipeline
Jenkins vs. AWS CodePipelineJenkins vs. AWS CodePipeline
Jenkins vs. AWS CodePipelineSteffen Gebert
 
Kubo (Cloud Foundry Container Platform): Your Gateway Drug to Cloud-native
Kubo (Cloud Foundry Container Platform): Your Gateway Drug to Cloud-nativeKubo (Cloud Foundry Container Platform): Your Gateway Drug to Cloud-native
Kubo (Cloud Foundry Container Platform): Your Gateway Drug to Cloud-nativecornelia davis
 
Smokey and the Multi-Armed Bandit Featuring BERT Reynolds Updated
Smokey and the Multi-Armed Bandit Featuring BERT Reynolds UpdatedSmokey and the Multi-Armed Bandit Featuring BERT Reynolds Updated
Smokey and the Multi-Armed Bandit Featuring BERT Reynolds UpdatedChris Fregly
 
OSDC 2018 - Distributed monitoring
OSDC 2018 - Distributed monitoringOSDC 2018 - Distributed monitoring
OSDC 2018 - Distributed monitoringGianluca Arbezzano
 
Sdn users group_january_2016v5
Sdn users group_january_2016v5Sdn users group_january_2016v5
Sdn users group_january_2016v5Joel W. King
 
ISTA 2019 - Migrating data-intensive microservices from Python to Go
ISTA 2019 - Migrating data-intensive microservices from Python to GoISTA 2019 - Migrating data-intensive microservices from Python to Go
ISTA 2019 - Migrating data-intensive microservices from Python to GoNikolay Stoitsev
 
Building a modern SaaS in 2020
Building a modern SaaS in 2020Building a modern SaaS in 2020
Building a modern SaaS in 2020Nikolay Stoitsev
 
Flink Forward San Francisco 2019: Managing Flink on Kubernetes - FlinkK8sOper...
Flink Forward San Francisco 2019: Managing Flink on Kubernetes - FlinkK8sOper...Flink Forward San Francisco 2019: Managing Flink on Kubernetes - FlinkK8sOper...
Flink Forward San Francisco 2019: Managing Flink on Kubernetes - FlinkK8sOper...Flink Forward
 
AllTheTalks.online - A Streaming Use-Case: And Experiment in Continuous Deplo...
AllTheTalks.online - A Streaming Use-Case: And Experiment in Continuous Deplo...AllTheTalks.online - A Streaming Use-Case: And Experiment in Continuous Deplo...
AllTheTalks.online - A Streaming Use-Case: And Experiment in Continuous Deplo...Nicolas Fränkel
 
High-Performance Python
High-Performance PythonHigh-Performance Python
High-Performance PythonWork-Bench
 
Refactoring Design Patterns the Functional Way (in Scala)
Refactoring Design Patterns the Functional Way (in Scala)Refactoring Design Patterns the Functional Way (in Scala)
Refactoring Design Patterns the Functional Way (in Scala)Kfir Bloch
 

What's hot (20)

Netflix conductor
Netflix conductorNetflix conductor
Netflix conductor
 
Running Flink in Production: The good, The bad and The in Between - Lakshmi ...
Running Flink in Production:  The good, The bad and The in Between - Lakshmi ...Running Flink in Production:  The good, The bad and The in Between - Lakshmi ...
Running Flink in Production: The good, The bad and The in Between - Lakshmi ...
 
KubeFlow + GPU + Keras/TensorFlow 2.0 + TF Extended (TFX) + Kubernetes + PyTo...
KubeFlow + GPU + Keras/TensorFlow 2.0 + TF Extended (TFX) + Kubernetes + PyTo...KubeFlow + GPU + Keras/TensorFlow 2.0 + TF Extended (TFX) + Kubernetes + PyTo...
KubeFlow + GPU + Keras/TensorFlow 2.0 + TF Extended (TFX) + Kubernetes + PyTo...
 
Infrastructure as code
Infrastructure as codeInfrastructure as code
Infrastructure as code
 
Kube Your Enthusiasm - Paul Czarkowski
Kube Your Enthusiasm - Paul CzarkowskiKube Your Enthusiasm - Paul Czarkowski
Kube Your Enthusiasm - Paul Czarkowski
 
State in stateless serverless functions
State in stateless serverless functionsState in stateless serverless functions
State in stateless serverless functions
 
XebiCon'18 - Passage à l'échelle de mes applications Kafka-Streams
XebiCon'18 - Passage à l'échelle de mes applications Kafka-StreamsXebiCon'18 - Passage à l'échelle de mes applications Kafka-Streams
XebiCon'18 - Passage à l'échelle de mes applications Kafka-Streams
 
Infrastructure as Code
Infrastructure as CodeInfrastructure as Code
Infrastructure as Code
 
Graphs: Fabric of DevOps
Graphs: Fabric of DevOpsGraphs: Fabric of DevOps
Graphs: Fabric of DevOps
 
Jenkins vs. AWS CodePipeline
Jenkins vs. AWS CodePipelineJenkins vs. AWS CodePipeline
Jenkins vs. AWS CodePipeline
 
Kubo (Cloud Foundry Container Platform): Your Gateway Drug to Cloud-native
Kubo (Cloud Foundry Container Platform): Your Gateway Drug to Cloud-nativeKubo (Cloud Foundry Container Platform): Your Gateway Drug to Cloud-native
Kubo (Cloud Foundry Container Platform): Your Gateway Drug to Cloud-native
 
Smokey and the Multi-Armed Bandit Featuring BERT Reynolds Updated
Smokey and the Multi-Armed Bandit Featuring BERT Reynolds UpdatedSmokey and the Multi-Armed Bandit Featuring BERT Reynolds Updated
Smokey and the Multi-Armed Bandit Featuring BERT Reynolds Updated
 
OSDC 2018 - Distributed monitoring
OSDC 2018 - Distributed monitoringOSDC 2018 - Distributed monitoring
OSDC 2018 - Distributed monitoring
 
Sdn users group_january_2016v5
Sdn users group_january_2016v5Sdn users group_january_2016v5
Sdn users group_january_2016v5
 
ISTA 2019 - Migrating data-intensive microservices from Python to Go
ISTA 2019 - Migrating data-intensive microservices from Python to GoISTA 2019 - Migrating data-intensive microservices from Python to Go
ISTA 2019 - Migrating data-intensive microservices from Python to Go
 
Building a modern SaaS in 2020
Building a modern SaaS in 2020Building a modern SaaS in 2020
Building a modern SaaS in 2020
 
Flink Forward San Francisco 2019: Managing Flink on Kubernetes - FlinkK8sOper...
Flink Forward San Francisco 2019: Managing Flink on Kubernetes - FlinkK8sOper...Flink Forward San Francisco 2019: Managing Flink on Kubernetes - FlinkK8sOper...
Flink Forward San Francisco 2019: Managing Flink on Kubernetes - FlinkK8sOper...
 
AllTheTalks.online - A Streaming Use-Case: And Experiment in Continuous Deplo...
AllTheTalks.online - A Streaming Use-Case: And Experiment in Continuous Deplo...AllTheTalks.online - A Streaming Use-Case: And Experiment in Continuous Deplo...
AllTheTalks.online - A Streaming Use-Case: And Experiment in Continuous Deplo...
 
High-Performance Python
High-Performance PythonHigh-Performance Python
High-Performance Python
 
Refactoring Design Patterns the Functional Way (in Scala)
Refactoring Design Patterns the Functional Way (in Scala)Refactoring Design Patterns the Functional Way (in Scala)
Refactoring Design Patterns the Functional Way (in Scala)
 

Similar to ReactWeek 2019 Conditional Modules & Dynamic Bundling: A Netflix Original

Netflix JavaScript Talks - Scaling A/B Testing on Netflix.com with Node.js
Netflix JavaScript Talks - Scaling A/B Testing on Netflix.com with Node.jsNetflix JavaScript Talks - Scaling A/B Testing on Netflix.com with Node.js
Netflix JavaScript Talks - Scaling A/B Testing on Netflix.com with Node.jsChris Saint-Amant
 
Adding IPv6 to the application layer
Adding IPv6 to the application layerAdding IPv6 to the application layer
Adding IPv6 to the application layerKoichi Taniguchi
 
Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)Yan Cui
 
Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)Yan Cui
 
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...Amazon Web Services
 
Kubernetes - State of the Union (Q1-2016)
Kubernetes - State of the Union (Q1-2016)Kubernetes - State of the Union (Q1-2016)
Kubernetes - State of the Union (Q1-2016)DoiT International
 
Openshift operator insight
Openshift operator insightOpenshift operator insight
Openshift operator insightRyan ZhangCheng
 
Serverless in production, an experience report
Serverless in production, an experience reportServerless in production, an experience report
Serverless in production, an experience reportYan Cui
 
Docker at OpenDNS
Docker at OpenDNSDocker at OpenDNS
Docker at OpenDNSOpenDNS
 
Kubernetes workshop -_the_basics
Kubernetes workshop -_the_basicsKubernetes workshop -_the_basics
Kubernetes workshop -_the_basicsSjuul Janssen
 
Cilium - API-aware Networking and Security for Containers based on BPF
Cilium - API-aware Networking and Security for Containers based on BPFCilium - API-aware Networking and Security for Containers based on BPF
Cilium - API-aware Networking and Security for Containers based on BPFThomas Graf
 
MongoDB.local DC 2018: MongoDB Ops Manager + Kubernetes
MongoDB.local DC 2018: MongoDB Ops Manager + KubernetesMongoDB.local DC 2018: MongoDB Ops Manager + Kubernetes
MongoDB.local DC 2018: MongoDB Ops Manager + KubernetesMongoDB
 
Kubernetes Multi-cluster without Federation - Kubecon EU 2018
Kubernetes Multi-cluster without Federation - Kubecon EU 2018Kubernetes Multi-cluster without Federation - Kubecon EU 2018
Kubernetes Multi-cluster without Federation - Kubecon EU 2018Rob Szumski
 
Kubernetes deep dive - - Huawei 2015-10
Kubernetes deep dive - - Huawei 2015-10Kubernetes deep dive - - Huawei 2015-10
Kubernetes deep dive - - Huawei 2015-10Vishnu Kannan
 
Wireless Developing Wireless Monitoring and Control devices
Wireless Developing Wireless Monitoring and Control devicesWireless Developing Wireless Monitoring and Control devices
Wireless Developing Wireless Monitoring and Control devicesAidan Venn MSc
 
Use GitLab with Chaos Engineering to Harden your Applications + OpenEBS 1.3 ...
 Use GitLab with Chaos Engineering to Harden your Applications + OpenEBS 1.3 ... Use GitLab with Chaos Engineering to Harden your Applications + OpenEBS 1.3 ...
Use GitLab with Chaos Engineering to Harden your Applications + OpenEBS 1.3 ...MayaData Inc
 
Luca Relandini - Microservices and containers networking: Contiv, deep dive a...
Luca Relandini - Microservices and containers networking: Contiv, deep dive a...Luca Relandini - Microservices and containers networking: Contiv, deep dive a...
Luca Relandini - Microservices and containers networking: Contiv, deep dive a...Codemotion
 
MongoDB.local Austin 2018: MongoDB Ops Manager + Kubernetes
MongoDB.local Austin 2018: MongoDB Ops Manager + KubernetesMongoDB.local Austin 2018: MongoDB Ops Manager + Kubernetes
MongoDB.local Austin 2018: MongoDB Ops Manager + KubernetesMongoDB
 
K8s Pod Scheduling - Deep Dive. By Tsahi Duek.
K8s Pod Scheduling - Deep Dive. By Tsahi Duek.K8s Pod Scheduling - Deep Dive. By Tsahi Duek.
K8s Pod Scheduling - Deep Dive. By Tsahi Duek.Cloud Native Day Tel Aviv
 

Similar to ReactWeek 2019 Conditional Modules & Dynamic Bundling: A Netflix Original (20)

Netflix JavaScript Talks - Scaling A/B Testing on Netflix.com with Node.js
Netflix JavaScript Talks - Scaling A/B Testing on Netflix.com with Node.jsNetflix JavaScript Talks - Scaling A/B Testing on Netflix.com with Node.js
Netflix JavaScript Talks - Scaling A/B Testing on Netflix.com with Node.js
 
Adding IPv6 to the application layer
Adding IPv6 to the application layerAdding IPv6 to the application layer
Adding IPv6 to the application layer
 
Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)
 
Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)
 
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
 
Kubernetes - State of the Union (Q1-2016)
Kubernetes - State of the Union (Q1-2016)Kubernetes - State of the Union (Q1-2016)
Kubernetes - State of the Union (Q1-2016)
 
Openshift operator insight
Openshift operator insightOpenshift operator insight
Openshift operator insight
 
Serverless in production, an experience report
Serverless in production, an experience reportServerless in production, an experience report
Serverless in production, an experience report
 
Docker at OpenDNS
Docker at OpenDNSDocker at OpenDNS
Docker at OpenDNS
 
Kubernetes workshop -_the_basics
Kubernetes workshop -_the_basicsKubernetes workshop -_the_basics
Kubernetes workshop -_the_basics
 
Cilium - API-aware Networking and Security for Containers based on BPF
Cilium - API-aware Networking and Security for Containers based on BPFCilium - API-aware Networking and Security for Containers based on BPF
Cilium - API-aware Networking and Security for Containers based on BPF
 
MongoDB.local DC 2018: MongoDB Ops Manager + Kubernetes
MongoDB.local DC 2018: MongoDB Ops Manager + KubernetesMongoDB.local DC 2018: MongoDB Ops Manager + Kubernetes
MongoDB.local DC 2018: MongoDB Ops Manager + Kubernetes
 
Kubernetes Multi-cluster without Federation - Kubecon EU 2018
Kubernetes Multi-cluster without Federation - Kubecon EU 2018Kubernetes Multi-cluster without Federation - Kubecon EU 2018
Kubernetes Multi-cluster without Federation - Kubecon EU 2018
 
Kubernetes deep dive - - Huawei 2015-10
Kubernetes deep dive - - Huawei 2015-10Kubernetes deep dive - - Huawei 2015-10
Kubernetes deep dive - - Huawei 2015-10
 
Wireless Developing Wireless Monitoring and Control devices
Wireless Developing Wireless Monitoring and Control devicesWireless Developing Wireless Monitoring and Control devices
Wireless Developing Wireless Monitoring and Control devices
 
Use GitLab with Chaos Engineering to Harden your Applications + OpenEBS 1.3 ...
 Use GitLab with Chaos Engineering to Harden your Applications + OpenEBS 1.3 ... Use GitLab with Chaos Engineering to Harden your Applications + OpenEBS 1.3 ...
Use GitLab with Chaos Engineering to Harden your Applications + OpenEBS 1.3 ...
 
Luca Relandini - Microservices and containers networking: Contiv, deep dive a...
Luca Relandini - Microservices and containers networking: Contiv, deep dive a...Luca Relandini - Microservices and containers networking: Contiv, deep dive a...
Luca Relandini - Microservices and containers networking: Contiv, deep dive a...
 
MongoDB.local Austin 2018: MongoDB Ops Manager + Kubernetes
MongoDB.local Austin 2018: MongoDB Ops Manager + KubernetesMongoDB.local Austin 2018: MongoDB Ops Manager + Kubernetes
MongoDB.local Austin 2018: MongoDB Ops Manager + Kubernetes
 
K8s Pod Scheduling - Deep Dive. By Tsahi Duek.
K8s Pod Scheduling - Deep Dive. By Tsahi Duek.K8s Pod Scheduling - Deep Dive. By Tsahi Duek.
K8s Pod Scheduling - Deep Dive. By Tsahi Duek.
 
LINQ
LINQLINQ
LINQ
 

Recently uploaded

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 

Recently uploaded (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 

ReactWeek 2019 Conditional Modules & Dynamic Bundling: A Netflix Original

Editor's Notes

  1. Good Morning Everyone How are we doing? Welcome to my talk: Conditional Modules and Dynamic Bundling:A Netflix Original
  2. Okay, so Netflix! Is there anybody who doesn't know what Netflix is? Netflix is an online video streaming service and we have a wide variety of programs and several Original shows, movies and documentaries. What is pretty amazing is that we are now in over 190 countries and have over 140M subscribers worldwide.
  3. Yes #netflixeverywhere!
  4. My name is Rajat Kumar I work at Netflix. I am part of Node.js Platform team And we do everything from building Nodejs libraries To writing Nodejs services that support our UI and product teams. Today I am going to talk about bundling Javascript files at Netflix and how we challenged some of the common conventions to solve our set of problems with bundling at Netflix.
  5. Alright this talk is split into 4 parts I will start by talking about the problem - what exactly is it that we are trying to solve Then go on to talk about how we worked through the problem and what we ended up building And finally end the session with some of the things that we plan to do in near future.
  6. Netflix is a data driven product development company. At Netflix we do a TON of A/B testing. Our TV App and website netflix.com is built using React and developers focus a lot on gathering metrics Data gathered through these tests helps us provide our subscribers with an even better Experience.
  7. For example - on our netflix.com member homepage There are several components that Have been tested and retested many times
  8. This shows what we might be testing at a given point in time It could be as simple as testing the Category title, to testing the size of the box shot, to even as minute as testing the Netflix’s N logo on the boxart
  9. We run hundreds of AB tests And with each AB test it is quite possible each subscriber might see a different version of same UI and gets a personalized User Experience
  10. The user experience is not only driven by AB Tests but also on other dimensions Like - user’s browser, geo-location, users device like TV etc
  11. Lets say - we are AB Testing two versions of `Search` Component. Lets call them current Search experience and the new Search experience. So as an engineering team it is our responsibility to ensure we can send Javascript code down to the user so that we can test these 2 variations of the Search experiences
  12. Our modular javascript code would probably look similar to this. Here we have an entry point app.js and we have 2 search components and for running each search experience the javascript code needs its dependencies and sub-dependencies
  13. if you are in current Search Experience A/B test cell, The JavaScript bundle that we send to the you - must include the current search component and dependencies that are needed by current search experience to work.
  14. Likewise if you are in new Search Experience A/B test cell then you should only get new Search components and dependencies that are needed by new search experience to work.
  15. So you can imagine that the code for app.js would look like this. Import currentSearch and import newSearch, then somewhere in the code we render only one of the component We import both the experiences even though we know only one of them will be executed.
  16. When we import both these experiences, our package contains all the files needed to support both currentSearch and newSearch component. But the fact is that several of these files will never be executed by the client device. A user will only be seeing one of the search experience. So, do you see the problem?
  17. The Problem so every great story starts with a problem! And we just saw how we are packaging 2 mutually exclusive code execution paths together…
  18. The fact is Netflix apps are huge, so when we put together such experiences togather our packages become really big! And these sizes are after applying uglification, minification and all sorts of optimizations. Do you think our users will appreciate downloading 10megs of JS code on their browser? I will not!
  19. We see - poor performance from these apps, painfully longer time to load and time to interactive. End result: Poor User Experience
  20. We see - poor performance from these apps, painfully longer time to load and time to interactive. End result: Poor User Experience
  21. So the challenge in front of us was - improving the overall user experience, The common conventions says we should be building and sending smaller packages! Can we build smaller packages that are very specific to user’s AB test allocation?
  22. But is that it?
  23. Turns out, Unfortunately, the answer is No! We run hundreds of AB tests… and That has side effects for our team! It affects the way we approach the task of javascript packaging Lets see how
  24. When people think of AB testing They typically think of 2 variations of a test experience variation A and variation B At netflix, we do `multi-variate` AB testing
  25. `multi-variate` AB testing means - multiple variations for each test And each cell leads to a slightly different experience Additionally, we run multiple `mutli-variate` tests
  26. Something like this. We are collecting data to gauge which cell performs better.
  27. How users are allocated to these tests is completely random, as long as they meet certain criteria, they can be allocated into any of these AB test cells They see a user experience that is unique and is based on test cells they are allocated to.
  28. how many such custom and highly targeted packages do we need to build and serve? Any guesses on how many packages we should be building here? The math here is - number of items in each set multiplied by each other,
  29. i.e number of test cells in each test multiplied by each other Lets make it simple - consider just 15 A/B tests
  30. Let’s assume, we just run 15 AB tests with 4 variants in each test doing our math this number is...
  31. This number is 4 to the power 15 And thats is
  32. Over a Billion unique packages That is a huge number of unique experiences we want to serve. And yes, with more AB tests this number is just going to grow
  33. But we run 100s of AB Tests, and assuming each test still has only 4 variations
  34. Then this number is mind boggling - 4 ^ 100 is a very large number number, a number that I cannot fit on this slide
  35. So mathematically we know we might be serving billions of packages
  36. The problem is pretty clear now We want a system so that we can serve billions of smaller packages - These packages need to be highly targeted and tailored specifically to a Users AB Test allocation, device, region and few other dimensions. How can we even manage packaging at this kind of scale? Can we really pre-build billions of different variations? Of course not! At this scale it is unreasonable to prebuild all the variations. Do we all agree?
  37. So we dressed up like Defenders and decided to solve this. We were as are as serious as Luke Cage and Jessica Jones. Just to clarify - I wore the suit. Most of the solutions attempt to tackle this at the client side. We thought pretty hard about it and we realized something - we have a server, if we can build a service that can quickly package files and serve the targeted packages then we might be able to solve it. We are talking about generating the bundles on-demand.
  38. We looked back and noticed that developers use simple conditions to gate the experience. So for the current and new Search experience you can think of the 2 variations being gated by a boolean flag called newSearchExperience
  39. For our runtime bundling to be successful it needs to be fast, that means we should do some pre-work. What if we can pre-determine the conditions or flag that triggers the the inclusion of a file, and provide that information to our on-demand bundler? We cannot expect the bundler to figure out all of the repo’s structure at the time of on-demand bundling.
  40. What we are looking for is, Step 1 at Build Time - use some static analysis magic to determine what are the different AB test variations that exists, and determine the conditions or flag that triggers the the inclusion of a file, And then step 2 at Runtime - when devices ask for the JS package we apply some smart resolution logic, figure out the the files of files needed for AB Tests experience and finally generate a package dynamically
  41. We chose NodeJS to do the request time resolution of the files to be included in a bundle, and decided to use Webpack to do the static analyses at build time We chose webpack because it has a great ecosystem of plugins, most developers are already comfortable working with it. Its performance is good and we felt it had all the right hooks and options to customize the behaviour
  42. So the proposed build process was - Phase 1 Webpack reads our repo, analyses our code and produces an artifact. This artifact has all the metadata of how different files are related aka dependency graph, all metadata needed to resolve conditions, all the transpiled and optimized source Think - like a binary of the App
  43. Phase 2: Happens on the server side, the server uses the same artifact to generate packages. The artifact acts as the single store which contains the dependency information, All the source code Conditions and what it takes to resolve the conditions. So this artifact is like whole repo put together in one file
  44. We understand the problem, we know what kind of system we want to build and now lets explore the some concepts and questions that we need to solve.
  45. To make our build process work, it is important to understand what exactly needs to go into the artifact.
  46. This artifact should ideally have The dependency graph,
  47. This artifact should ideally have all metadata needed to resolve conditions,
  48. And - all the transpiled and optimized source Think of it like a single file binary of the App. It has all the content from your source files from the repo! You can see the similarity between this file and the way webpack generates its output file. (This artifact should store the metadata that says - newSearch component and its dependencies should only be included if the condition `newSearchExp` is true. That means we need to store all the conditions, modules that cannot be included until the conditions are true)
  49. We want to use webpack to build this conditional dependency graph. And we want webpack to then serialized the graph into a file and this file will be our artifact file.
  50. So the terminology - conditional dependency graph sounds complicated, but it isnt. Its a dependency graph with additional data that highlights the fact that app.js needs newSearch component only when newSearchExperience flag is true. So newSearch Component is the conditional module, and newSearchExperience is the condition.
  51. So, the next question we needed to solve is - How do we mark a JS file or module as conditional? And how do we make Webpack’s build process understand that the module is conditional?
  52. We introduced 2 ways of marking a file as conditional: The first option available to developers was using @condition <conditionName>. Soo= from our prev example of current and new Search component, the newSearchComponent could just announce to that hey I can only be included if `newSearchExperience` condition is true. If that condition is false, please dont include me. We want Webpack to see this syntax and mark the edge in the dependency graph as conditional
  53. The 2nd option available to devs was to require a file conditionally. That is to let the parent file decide which child component to include. In this case app.js uses a special $$conditions$$ syntax to determine which one should be included in the package. Again, we wanted Webpack to see this $$condition$$ syntax and mark the 2 edges between app.js -> newSEach and app.js -> currentSearch as conditional
  54. So, this brings us to our next question, How do we build a conditional dependency graph with Webpack?
  55. Simple - we built our own Webpack plugin. This plugin could understand the 2 syntaxes using AST parsing. Webpack provides a number of hooks, and we used those hooks to look at what files are being resolved by Webpack. The parser’s program is a hook on the Webpack parser and it returns the AST of the current file. Using this hook the plugin knows that these are certain files which either mark themselves as conditional or the parent file marks them as conditional We maintain the list of such conditionals and keep adding this information to the webpack’s internal dependency graph
  56. Finally, when webpack is done resolving and building the various files, we latch on to Webpack compiler’s emit hook. This is the right time to instruct Webpack to write out our Artifact file and we serialize all the graph information into this file.
  57. At this point, we have successfully serialized conditional dependency graph which represents the entire repo. In a way you can think of Artifact as the “build” or “compiled” output for your app
  58. We still have to perform the bundling. We solved one part of generating the artifacts. Let’s tackle the next. At netflix our on demand bundling service is called Codex.
  59. And then, the server can use the same artifact to serve user requests and generate bundles on demand based on the conditions that are valid. Theoretically this seems doable. Artifact provides all the necessary information around how the repo is structures, what and how are the dependencies between various components. TODO: set the right arrows, mark it clearly what is happening, what is being bundled and requested
  60. So we can expect many versions of the app, so we will have many versions of the artifact over time. Each build means new artifact. You can imagine these artifacts as binary of some sorts. With just these artifacts we want the ability to generate all the possible combinations of bundles for that particular build version.
  61. And these artifacts are for our website (netflix.com), the TV app (which is also built using React). These apps will have multiple releases and all of a sudden we have multiple apps producing multiple artifacts that we need to server
  62. So we can imagine that our service Codex gets a request from our subscribers watching netflix on their TVs or Browsers. And Codex is creating the highly targetted packages for these users It is able to figure out different files to combine and looks at what are the various AB tests the user is allocated to, based on what device are they access it from, based on geo-location and so many other dimensions
  63. At this point you must be wondering - How exactly do we resolve the conditional dependency graph? How does the runtime even know that certain experiences needs to be unlocked for a user because they belong to the right AB tests and are using the right browser or device etc.? Let’s look at it in detail.
  64. The one of the interesting things we did - was around the bundle request URLs. The URLs you see here are actually templatized and they tell us exactly which artifact is being requested, which app, which version, which entry point and what are the experiences to unlock! The last section containing the comma - delimited values are the actual conditions that are true for the user. So the URLs contain almost everything we need to resolve our files
  65. The URL clearly specifies hey look for webui, version 3 artifact
  66. And by the way, when you are resolving, just consider that these conditions are set to true
  67. And start resolving your dependency graph, starting from app.js, and apply the conditions
  68. And once we apply the conditions, we know the exact list of files we need to package, we cobble those together and send it back!
  69. So the actual graph resolution algorithm we use is quite simple. Consider the graph resolution with these 2 boolean conditions set to true. As you can see as we start traversing the graph, we immediately hit a fork and need to serve only one of the experiences. In this case `newSearchExp` is true, so we bring in all its deps and sub-deps
  70. As we walk down the graph, we stop until we find another conditional edge and then re-evaluate if the conditions are true or not. Ex we stop at `smartPlayback` and `smartSession` conditional edges. At this point we see smartPlayback is true and we can pull in this file and its dependencies but because `smartSession` is not true we dont travel down that path.
  71. So, once we resolve the conditions, we might get the final bundle consisting of only these files. This is a very small bundle, highly targeted, very specific user experience for the User // improve the graph, dim or darken the one’s that is not used
  72. The original full dependency graph has now been pruned to include only the one’s that makes sense for this user with current set of conditions. No unnecessary files will make it into the bundle. We have cut down the graph by more than a half just by this resolving the conditions
  73. At this point you must be like - isn’t all of this graph resolution and bundling really slow?
  74. We have spent a lot of time optimizing this and now with optimizations like use of memoization and storing the graph information on the instances Using multi level caching of the artifact information We are seeing a response time that is < 70ms for the website app and closer to 400 ms for our TV app. This is p95 latency seen to package all the files together. We are still optimizing the bundling process and as we add more optimizations we are confident that we can bring down these numbers even further.
  75. Another benefit of having a URL that defines the complete state is that now we can use CDN’s effectively. Codex services are fronted by a CDN (akamai and Netflix’s own CDN) and that ensures our bundler as a service is never serving the same bundle again and if we do see a request for the same bundle, CDN can serve the
  76. To summarize the whole process
  77. UI developers clearly mark the conditional flag in their code and are explicit about telling which condition should fetch which UI component. This is achieved with @condition code comment and or $$conditions$$.<conditionName> syntax.
  78. Next you run webpack with our plugin. Plugin is designed to read the webpack internals, figure out the dependency graph, find all the conditions in the code, find all the modules that should be conditional and builds a conditional dependency graph.
  79. This graph is then serialized and saved. You can consider these serialized artifacts as the build output for that version of the app.
  80. Next, we just provide this artifact to the codex service which our the dynamic bundler capable of building packages at runtime
  81. Our subscribers use netflix.com or apps and they request for the bundles passing the features or abtests a user belongs to, and Codex - our Bundling as a Service now builds the right package and serves it. The served bundle also gets cached at our CDN layer.
  82. Building Codex at Netflix scale wasn’t easy and we stumbled a lot and hey nobody ever said setting up a new service is easy! As I wrap up here, I wanted to talk a little bit about what are the next few things we plan to work on
  83. To keep our services performant we need to make sure we only have the active and most freq used artifacts in memory and we have incentives to quickly eliminate those artifacts that are not used. TVUI and WebUI teams push out new versions at least twice in a week! So that is minimum of 4 release uploaded into Codex. So the question is - how far back should we go in time and support the bundles? We are still debating and figuring out the best strategy. We have manual steps to remove artifacts but we want to automate that and use smart heuristics and make some judgement about it
  84. We want to leverage the awesome Webpack and its ecosystem but at the moment we have a few restrictions since we are creating a custom artifact and there is a specific way to serve and consume bundles that depends on this artifact. At the moment we do not support sourcemaps with current setup and that is something we want to build very soon. We are exploring ways to make sure our bundles can work with existing webpack’s dev server, that will enhance the local developer experience. We are also exploring bundle optimization options that webpack can do on our dynamically generated bundles.
  85. Thats all for today, my name is Rajat Kumar. Feel free to reach out to me, you can also find me after this and I will be happy to talk and take questions. Thank you and have a great day.
  86. The Problem // so every great story starts with a problem!
  87. The Problem // so every great story starts with a problem!