Introduction to System Design for Newbies: Part 1

What is System Design?

System design is crucial for creating solutions that align with business requirements. It involves making strategic decisions early in the development process to ensure scalability, resilience, and flexibility. As the system evolves, having a well-thought-out design makes it easier to manage architectural changes effectively.

Introduction to Distributed System

We will be taking a real world example of opening a burger shop and how can we scale it ? We will be going through what happens in the background and will also cover various important terms related to System Design.

  1. Initially , we have one chef . The problem with this is that a single chef cannot handle many orders.
    Solution: ask the chef to work harder and pay them more .
    Optimising current resources and getting better output is known as vertical scaling. Another solution is to simply prepare the orders beforehand when the shop is closed also known as preprocessing or cron job.

  2. Now that we have the shop running , how can we make it resilient?
    Suppose one day the chef falls sick and your business will come to a halt.
    Solution: hire another backup chef so that you do not lose on business just because you had a single point of failure (single chef).

  3. In fact , you can hire more chefs so that you can get more work done in the same amount of time and this process is known as horizontal scaling.

  4. Now our shop is going at a good pace and handling more orders , lets see how we can expand the business?
    Lets say we also start offering sandwiches alongwith burger. Now we have some chefs who are specialist in burger and others in sandwiches. For optimal approach, we will play on their strengths and assign the burger chefs to make burgers and sandwich chefs to make sandwiches.
    So now what we have is a system where the responsibilities are quite well defined and we are not handling anything outside the business use case .This is an example of a microservice.

  5. Now our system is to a large extent scalable but we also need to think of some other problems. What if there is a power cut or the police come and shut down your shop on some issue? That would be serious.
    Solution: open a backup shop in another place .Now we have built a distributed system.
    Also the complexity has increased since now we will also need to establish proper communication between the two shops like when an order comes to the main shop, should it be prepared in the main shop or the backup shop? Plus the backup shop can handle local orders for faster delivery. This is known as partitioning.

  6. Now since we have two shops ,we will need a central authority to handle the orders of the customers and route each to the shop which will take the least time to deliver it to the customer. This central authority is the load balancer and optimises the process of route handling and eventually leads to cost saving.

  7. The system is now fault tolerant .But how do we keep it flexible or extensible?
    Like for a delivery agent ,it does not make much difference that from which shop they are picking up the order and similarly for the shop it does not matter whether the customer himself/herself or the delivery agent is coming to pick up the order. So here we need separate managers for handling separate duties. This process of separation of duties is known as decoupling. It will also lead to better logging and metrics where separate managers keep track of their duties realtime. Hence the system remains extensible.

So what we have done is take a real world problem, find out various problems we can encounter and also figure out their solutions on a higher level. This is known as High Level Design.

Wrapping up

So thats it! Thanks for reading and I will be back with another informative blog!

0
Subscribe to my newsletter

Read articles from Mainak Mukherjee directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mainak Mukherjee
Mainak Mukherjee