Design a Youtube like video streaming service (early draft)

Welcome to the second second system design series. In this post we will take a look at how to approach designing video streaming services like youtube.

This approach can also be considered for designing streaming service like Netflix. Though architecturally both differs, but from a very high level perspective similar design decisions can be implemented.

In the process will touch base on below technical aspects as part of designing this system.

  • CDN
  • Cache
  • Sharding (divide database into multiple parts)
  • HDFS (Store video)
  • Google BigTable (Store thumbnails)
  • Encoding

The MVP requirements

  • Users should be able to upload videos
  • Users should be able to view videos
  • Users should be able to add and view comments on videos
  • Users can perform searches based on video titles
  • Users should be able to like/dislike videos

Representative YouTube Tech Stack

  • Apache
  • Python
  • Linux
  • MySQL/MariaDB
  • lighttpd for video (

Do note however that, it’s not required to use the same tech stack as used by x or Youtube to get similar site performance and scale.

High Level Overview

When designing systems like this it’s always better to start with a high level overview of the system before going into the details.

So, basically, we can simplify the system into the following major components.

  • Web Server
  • Storage
  • Cache
  • Scalability
  • Sharding
  • Recommendation System

For this discussion I am not pondering over the security system and other miscellaneous components.


There goes famous saying. The two most hard things in computer science is naming things and cache invalidation (of-course there are many more hard problems).

What problem does cache solve?

Cache helps avoid frequent reads from disk. Reading from physical hard disk is one of the slowest operation. In applications that need to frequently read from database or file, the performance bottleneck is usually the disk.

This problem is solved by cache, because cache primarily stores data in memory(RAM) and accessing data from RAM is one of the fastest operation.

Limitations of cache

Of course, with cache some precautions has to be considered as memory is limited. The below list highlights some of the primary limitations and challenges with cache.

  • Memory usually is limited and isn’t large enough to hold the entire data set. So, devs have to be careful with respect to the usage of cache.
  • Data is lost if power lost or machine rebooted/restarted.
  • Cache Invalidation strategy should be in place to avoid stale data being served to the client (this varies from application to application)


Sharding essentially breaks the data into different partitions. This help scale up the databases across different machines to improve performance and availability.

Availability / Redundancy

When designing a system planned for scale, it is common to replicate each components of the system like web server, app server, database to make sure there is no single point of failure.

It greatly increase the availability by adding redundancy.

Load Balancer

As we introduce redundancy to avoid single point of failure there has to be a way to balance load across all the redundant components. This is where load balancing comes into action.

The load balancer typically sits between a client and servers. It routes the request from client to a server to make sure all servers have similar load.

Some questions to ponder over for load balancing.

  • How should we distribute the requests to different servers
  • Do you want to support sticky sessions?
  • and more

There are many algorithms that can be used in load balancer, e.g. round robin, least response time, least connection method etc.


SQL and NoSQL databases are two primary approaches in which you approach a database storage.

In SQL data models are relational, meaning all rows have the same column /attributes.

Whereas a NoSQL has very flexible schema. Each document in a NoSQL can have different attributes and these attributes can be dynamically added as well (of course schema validations are there as required).

Besides there are other differences which I encourage the readers to research on the subject.

Next Step

For the curious among you, it will be a good activity to dig into the details of the tech stack mentioned.

Probably once I done with the foundational discussion about system design, will work/upload sample implementation.

In case anyone has already done, please feel free to share the repo/blog link in the comment.

NOTE: This is a work in progress (draft tutorial for early review). Please use comments tot make this article more useful.

#csforall #systemdesign #interviewpreparation #algorithms #youtube #netflix #messagequeue #faang #productcompany

How useful was this post?

Click on a heart to rate it!

Average rating 4.8 / 5. Vote count: 5

No votes so far! Be the first to rate this post.

Leave a Reply