Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 8 Next »

The Framework proposed in this space (Alex Xu) is applied to propose a design : Getting started - a framework to propose...

Introduction

We can do a lot more on YouTube than watching a video. So, we must narrow down the scope.

Step 1 - Understand the problem and establish the scope

Required features ?

Upload and watch video only.

What clients do we need to support ?

Mobile App, Web App, Smart TV.

How many daily active users ?

5 million

Average daily time spent on product ?

30 min.

Support international users ?

Yes.

What are supported video resolutions ?

Most of the video resolutions and formats.

Encryption required ?

Yes.

File size requirement for videos ?

Max size = 1 GB.

Leverage cloud infra (Amazon, Google, Microsoft)

Recommended to use existing cloud services.

Focus : ability to upload videos fats, smooth video streaming, ability to change video quality, low infra cost, HA, scalability and reliability, clients supported (mobile, web and smart TV).

Back-of-the-enveloppe estimation

  • 5 million daily active users (DAU)

  • 5 videos per day.

  • 10% of users upload 1 video per day.

  • Average video size = 300 MB.

  • Total daily storage = 5 million * 10% * 300 MB = 150 TB.

  • CDN cost :

    • CDN serves video, we are charges for data transferred out of CDN.

    • Average cost per GB is 0.02$ for USA.

    • 5 million * 5 videos * 0.03GB * 0.02$ = $150000 per day.

On this page.

Step 2 - High-level design

From the design above, 2 flows could be considered:

Video uploading flow

Transcoding servers : video transcoding is called video encoding. It’s the process of converting a video format to other formats (MPEG, HLS, etc.) which provide the best video streams and bandwidth capabilities.

Original and transcoded storage are BLOB storage.

Metadata cache is for better performance. Once the video has been uploaded, the user sends a request to update the video metadata (size, format, file name, …).

Video streaming flow

Streaming protocol like Microsoft Smooth Streaming, Apple HLS, etc. Video are streamed from CDN directly and there is very little latency.

Step 3 - Design deep dive

The DAG Model (Directed Acyclic Graph)

DAG Model help to achieve flexibility and parallelism.

Video transcoding architecture (leveraging cloud services)

  • Preprocessor has 4 responsibilities:

    • video splitting into smaller GOP (Group of pictures).

    • Splits videos by GOP (Group of pictures) alignment for old clients.

    • Generates DAG based on config files client programmers writes.

    • Cache data.

  • DAG Scheduler splits a DAG graph into stages of tasks.

  • Resource manager : It contains 3 queues and a task scheduler.

    • 1 Task queue : priority queue containing tasks to be executed.

    • 1 Worker queue : priority queue containing worker utilization info.

    • 1 Running queue : contains info about currently running tasks and workers running tasks.

    • Task scheduler picks optimal task/work and instructs the chosen task worker to execute the job.

System Optimization

Speed Optimization

→ Parallelize video uploading from client

→ Parallelize video encoding : Introduction of Message Queue

Safety Optimization (Pre-signed upload URL & protect videos)

Cost-Saving Optimization

  • No labels