Command Palette

Search for a command to run...

Hectal
PHASE 0Beginner ~7 min· topic 4 of 4

Topic 0.4

Latency, Bandwidth, Throughput & Jitter

In one line

Latency is how long one packet takes, bandwidth is how much the pipe can carry, throughput is how much you actually get; confusing them leads to buying the wrong fix.

0/4 · 0%

Think of it like this

A motorway. BANDWIDTH is the number of lanes. LATENCY is how long one car takes to drive from A to B. THROUGHPUT is how many cars actually arrive per hour, limited by lanes, traffic jams, and toll booths. Adding lanes doesn't make any single car faster.

Key ideas

  1. 01

    LATENCY is often measured as RTT (round-trip time): request out and response back. It's bounded by physics. Light in fibre travels ~200,000 km/s, so Mumbai to Virginia (~13,000 km) is at least ~130 ms round trip before any processing.

  2. 02

    BANDWIDTH is capacity in bits per second (Mbps, Gbps; note bits, not bytes: 100 Mbps ≈ 12.5 MB/s). THROUGHPUT is what a connection actually achieves, often limited by latency (TCP's window, Phase 2), packet loss, or the slowest link on the path.

  3. 03

    JITTER is variation in latency; it matters for voice, video, and games. PACKET LOSS forces retransmissions, and even 1% loss can dramatically cut TCP throughput.

  4. 04

    Why this matters to backend engineers: a page making 20 SEQUENTIAL API calls across regions pays 20 × RTT, whatever the bandwidth. The fixes are about latency: fewer round trips (batching, HTTP/2 multiplexing), shorter distance (CDNs, regions near users), and caching.

  5. 05

    Latency numbers every engineer should know (orders of magnitude): same-datacentre round trip ~0.5 ms, same-region different AZ ~1–2 ms, cross-continent ~100–250 ms, disk seek ~5–10 ms, SSD read ~0.1 ms.

Code & diagrams

measure.shbash
ping -c 10 example.com                   # RTT min/avg/max/mdev (mdev ≈ jitter)
mtr -rwc 50 example.com                  # per-hop latency and loss over 50 probes
curl -o /dev/null -s -w 'dns=%{time_namelookup} connect=%{time_connect} tls=%{time_appconnect} ttfb=%{time_starttransfer} total=%{time_total}\n' https://example.com
iperf3 -c iperf.example.net              # raw throughput test against an iperf3 server

Explain it without notes

01

Your API is slow for users in Europe but fast in India, where the servers are. Upgrading the servers' bandwidth from 1 Gbps to 10 Gbps — will it help? Why?

Practice

01

Use the curl -w command above on a site you use. Which phase takes the most time: DNS, connect, TLS, or waiting for the first byte? What would you optimise?

Trade-offs

  • ↔

    Throughput and latency often trade against each other: batching increases throughput but adds delay; aggressive parallelism can hide latency but increases load. Decide which one your use case is actually sensitive to.

Done when you can

  • I can explain latency, bandwidth, throughput, jitter, and packet loss with an analogy.

  • I know the approximate RTT for same-AZ, cross-region, and cross-continent traffic.

  • I can break down a request's time with curl -w.