SlideShare a Scribd company logo
2
Most read
5
Most read
System Design For Video
Streaming Service
ZoneLB
LBLBLB
Zone2Zone3Zone1
M2M3M1M3M2M1M3M2M1
CDN Object
Storage
Video
Transcoding
Video Upload
Library
DB
(NoSQL)
In-Memory
DB
Auth/User
DB (SQL)
Billing DB
(SQL)
API
Gateway
Queue
M2M1
R2R1
MapReduce
mp4
1080p
mp4
720p
mov
1080p
Hadoop Cluster
Recommendation
Engine
OAuth
…..
ZoneLB
LBLBLB
Zone2Zone3Zone1
• Request arrives at the zone level load balancer
• The zone load balancer is responsible for routing the requests to the
correct zones
• The zone load balancer would use geolocation-based routing policy
• Using Geolocation based routing policy allows for
⁻ Low latency
⁻ Region based distribution/availability of content and/or features
• In addition to using geolocation-based routing, the system will also use
health checks to determine the health of a zone and re-route traffic to
another zone in case the geo-location based chosen zone is unhealthy
• Using a multi-value routing policy enables the system to continue to be
highly available at the cost of some performance even during zone
outages
• Routing traffic to a non-preferred zone would still need to be constrained
since connecting to any zone could result in issues with region based
content delivery
Zone Load Balancer
• Once the request is routed to a zone, each zone has a set of load balancers
• These load balancers are responsible to route the traffic to the servers
• The routing policy for these 2nd level load balancers would be round-robin
• Choosing round robin as the routing policy ensures that no server/instance
is overused leading to failures
• This load balancer also checks for the health of their instances/servers in
order to not route the request to a server in a bad state
Regular Load Balancer
LBLBLB
Zone2Zone3Zone1
M2M3M1M3M2M1M3M2M1…..
• Once the request reaches the instance, it is first greeted by the API Gateway.
• When using AWS, we could use the API Gateway service provided by AWS
but for flexibility purposes, we chose to have a 3rd party/ home grown API
gateway in this case
• The API Gateway can then route the request based on the endpoint to either
services hosted on other instances or micro-services or even present as logic
in the instance itself
• In this particular architecture we are choosing to have the business logic / API
endpoint functions within the instance. For example, logic for authentication
or billing or the logic for fetching the recommendations / watch history from
the in-memory database
• This could be extended to instead use micro-services for each of the logic /
API endpoint functions too.
• These instances are configured to be dynamically scalable
₋ Horizontal scaling for AWS/Azure
₋ Combination of Horizontal and Vertical Scaling if using custom cloud
Instances / Servers
Auth DB
(SQL)
Billing DB
(SQL)
APIGateway
API call
Login
API call Get
Library
API call Set
Watched
API call
Get Info
• The main database architecture is designed to be fast and reliable with a combination of NoSQL and in-memory database
• The Library DB as seen in the architecture diagram is used to store data such as
⁻ Names and metadata of video titles ( such as movies and tv-series )
⁻ Each users watch and search history
⁻ Other metadata for each user which can be used in analytics such as watch times, which titles the user engaged more
with, etc
⁻ Some of this metadata is written / updated with user actions ( such as adding a title to the users watch history as soon
as they play the title for x seconds/minutes, while some are updated by services such as recommendation engine (
example, adding titles to the recommended field/key after running through the algorithm for recommendation )
Database
Library
DB
(NoSQL)
In-Memory
DB
• This database is chosen to be NoSQL since there are some key characteristics about the data stored :
⁻ The number of writes to this database is not very high due to the nature of the data
⁻ NoSQL will allow us to shard the data better in order to be able to scale horizontally in the database cluster
⁻ Data for each user can be consolidated within one document and fetched with 1 call instead of having multiple tables
and/or performing joins etc as in relational dbs
⁻ Similar case applies for data about each title. All metadata can be consolidated within one document
• In addition to the NoSQL database, we have added an in-memory database ( such as Redis ) to allow for faster read times
• This will allow us to not only deliver initial content quickly to the client, but also help with features such as fast search, etc
• The In-Memory database can be configured to persist data at either regular intervals or at every write. In case of this
architecture though, regular interval updating makes more sense because none of the data we are storing is time-critical.
For example, if we are writing the time stamp for when the user/client paused a video. In this case, if the data in memory is
lost for some reason, and the pause time stamp is not updated in persistent storage, it still does not affect the usability of
the system. By making this decision we are prioritizing performance over consistency for non time-critical data
• For enabling fast searches, we can use custom Redis solutions that enable representing a prefix-tree / trie in the Redis key-
value format. Prefix trees allow for quick string searches. Prefixy is an implementation that allows for such a Redis mapped
prefix tree along with ranks for searches based on popularity.
Database
• When a new title needs to be uploaded to be served via the video streaming platform, we go through a series of steps to
make sure of seamless delivery of the content
• A newly uploaded title first goes through the process of transcoding ( converting the video into multiple formats and
resolutions )
• The processed videos are pushed to an object storage for persistent storage
• In order to facilitate fast and reliable streaming though, these videos/titles are then pushed to CDN servers around the
world to enable availability as close as possible to a client
New Content onboarding and delivery
CDN Object
Storage
Video
Transcoding
Video Upload
• Video transcoding is the process of converting a video into multiple formats
and multiple resolutions for each format
• This is required in order for providing seamless service even at low
performing internet speeds at the client side
• In our system the transcoding process is done with a Hadoop cluster
• When a title is uploaded, it gets queued in HDFS to be processed
• The title is broken down into multiple chunks to be processed by the
mappers
Video Transcoding
Queue
M2M1
R2R1
MapReduce
mp4
1080p
mp4
720p
mov
1080p
Hadoop Cluster
• Mappers convert the chunks of video into different video formats and resolutions
• These chunks are then re-stitched into a single title with the reducers and then written out along with extra meta-data
• The converted titles are then pushed to an object storage for persistent storage as mentioned before
• The recommendation system in our services uses AI/ML for recommendation
• The recommendation system uses 2 types of ML techniques
‾ Content Based
‾ Collaborative Based
• In the content-based system, the recommendations are calculated based on
each user’s watch and search history
• In the collaborative-based system, the recommendations are calculated based
on the results of multiple users and various trends
Recommendation Engine
Recommendation
Engine
• The recommendation system in our service would also take into consideration the times of the day, week or year, etc
• For example, which type shows are usually more viewed on weekends ( drama vs family show ) or during different times of
year ( Halloween time vs Christmas )
• The recommendation system then updates the in-memory database which holds the “landing page” for each user with the
personalized recommendations at regular intervals
• Client side : React JS / React Native
• Authorization : OAuth 2.0
• Authentication : OpenID connect
• Load Balancer : HAProxy+GeoIP / AWS ELB / Azure LB
• Backend : Python
• Databases :
₋ MySQL for billing and user/auth database
₋ NoSQL database like MongoDB / DynamoDB ( AWS )
₋ Redis for in-memory database
• Video Transcoding : Hadoop Map-Reduce
• Video Storage : Object Storage ( S3 : AWS / Azure : Blob )
• CDN : Akamai / AWS CloudFront / Azure CDN
• Recommendation Engine : Custom python implementation / AWS Personalize / Azure ML service
Technologies
• Prefixy : https://prefixy.github.io/
• HAProxy as LB : https://www.linode.com/docs/uptime/loadbalancing/how-to-use-haproxy-for-load-balancing/
• GeoIP with HAProxy : https://www.haproxy.com/blog/use-geoip-database-within-haproxy/
• CDN : https://www.akamai.com/us/en/resources/cdn-video-streaming.jsp
• Netflix System Design :
https://medium.com/@narengowda/netflix-system-design-dbec30fede8d
https://www.youtube.com/channel/UCn1XnDWhsLS5URXTi5wtFTA
• Redis for landing page ( similar to twitter timelines ) :
https://blog.twitter.com/engineering/en_us/topics/infrastructure/2017/the-infrastructure-behind-twitter-scale.html
• OAuth 2.0 and OpenID Connect : https://www.youtube.com/watch?v=996OiexHze0&feature=youtu.be
• Hadoop for Video Transcoding :
https://content.pivotal.io/blog/using-hadoop-mapreduce-for-distributed-video-transcoding
https://pdfs.semanticscholar.org/43b9/bab9b801f0e548e97462ccc94089dd13b2c6.pdf
References
Thank You!

More Related Content

PPTX
PDF
Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...
PDF
Easy, Secure, and Fast: Using NATS.io for Streams and Services
PPTX
Kubernetes introduction
PPTX
An Introduction to Confluent Cloud: Apache Kafka as a Service
PDF
Your Roadmap for An Enterprise Graph Strategy
PPTX
Prometheus - Intro, CNCF, TSDB,PromQL,Grafana
PDF
Elasticsearch
Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...
Easy, Secure, and Fast: Using NATS.io for Streams and Services
Kubernetes introduction
An Introduction to Confluent Cloud: Apache Kafka as a Service
Your Roadmap for An Enterprise Graph Strategy
Prometheus - Intro, CNCF, TSDB,PromQL,Grafana
Elasticsearch

What's hot (20)

PPTX
PPTX
What is AWS Glue
PDF
OpenShift-Technical-Overview.pdf
PDF
Designing microservices platforms with nats
PPTX
Recommendation at Netflix Scale
PPTX
Modern CI/CD Pipeline Using Azure DevOps
PDF
VictoriaLogs: Open Source Log Management System - Preview
PPTX
Prometheus in Practice: High Availability with Thanos (DevOpsDays Edinburgh 2...
PDF
Distributed tracing using open tracing & jaeger 2
PPTX
Data Streaming with Apache Kafka & MongoDB
PDF
Kubernetes Security with Calico and Open Policy Agent
PDF
DevOps: Benefits & Future Trends
PDF
Thanos: Global, durable Prometheus monitoring
PPT
Unit 4
PPTX
Couchbase presentation
PDF
Grafana introduction
PPTX
The Top 5 Apache Kafka Use Cases and Architectures in 2022
PPTX
Prometheus Training
PDF
모든 데이터를 위한 단 하나의 저장소, Amazon S3 기반 데이터 레이크::정세웅::AWS Summit Seoul 2018
PDF
AWS vs Azure vs Google (GCP) - Slides
What is AWS Glue
OpenShift-Technical-Overview.pdf
Designing microservices platforms with nats
Recommendation at Netflix Scale
Modern CI/CD Pipeline Using Azure DevOps
VictoriaLogs: Open Source Log Management System - Preview
Prometheus in Practice: High Availability with Thanos (DevOpsDays Edinburgh 2...
Distributed tracing using open tracing & jaeger 2
Data Streaming with Apache Kafka & MongoDB
Kubernetes Security with Calico and Open Policy Agent
DevOps: Benefits & Future Trends
Thanos: Global, durable Prometheus monitoring
Unit 4
Couchbase presentation
Grafana introduction
The Top 5 Apache Kafka Use Cases and Architectures in 2022
Prometheus Training
모든 데이터를 위한 단 하나의 저장소, Amazon S3 기반 데이터 레이크::정세웅::AWS Summit Seoul 2018
AWS vs Azure vs Google (GCP) - Slides
Ad

Similar to System design for video streaming service (20)

PPTX
On demand video_streaming_apps_and_its_server_side_cloud_infrastructure_at_aws
PPTX
AWS re:Invent 2013 Recap
PPT
EQR Reporting: Rails + Amazon EC2
PPTX
TV3.0 New TV frontiers.
PDF
Mux loves Clickhouse. By Adam Brown, Mux founder
PPTX
Building an recommendation system for IPTV on a fast streaming architecture -...
PPTX
Cinema booking system | Movie Booking System
PPTX
AWS re:Invent 2013 Scalable Media Processing in the Cloud
PDF
VTU 6th Sem Elective CSE - Module 5 cloud computing
PPTX
Big Data_Architecture.pptx
PDF
ParisfxLab - Cloud4Media
PPTX
Netflix Edge Engineering Open House Presentations - June 9, 2016
PDF
An intro to Amazon Web Services (AWS)
PPTX
Maintaining the Front Door to Netflix
PDF
Lot Explorer Report
PDF
Service-Oriented Design and Implement with Rails3
PDF
ROMA User-Customizable NoSQL Database in Ruby
PDF
Tv and video on the Internet
PDF
Android Mobile Application for Video Streaming using Load Balancing
PDF
Challenges and requirements for a next generation service for video content s...
On demand video_streaming_apps_and_its_server_side_cloud_infrastructure_at_aws
AWS re:Invent 2013 Recap
EQR Reporting: Rails + Amazon EC2
TV3.0 New TV frontiers.
Mux loves Clickhouse. By Adam Brown, Mux founder
Building an recommendation system for IPTV on a fast streaming architecture -...
Cinema booking system | Movie Booking System
AWS re:Invent 2013 Scalable Media Processing in the Cloud
VTU 6th Sem Elective CSE - Module 5 cloud computing
Big Data_Architecture.pptx
ParisfxLab - Cloud4Media
Netflix Edge Engineering Open House Presentations - June 9, 2016
An intro to Amazon Web Services (AWS)
Maintaining the Front Door to Netflix
Lot Explorer Report
Service-Oriented Design and Implement with Rails3
ROMA User-Customizable NoSQL Database in Ruby
Tv and video on the Internet
Android Mobile Application for Video Streaming using Load Balancing
Challenges and requirements for a next generation service for video content s...
Ad

Recently uploaded (20)

PDF
Introduction to the IoT system, how the IoT system works
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PPT
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
PPTX
Slides PPTX World Game (s) Eco Economic Epochs.pptx
PPT
FIRE PREVENTION AND CONTROL PLAN- LUS.FM.MQ.OM.UTM.PLN.00014.ppt
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PPTX
artificial intelligence overview of it and more
PDF
Paper PDF World Game (s) Great Redesign.pdf
PPTX
Database Information System - Management Information System
PPTX
Introduction to Information and Communication Technology
PPTX
Internet___Basics___Styled_ presentation
PDF
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
PPT
Ethics in Information System - Management Information System
PPTX
Digital Literacy And Online Safety on internet
PDF
Sims 4 Historia para lo sims 4 para jugar
DOCX
Unit-3 cyber security network security of internet system
PPT
Design_with_Watersergyerge45hrbgre4top (1).ppt
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
PPTX
newyork.pptxirantrafgshenepalchinachinane
Introduction to the IoT system, how the IoT system works
Unit-1 introduction to cyber security discuss about how to secure a system
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
Slides PPTX World Game (s) Eco Economic Epochs.pptx
FIRE PREVENTION AND CONTROL PLAN- LUS.FM.MQ.OM.UTM.PLN.00014.ppt
Job_Card_System_Styled_lorem_ipsum_.pptx
Tenda Login Guide: Access Your Router in 5 Easy Steps
artificial intelligence overview of it and more
Paper PDF World Game (s) Great Redesign.pdf
Database Information System - Management Information System
Introduction to Information and Communication Technology
Internet___Basics___Styled_ presentation
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
Ethics in Information System - Management Information System
Digital Literacy And Online Safety on internet
Sims 4 Historia para lo sims 4 para jugar
Unit-3 cyber security network security of internet system
Design_with_Watersergyerge45hrbgre4top (1).ppt
INTERNET------BASICS-------UPDATED PPT PRESENTATION
newyork.pptxirantrafgshenepalchinachinane

System design for video streaming service

  • 1. System Design For Video Streaming Service
  • 2. ZoneLB LBLBLB Zone2Zone3Zone1 M2M3M1M3M2M1M3M2M1 CDN Object Storage Video Transcoding Video Upload Library DB (NoSQL) In-Memory DB Auth/User DB (SQL) Billing DB (SQL) API Gateway Queue M2M1 R2R1 MapReduce mp4 1080p mp4 720p mov 1080p Hadoop Cluster Recommendation Engine OAuth …..
  • 3. ZoneLB LBLBLB Zone2Zone3Zone1 • Request arrives at the zone level load balancer • The zone load balancer is responsible for routing the requests to the correct zones • The zone load balancer would use geolocation-based routing policy • Using Geolocation based routing policy allows for ⁻ Low latency ⁻ Region based distribution/availability of content and/or features • In addition to using geolocation-based routing, the system will also use health checks to determine the health of a zone and re-route traffic to another zone in case the geo-location based chosen zone is unhealthy • Using a multi-value routing policy enables the system to continue to be highly available at the cost of some performance even during zone outages • Routing traffic to a non-preferred zone would still need to be constrained since connecting to any zone could result in issues with region based content delivery Zone Load Balancer
  • 4. • Once the request is routed to a zone, each zone has a set of load balancers • These load balancers are responsible to route the traffic to the servers • The routing policy for these 2nd level load balancers would be round-robin • Choosing round robin as the routing policy ensures that no server/instance is overused leading to failures • This load balancer also checks for the health of their instances/servers in order to not route the request to a server in a bad state Regular Load Balancer LBLBLB Zone2Zone3Zone1 M2M3M1M3M2M1M3M2M1…..
  • 5. • Once the request reaches the instance, it is first greeted by the API Gateway. • When using AWS, we could use the API Gateway service provided by AWS but for flexibility purposes, we chose to have a 3rd party/ home grown API gateway in this case • The API Gateway can then route the request based on the endpoint to either services hosted on other instances or micro-services or even present as logic in the instance itself • In this particular architecture we are choosing to have the business logic / API endpoint functions within the instance. For example, logic for authentication or billing or the logic for fetching the recommendations / watch history from the in-memory database • This could be extended to instead use micro-services for each of the logic / API endpoint functions too. • These instances are configured to be dynamically scalable ₋ Horizontal scaling for AWS/Azure ₋ Combination of Horizontal and Vertical Scaling if using custom cloud Instances / Servers Auth DB (SQL) Billing DB (SQL) APIGateway API call Login API call Get Library API call Set Watched API call Get Info
  • 6. • The main database architecture is designed to be fast and reliable with a combination of NoSQL and in-memory database • The Library DB as seen in the architecture diagram is used to store data such as ⁻ Names and metadata of video titles ( such as movies and tv-series ) ⁻ Each users watch and search history ⁻ Other metadata for each user which can be used in analytics such as watch times, which titles the user engaged more with, etc ⁻ Some of this metadata is written / updated with user actions ( such as adding a title to the users watch history as soon as they play the title for x seconds/minutes, while some are updated by services such as recommendation engine ( example, adding titles to the recommended field/key after running through the algorithm for recommendation ) Database Library DB (NoSQL) In-Memory DB
  • 7. • This database is chosen to be NoSQL since there are some key characteristics about the data stored : ⁻ The number of writes to this database is not very high due to the nature of the data ⁻ NoSQL will allow us to shard the data better in order to be able to scale horizontally in the database cluster ⁻ Data for each user can be consolidated within one document and fetched with 1 call instead of having multiple tables and/or performing joins etc as in relational dbs ⁻ Similar case applies for data about each title. All metadata can be consolidated within one document • In addition to the NoSQL database, we have added an in-memory database ( such as Redis ) to allow for faster read times • This will allow us to not only deliver initial content quickly to the client, but also help with features such as fast search, etc • The In-Memory database can be configured to persist data at either regular intervals or at every write. In case of this architecture though, regular interval updating makes more sense because none of the data we are storing is time-critical. For example, if we are writing the time stamp for when the user/client paused a video. In this case, if the data in memory is lost for some reason, and the pause time stamp is not updated in persistent storage, it still does not affect the usability of the system. By making this decision we are prioritizing performance over consistency for non time-critical data • For enabling fast searches, we can use custom Redis solutions that enable representing a prefix-tree / trie in the Redis key- value format. Prefix trees allow for quick string searches. Prefixy is an implementation that allows for such a Redis mapped prefix tree along with ranks for searches based on popularity. Database
  • 8. • When a new title needs to be uploaded to be served via the video streaming platform, we go through a series of steps to make sure of seamless delivery of the content • A newly uploaded title first goes through the process of transcoding ( converting the video into multiple formats and resolutions ) • The processed videos are pushed to an object storage for persistent storage • In order to facilitate fast and reliable streaming though, these videos/titles are then pushed to CDN servers around the world to enable availability as close as possible to a client New Content onboarding and delivery CDN Object Storage Video Transcoding Video Upload
  • 9. • Video transcoding is the process of converting a video into multiple formats and multiple resolutions for each format • This is required in order for providing seamless service even at low performing internet speeds at the client side • In our system the transcoding process is done with a Hadoop cluster • When a title is uploaded, it gets queued in HDFS to be processed • The title is broken down into multiple chunks to be processed by the mappers Video Transcoding Queue M2M1 R2R1 MapReduce mp4 1080p mp4 720p mov 1080p Hadoop Cluster • Mappers convert the chunks of video into different video formats and resolutions • These chunks are then re-stitched into a single title with the reducers and then written out along with extra meta-data • The converted titles are then pushed to an object storage for persistent storage as mentioned before
  • 10. • The recommendation system in our services uses AI/ML for recommendation • The recommendation system uses 2 types of ML techniques ‾ Content Based ‾ Collaborative Based • In the content-based system, the recommendations are calculated based on each user’s watch and search history • In the collaborative-based system, the recommendations are calculated based on the results of multiple users and various trends Recommendation Engine Recommendation Engine • The recommendation system in our service would also take into consideration the times of the day, week or year, etc • For example, which type shows are usually more viewed on weekends ( drama vs family show ) or during different times of year ( Halloween time vs Christmas ) • The recommendation system then updates the in-memory database which holds the “landing page” for each user with the personalized recommendations at regular intervals
  • 11. • Client side : React JS / React Native • Authorization : OAuth 2.0 • Authentication : OpenID connect • Load Balancer : HAProxy+GeoIP / AWS ELB / Azure LB • Backend : Python • Databases : ₋ MySQL for billing and user/auth database ₋ NoSQL database like MongoDB / DynamoDB ( AWS ) ₋ Redis for in-memory database • Video Transcoding : Hadoop Map-Reduce • Video Storage : Object Storage ( S3 : AWS / Azure : Blob ) • CDN : Akamai / AWS CloudFront / Azure CDN • Recommendation Engine : Custom python implementation / AWS Personalize / Azure ML service Technologies
  • 12. • Prefixy : https://prefixy.github.io/ • HAProxy as LB : https://www.linode.com/docs/uptime/loadbalancing/how-to-use-haproxy-for-load-balancing/ • GeoIP with HAProxy : https://www.haproxy.com/blog/use-geoip-database-within-haproxy/ • CDN : https://www.akamai.com/us/en/resources/cdn-video-streaming.jsp • Netflix System Design : https://medium.com/@narengowda/netflix-system-design-dbec30fede8d https://www.youtube.com/channel/UCn1XnDWhsLS5URXTi5wtFTA • Redis for landing page ( similar to twitter timelines ) : https://blog.twitter.com/engineering/en_us/topics/infrastructure/2017/the-infrastructure-behind-twitter-scale.html • OAuth 2.0 and OpenID Connect : https://www.youtube.com/watch?v=996OiexHze0&feature=youtu.be • Hadoop for Video Transcoding : https://content.pivotal.io/blog/using-hadoop-mapreduce-for-distributed-video-transcoding https://pdfs.semanticscholar.org/43b9/bab9b801f0e548e97462ccc94089dd13b2c6.pdf References