How to Design a Scalable System? — Part 1

Divya P
4 min readApr 8, 2023

--

System Design

For designing any application, it is important to make sure it is scalable. Before we deep dive into the concepts of system design, it is necessary to understand the basic working of the website.

The above diagram explains the general working flow of how the user request is processed.

Domain Name System (DNS)

It is a key value mapping store where all the IP addresses are mapped to the domain names. DNS will locate the server IP address containing the domain name. DNS returns the IP address to your browser from where the request has been generated and now the browser will redirect to the server which contains the IP.

Web Server

A web server serves you with the required data HTML page or JSON Object.

Maintaining a system with a single server setup is difficult. Because it has the major drawback of single-point failure. Therefore multiple server setups are made in most cases.

Load Balancer

It evenly distributes the request from the user to the number of servers available. When multiple requests reach the server load balancer helps to control the network traffic. It reduces the workload and latency. It is highly helpful in scaling the system.

Who does the user request communicates with the load balancer?

In the usual flow, the user communicates with the server through DNS which has the IP mapping of the server stored in it. Whereas in the load balancer, the server IP is not directly mapped in the DNS. So load balancer will have public IP which is mapped to the domain name in the DNS. And this IP communicates with the private IP of the web servers. The load balancer communicates with web servers through private IPs.

We require a database for a system that stores user data.

Data Replication

To avoid the time for data to be fetched from the database, we can replicate the database as a slave. Consider having a master database which many slave databases (copies of the master). Only the write, update and delete operations will happen in the master database. Read operations can be done from any of the slave databases. This reduces the waiting time for the requests to fetch from a single database. Even if any of the slave databases goes offline the request can be redirected to another slave DB. Data REplication has its own disadvantage where a slave database may not serve updated data sometimes. The missing data needs to be updated by running data recovery scripts.

Cache

The cache is a temporary storage where a large amount of data can be easily accessed from memory.

For Detailed info about cache. Refer to the below articles.

There are two types of cache: Redis and Memcache

Content delivery network (CDN)

When the user data are cached for easy retrieval why not the scripts, stylesheets, images, and videos of the page? A CDN is a network of geographically closest servers used to deliver static content for a better end-user experience. When the request is sent from the user instead of taking the data from the origin server it takes it from the nearest CDN server or edge server. If the data is not present in the nearest CDN, it requests from the origin server and caches the data before being served to the user. It highly helps to increase performance, speed, and reliability.

Database Scaling

There are two types of scaling vertical scaling and horizontal scaling.

Vertical Scaling - It is also known as scaling up where you add extra CPU, RAM, and Power to the existing hardware. It also has some hardware limits. A single server is not enough for a large application.

Horizontal Scaling — It is also known as sharding. Here we had more servers in the system instead of increasing the server hardware capacity.

To learn more about scaling refer to this article.

These are the few ways you can improve your system performance and make it highly scalable.

For more such articles kindly follow and leave your comments on your views on System Scaling.

Thanks for Reading!

Reference:

System Design — Alex Xu

Find me here:

https://www.linkedin.com/in/p-divya/

--

--

No responses yet