SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
  • Scalability
  • Availability
  • Reliability
  • Single Point of Failure (SPOF)
  • Latency vs Throughput vs Bandwidth
  • Consistent Hashing
  • CAP Theorem
  • Fault Tolerance and Redundancy
  • Failover
  • Stateless vs Stateful
  • Concurrency vs Parallelism
  • Capacity Planning
  • Back Pressure
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Foundations/Core Concepts

Latency vs Throughput vs Bandwidth

Three different ways to talk about 'fast'. Do not mix them up.

โฑ 12 min readBeginnerMust KnowInterview FavouriteHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

These three words all talk about "fast", but each one means something different.

  • Latency: how long one request takes. (Time)
  • Bandwidth: the maximum data the pipe can carry per second. (Capacity)
  • Throughput: how much work is really done per second. (Actual speed)

Remember: a wide pipe (high bandwidth) does not make a single request faster. Latency and bandwidth are different problems.

02Concept: What is it?

โฑ๏ธLatency
The time one request takes from start to finish. Measured in milliseconds (ms). Lower is better.
๐Ÿ›ฃ๏ธBandwidth
The most data a connection can carry each second. Measured in Mbps or Gbps. Higher is better.
๐ŸššThroughput
The amount of work actually done each second: requests per second, or MB per second. Higher is better.
๐Ÿง One line each
Latency = how long. Bandwidth = how much could fit. Throughput = how much really went through.
โš ๏ธBits and bytes
Network speed is usually in bits per second (Mbps). File size is in bytes (MB). 1 byte = 8 bits. So a 100 Mbps line moves at most about 12.5 MB per second.

Percentiles: do not trust the average

Latency is not one number. Some requests are fast and some are slow. So we look at percentiles: p50 (the middle request), p95 and p99 (the slow ones). If p99 is 2 seconds, then 1 in 100 users waits 2 seconds or more.

03Real-Life Example

๐ŸตWater pipe and highway
Think of a water pipe. Latency is how long one drop takes to travel from the tank to your tap (this depends on the pipe length). Bandwidth is how wide the pipe is. Throughput is how many litres really come out each second.
The pipe
๐ŸญTank
โ†’โ†“long = high latency
๐ŸšฐTap
Wide pipe (bandwidth)big
Water really flowing (throughput)less than the max
A long pipe has high latency. A wide pipe has high bandwidth. Both can be true at once.
Highway
Network
Time for one car to drive from A to B
Latency
Number of lanes
Bandwidth
Cars that really reach B each minute
Throughput
A traffic jam or a broken lane
Packet loss, congestion
A longer road (A to far-away B)
Server is far away
๐Ÿ’กA great trick question
A 10-lane highway (big bandwidth) to a city 1,000 km away still takes hours for one car (high latency). Adding lanes does not make one car arrive sooner.

04Why Do We Need It?

When someone says "the system is slow", we must know which kind of slow. The fix is different for each.

๐Ÿ˜€User experience
Users feel latency. Even a small delay makes a page feel slow.
๐Ÿ“ˆHandling growth
Throughput tells us how many users the system can serve at once.
๐Ÿ”งFix the right thing
Buying more bandwidth will not fix a far-away server.
๐ŸŽฏSet goals
Teams write goals like p99 under 200 ms and 5,000 requests per second.
๐Ÿ’ฐPlan cost
Know what you need before paying for it.
๐ŸงชFind bottlenecks
Measuring each one shows which part is the slow one.
Measure first. Then decide if you need lower latency, more bandwidth, or more throughput.

05Where Do We Use It?

๐ŸŽฎOnline games
Need very low latency. A 200 ms delay makes you lose.
๐Ÿ“žVideo calls
Need low latency (to talk naturally) and enough bandwidth (for video).
๐ŸŽฌVideo streaming
Needs high bandwidth. A small start delay is fine.
๐Ÿ“ˆStock trading
Every millisecond of latency can cost money.
๐Ÿ’ณPayment systems
Need high throughput at peak time, and low latency per payment.
๐Ÿ—„๏ธDatabases
Queries per second (throughput) and time per query (latency).

Where do we measure them?

๐Ÿ“ฑClientpage load time
๐ŸŒNetworkround trip time
๐Ÿ–ฅ๏ธServerrequest time
๐Ÿ—„๏ธDatabasequery time

06Types / Parts / How It Works

Where does latency come from?

One request, many small delays
๐Ÿ“ฑClient
โ†’โ†“network
๐Ÿ–ฅ๏ธServerprocessing
โ†’โ†“query
๐Ÿ—„๏ธDatabasedisk read
Network traveldistance, hops
Server processingcode, CPU
Database / diskqueries
Waiting in a queuebusy server
Total latency is the sum of every step. Reduce the biggest step first.
  • Propagation delay: time for the signal to travel. Limited by the speed of light. Far servers are slower.
  • Transmission delay: time to push the bits onto the wire. This is where bandwidth matters.
  • Processing delay: time the server and database spend working.
  • Queueing delay: time spent waiting because everything is busy.

Rough numbers every engineer should know

ActionAbout how longFeels like
Read from CPU cache1 nanosecondInstant
Read from RAM100 nanosecondsVery fast
Read from SSD0.1 ms (100 microseconds)Fast
Round trip inside one data centre0.5 msFast
Read from a spinning disk10 msSlow
Round trip across a continent50 to 150 msNoticeable
๐Ÿ“Note
These are rough, common textbook values. Real hardware differs. Use them to compare, not to promise.
VisualizerPipe and highwayChange the file size, latency and bandwidth. Then switch to many requests.
What do you want to explore?
What are we downloading?
๐Ÿ’ปYou
longer pipe = more latencythicker pipe = more bandwidth
โ†’โ†“100 ms
๐Ÿ–ฅ๏ธServer
Waiting (latency)100 ms
Moving the data (size รท bandwidth)1.6 ms
Total time
102 ms
You paid for
100 Mbps
You really got
1.6 Mbps
throughput
The file is small, so most of the time is waiting (98%). A thicker pipe will not help. Only lower latency helps (a closer server or a CDN).

07How to Use It / Steps / Implementation

Lower latency

  1. 1
    Move data closer to users
    Use a CDN and servers in more regions.
  2. 2
    Cache hot data
    Answer from fast memory instead of the database.
  3. 3
    Do less work per request
    Add database indexes. Avoid extra calls.
  4. 4
    Reduce round trips
    Reuse connections. Send many small requests as one.
  5. 5
    Do slow work in the background
    Use queues so the user does not wait.

Raise throughput

  1. 1
    Add more servers
    Use a load balancer. This is horizontal scaling.
  2. 2
    Do work in parallel
    Use many threads or workers.
  3. 3
    Send data in batches
    One big request is often cheaper than 100 tiny ones.
  4. 4
    Remove the bottleneck
    Measure to find the slowest part first.

Raise bandwidth

  • Buy a faster network link.
  • Compress data (smaller files, such as gzip or WebP images).
  • Send only what is needed.
๐Ÿ’กThe simple formula
Throughput = requests in flight รท latency. With 10 requests at once and 100 ms each, you get 10 รท 0.1 = 100 requests per second. You can raise it by running more at once or making each one faster.

08Key Terms to Know

TermMeaning in easy words
LatencyTime for one request to finish. Measured in ms.
Round trip time (RTT)Time for a message to go to the server and come back.
BandwidthThe maximum data per second a connection can carry.
ThroughputThe data or requests per second that really get through.
GoodputThroughput of useful data only, without resent or extra header bytes.
RPS / QPSRequests (or queries) per second.
p50, p95, p99The time within which 50%, 95% or 99% of requests finish.
JitterHow much the latency changes from one request to the next.
Packet lossData pieces that never arrive and must be sent again.
CongestionToo much traffic on a link, so things slow down.
Time to first byte (TTFB)Time until the first part of the answer arrives.

09Pros, Cons and Trade-offs

โœ… Pros
  • Clear words help the whole team agree on the problem
  • Numbers let us set goals and check them
  • We spend money on the right fix
โš ๏ธ Cons
  • Hard to measure well (averages hide slow requests)
  • Improving one can hurt another
  • Real networks change all the time

Trade-offs

ChoiceWe gainWe lose
Batching requestsHigher throughputHigher latency for each item (it waits for the batch)
CachingLower latencyData may be old
CompressionLess bandwidth usedA little CPU time and latency
More serversHigher throughputMore cost and complexity
QueuesSmooth throughput at spikesLonger wait for the result

10Common Problems and Mistakes

Common mistakes

  1. Mixing up the words. Saying "bandwidth" when the problem is a far-away server.
  2. Looking only at the average. The average can look fine while p99 is terrible.
  3. Buying more bandwidth for a latency problem. It does not help small requests.
  4. Mixing Mbps and MBps. One is bits, one is bytes. They differ by 8.
  5. Testing on a quiet system. Latency rises sharply when the system is busy.
  6. Too many small calls. Each call pays the round trip again. Batch them.
โš ๏ธLatency grows when busy
When a server is nearly full, requests wait in a queue and latency jumps. Aim to run at a safe level (for example, below 70% capacity), not at 100%.

11Real-World Examples

๐ŸŽฌVideo streaming
Needs bandwidth. Apps pick a lower video quality when your bandwidth drops.
๐ŸŒCDNs
Copy content near users to cut latency.
๐ŸŽฎOnline gaming
Games show your ping (latency) because it matters more than bandwidth.
๐Ÿ“žVideo calls
Use compression to fit in your bandwidth and keep latency low.
๐Ÿ›’Shopping sites
Teams track p99 page time, because slow pages lose sales.
๐Ÿ’ฌMessaging apps
Handle a huge number of small messages. Throughput matters most.
๐Ÿ“Note
These show the general idea. Real companies use many more techniques.

12Related Topics to Read Next

Scalabilityโ†’

Throughput is how we measure scaling.

Availabilityโ†’

A very slow system can feel down to users.

TCP vs UDPโ†’

Two ways to trade reliability against latency.

DNSโ†’

The lookup adds to your first-request latency.

What are Load Balancers?โ†’

Spread requests to raise throughput.

Anycast Routingโ†’

Routes users to the nearest server to cut latency.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • โœ”Latency: time for one request (ms). Lower is better.
  • โœ”Bandwidth: maximum data per second (Mbps). Higher is better.
  • โœ”Throughput: actual work per second (RPS). Never above the limit.
  • โœ”Analogy: pipe length = latency, pipe width = bandwidth, water flowing = throughput.
  • โœ”Formula: throughput โ‰ˆ requests in flight รท latency.
  • โœ”Measure: p50, p95, p99. Not just the average.
  • โœ”Units: 8 bits = 1 byte. Mbps is not MBps.
  • โœ”Fix latency with CDN, cache and fewer round trips. Fix throughput with more servers and parallel work.
โ† Previous
Single Point of Failure (SPOF)
Next โ†’
Consistent Hashing