What is System Design? A Beginner-Friendly Introduction
Welcome To AfterAcademy!
Today, we are going to learn "What is System Design?". The goal is to make you understand what is System Design which means that there are few simplifications done while writing this. If you understand what System Design is, then my mission will be accomplished. If you read this article completely, I am sure my mission will be accomplished.
Let's get started to learn System Design.
What is System Design?
System Design is the process of defining the components, API, database tables, etc for a system to satisfy the specified functional and non-functional requirements.
It might be difficult to understand the above definition. Let's break it down and understand.
System Design = System + Design
System: Assembly of different components for the specified requirements.
Design: How efficiently the assembly of different components is done.
Let's take the example of YouTube to understand the above definition. We will just talk about the high-level components to understand what is System Design.
YouTube is a video sharing platform with many features. YouTube system can have requirements such as:
- Upload video.
- View, share, like, unlike, comment on the video.
- Search for any video, channel.
- Subscribe to a channel.
- Add video to a playlist, favorites.
- Count the number of views.
- Watch History.
- Any video uploaded by a user should not be lost.
- There should be almost no downtime.
- The video should play without lag. Low Latency.
- The system should be easily scalable.
One important thing is that based on the requirement we decide what is important, what is not and where we can do tradeoffs and where not. It's all about balancing the things. For example:
- Important: Real-Time Streaming of Video and Video should not be lost.
- Not Important: Number of views on a video. No real-time sync across multiple same types of servers. So, on multiple servers, we can have a different number of views for a particular video. At user end, the number of views might differ. Although it will get synced gradually.
So, we need to satisfy each and every above-mentioned requirement by defining the components, API, database tables, etc. Let's see what we do here:
- Defining the Scope of the system: For example, in the above, we do not have Video recommendations. The scope must be defined clearly to some extent.
- Estimation: Based on the number of users, we can estimate the total storage and bandwidth.
- Components: Based on the scope, we can define the various components such as video uploading, video processing, database to store video metadata, database to store user data, and etc.
- Database Design: Choosing databases between SQL vs NoSQL, designing schema.
- API Design: Exposing the functionality through API. For example, upload, play, like, comment, and etc.
- Storage System: Choosing an efficient storage system to provide a better user experience. Making multiple copies of important data so that any video will not be lost in case of some failure.
- Caching: Caching the data at some level to make the system fast. It will help in playing video without lag.
- Load Balancing and Distributed System: To evenly distribute the load across all the servers. It can help in achieving almost no downtime and also when scaling if required.
- And many more things.
Now, we know What exactly comes under the System Design.
If you see closely, what we have done, we are actually using the concepts of Computer Science such as Computer Network, Distributed Systems, Parallel Computing to build a large scale system in which we are able to achieve things like:
- Easily Scalable. Adding a new machine or increasing the size of the current machine should be easy to scale.
- Almost no downtime. Any request to the server should not fail.
- Low Latency. API should be fast. We should optimize the network calls, database queries.
- Multiple copies of the server. In the case of hardware failure, it should be easily able to up with almost no downtime.
- Syncing across multiple same types of servers for data consistency.
- Evenly distributed load across all the servers.
- Reusable components.
- All components should work together as a system.
- Each component should work at its best efficiency.
In order to achieve these above mentioned, we try to assemble all the components efficiently. It is really very interesting.
I think we have received a good amount of knowledge today. Thank you so much for your time.
That's it for now. Very soon, I will be coming up with new articles like Designing YouTube, Uber, Instagram, and etc.
Do share this blog with your fellow developers to spread the knowledge.
Happy Learning :)