System Design has become the most essential part of a software engineer’s job profile. It has also become a crucial part of the interview process as well be it a Big Tech – GAFAM or startup. Well, I got pushed into understanding system design at a very early time in my career and got exposed to some pretty cool stuff, which helped to understand the system better and give me a holistic view of what I am supposed to develop.
System design as a concept is huge, so I have planned to break this into smaller modules and put my ideas across multiple posts 🤞.
In this post, I will be discussing some basics of system design, let’s go!
What is System Design?
Technopedia defines system design as –
System design is the process of defining the elements of a system such as the architecture, modules and components, the different interfaces of those components and the data that goes through that system. It is meant to satisfy specific needs and requirements of a business or organization through the engineering of a coherent and well-running system.Technopedia
Let me break this down for you.
Assume you are one of the cool pragmatic freelancer in the town 😎 and you recently got a project where you need to build an application similar to Instagram.
So to begin you start with understanding the client requirements better. You understand the features of the system – This is the Requirement Gathering Phase, this is where you will have to understand 2 things:
1. Functional Requirements – Something similar to the features of the system
2. Non – Functional Requirements – Quality Attributes of the system
For our Instagram like application some of the functional requirements are as follows:
- User should be able to upload and download pictures
- User should be able to search other users
- User should have a profile
Some non-functional requirements will be like:
- SLA of 5 Nine’s
- System should be highly reliable
Once you have your requirements next step, understanding the Userbase and Capacity.
You will need to ask your client questions like:
- How large is the userbase?
- Estimating the todal space required based of average file size
In case of the Insta clone, lets assume we have 50 Million users and 3 Million active users / day. 1 photo = 300 KB Total space for a day: 3M * 300KB = 600 GB Total space for 5 years: 600 GB * 365 * 5 = 1095 TB (approx) This estimation helps with the Hardward procurement process
Now as you have your estimate and hardware ready let’s talk about some High-Level System design. Here we decide on the components to make the system. In case of the Insta clone we will have to deal with Images so you can either have a CDN or leverage S3, along with that we would need to save some image metadata that could reside in an RDBMS.
Now we have a good understanding of all the components of the system next let’s jump into Modeling Data. The designing of a database is all about having the right tables, with the right relationships in place(RDBMS).
In the case of our insta clone, we will have a User Model that will hold the user details along with that we would need a couple of models to handle the user’s photos an example is given below.
Now lets think about our backend services basicalled Detailed Design. Now here lets talk about some services that we would need.
Any new user who come to our platform, we need to register them, now how do we go about doing this should we leverage Oauth or have our own password management. Once we decide that lets think about the services for uploading images, searching images too.
#Register User registerUser(first_name, last_name...) #Get all images for the user userImage(user_id) #Search images searchImage(user_id, image_id...) #Upload new images uploadImage(user_id, description, location...) ...
Once our services are in place let’s look at the holistic system and jot down the bottlenecks, I think at this time we all know the major challenge would be managing this much data, also questions around would we assure the latency stays low.
Well, this post was just to give you an overall understanding of what system design really is, in the following post I’ll try going deeper into the topics and discuss further. 🥳