Day1-100 series - Learning System Design for Interviews.
Tags: systemdesign, systems
Published: 2024-06-20 06:12:25

Hello everyone, I am starting Day1-100 series on Learning System Design for Interviews.

We will go from 0-100 in system design. If you want to learn system design follow and share, I will be posting everyday about system designs.

#Day1 -> 💜 **<u>LATENCY and THROUGHPUT</u>** 💜 
Let's start,
In today's date, every system is online and is accessible to everyone across the globe. So Latency and Throughput becomes one of the most important factors to measure performance of any system.

💁‍♂️ **What is Latency ?** 
👉 Latency is the measurement of time between request sent and response received by the system. In simple terms, when you open a website i.e. you send a request and then the delay taken for the response to arrive. 
👉 Latency measured in ms(milliseconds).
👉 Low latency is always preferred over high latency. There are systems where low latency is compulsory like Online Video games and high latency always gives bad user experience.
👉 Latency can be measured using ping test or there are many tools which can measure and record latency over a period of time.

💁‍♂️ **What is throughput ? **
👉 Over the networks, we send data using data packets. Now these data packets are like small chunks of bigger data. System takes those data packets and combine them back to create the bigger data. Hence that's why we see images on websites taking much more time to load instead of text because text data is smaller in size and image data.
👉 Now, Throughput refers to the amount of data that can be transferred over a network in a period of time. 
👉 So, When data is transferred through networks, due to multiple factors, data packets are lost and system will request for them again and again till it gets complete data or it hits connection timeout.(Connection is broken when it hits timeout).
👉 Throughput is measured in Mbps(megabit per second) or bps(bit per second).
👉 There are lots of tools to measure throughput of a system like when you do speedtest on your browser that also simulates network traffic generators.

🔺 Remember throughput is affected by latency and bandwidth(the internet speed that you buy from your ISP). So we use tools as it gives throughput and latency separately.

💁‍♀️ **Impacting factors for latency**
👉 Location : if your data has to travel long distance, latency will always be high.
👉 Protocol efficiency : Depending on the network protocol, latency may differs such as TCP does 3 handshakes for making and breaking connections. So it creates a delay.
👉 Infrastructure : if network infrastructures are overloaded, then data packets will be dropped, delayed adding it to latency.
👉 Congestion : Network data packets is bound to take longer distance routes, when there is high volume of data transferred.

💁‍♀️ **Impacting factors for Throughput**
👉 Bandwidth : If your network bandwidth is 1Gbps, you can send much more data packets in short amount of time resulting in less loss of data packets.
👉 Network topology : Depending on number of devices connected, distance between devices plays a major role in throughput.
👉 Packet loss : Misconfiguration, network overloaded and many more affects through put.
👉 Processing Power : Certain network devices are specialized in handling complex data packets, or more optimized interms of data packets lost.

These are few factors that affect latency and throughput of system.

Hopefully, you may have enjoyed these. Do Follow and show some love.