1. What it is
Latency is how long it takes to get a response after you make a request: the wait between asking for something and getting the answer back.
2. Everyday analogy
Picture ordering a coffee at a busy café. (An imagined café, for illustration.) You say "one latte, please." Then you wait. Your order has to travel to the barista. The barista has to make it. Then someone has to call your name and hand it across the counter. The time from "one latte, please" to the cup in your hand is the latency of your coffee.
Notice that the wait has several parts. There is travel (your order going to the barista), work (making the drink), and travel again (the cup coming back to you). Make any one of those slower and you wait longer.
Here is how that maps to computers. When you tap a link, your phone sends a small message across the internet to a computer somewhere else. That computer does some work and sends an answer back. The whole wait, from the trip there, through the work, to the trip back, is the latency of that request. The café is a helpful picture, but online, two sources of delay can never be removed completely: physical distance, and the equipment the message passes through. The next section explains both.
3. How it actually works
Engineers use the word in two related ways. Google's book on Site Reliability Engineering describes request latency as "how long it takes to return a response to a request." That is the whole wait from the café story. Cloudflare's guide uses a narrower, network-only meaning: the time it takes for data to pass from one point on a network to another, in one direction. This lesson uses both, and says which one it means.
Anything sent over the internet is split into small pieces called packets. Each packet carries one piece of the message, and the receiving device puts the pieces back together. When you load a web page, your device (the client) sends packets to a server, a computer that responds to requests. Cloudflare's guide gives an imagined example of the network meaning: if a server in New York sends a packet that arrives at a server in London 0.145 seconds later, the latency on that path is 145 milliseconds (thousandths of a second).
One of the main causes of latency is distance. Data moves extremely fast, but not instantly. Cloudflare's guide gives rough figures: for a website hosted in Columbus, Ohio, requests from users in nearby Cincinnati (about 100 miles away) would likely arrive within 5 to 10 milliseconds, while requests from users in Los Angeles (about 2,200 miles away) would take closer to 40 to 50 milliseconds.
Distance is not the only cause. A packet usually crosses several networks on its way. Where networks meet, equipment called a router has to process the packet and send it on toward its destination, and each step adds a little delay. Because of distance and this equipment, Cloudflare notes, latency can be reduced but never removed completely. The server also needs time to process the request before it can send results. Finally, the answer has to make the return trip. Cloudflare calls the journey there and back the round trip time, or RTT, and describes it as double the one-way latency.
One more idea is worth holding onto. Loading a page involves back-and-forth messages, not just a single trip, partly because your device and the server first have to set up a connection. So a delay that looks tiny on its own adds up. That is one reason a content delivery network, or CDN, helps. A CDN is a set of servers in many locations that keep copies of content closer to the people using it. Cloudflare, which runs a CDN of its own, calls using one "a major step towards reducing latency." Shorter trips mean less waiting.
4. Real-world example
In 2009, Google published the results of experiments on its own search results page. Engineers deliberately slowed down how fast search results were delivered for some users, then measured how those users behaved.
According to Google's write-up, slowing the page by 100 to 400 milliseconds reduced the number of searches per user by 0.2% to 0.6%. The effect also grew over time. Users who saw a 400 millisecond delay did 0.44% fewer searches in the first three weeks, and 0.76% fewer in the following three weeks. Even after the delay was removed, those users took time to return to their old habits.
Those percentages sound small. But Google's point was that at the scale of a large website, a small daily drop matters, and less than half a second of extra waiting was enough to change behavior.
Source: Google Research blog, "Speed Matters" (June 23, 2009): https://research.google/blog/speed-matters/
5. Diagram
You (client) Server
| |
|--- request travels (one-way latency) ------>|
| | server does work
|<-- answer travels back (one-way latency) ---|
| |
|<-------- request latency: the whole wait --------->|
Closer server = shorter trips = less waiting6. When you'd care
Latency matters any time a person is waiting for a page or app to respond. It matters especially when one action needs many back-and-forth trips, because the small delays add up.
If you work with a technical team, latency is one likely suspect behind "why does it feel slow for our users in another country?" Moving content closer to people with a CDN is one fix Cloudflare's guide recommends. The same guide notes that pages can also be slow for reasons other than latency, such as large images and files, which teams can shrink.
A common mistake: assuming a faster internet plan fixes all slowness. A bigger plan mostly lets you move more data at once. It does not shorten the distance to a server on the other side of the world. Cloudflare's guide makes the same point: buying more bandwidth is not a guarantee of better website performance. Latency is about time. Capacity is a separate idea, covered in the throughput lesson.
7. Check yourself
Q1. Which of these best describes latency?
- A) How much data can move at once
- B) How long you wait for a response to arrive
- C) How many servers a company owns
- D) How large a web page is
Show answer to question 1
Answer: B. Latency measures time spent waiting, not amount of data.
Q2. Which of these is one of the main causes of latency online?
- A) The color scheme of the website
- B) The physical distance between you and the server
- C) The number of tabs you have open
- D) The price of the website's domain name
Show answer to question 2
Answer: B. Data travels fast but not instantly, so longer distances mean longer waits.
Q3. In Google's 2009 experiment, what happened when search results were slowed by 100 to 400 milliseconds?
- A) Nothing measurable changed
- B) People searched more to make up for it
- C) People did measurably fewer searches
- D) The site crashed
Show answer to question 3
Answer: C. Google measured 0.2% to 0.6% fewer searches per user, and the effect grew over time.
8. Sources
- Google Research blog, "Speed Matters" (2009): https://research.google/blog/speed-matters/
- Google, Site Reliability Engineering, chapter "Service Level Objectives": https://sre.google/sre-book/service-level-objectives/
- Cloudflare Learning Center, "What is latency?": https://www.cloudflare.com/learning/performance/glossary/what-is-latency/
- Cloudflare Learning Center, "What is a packet?": https://www.cloudflare.com/learning/network-layer/what-is-a-packet/