Basis Lab

Answers · The network and the web

Why does a download start slow and then speed up?

In shortThe sender starts with about fourteen kilobytes in flight and doubles that each round trip until something is lost, so the opening round trips measure the path rather than move data.

Nothing is warming up, and nobody is throttling you. A sender has no measurement of the path in front of it, so it begins with a deliberately small amount of data outstanding, about fourteen kilobytes, and doubles that amount at the end of every round trip in which nothing was lost. What you are watching is a measurement being taken.

b=i⋅2kb = i \cdot 2^{k}

Here bb is how many bytes the sender will allow to be unacknowledged at once, ii is the starting allowance of roughly fourteen kilobytes, and kk is the number of round trips completed without loss. The sender cannot look at its own link and learn anything useful, because the path to you passes through whichever link is narrowest and that link tells it nothing. So fourteen kilobytes go out, they are acknowledged a round trip later, and only then does the allowance become twenty eight.

FIG 1
round trip completedallowed in flight, kilobytesdelivered so far, kilobytes
11414
22842
35698
4112210
5224434

The second column doubles and the third accumulates: 1414, then 14+28=4214+28=42, then 42+56=9842+56=98, then 98+112=21098+112=210, then 210+224=434210+224=434. Growth looks dramatic in percentages and is painful in absolute terms. Five round trips, and the sender still has less than half a megabyte to show for them.

Take a 200 kilobyte response over a path with an 80 millisecond round trip. After three round trips 98 kilobytes have arrived, so 102 remain, and the fourth round trip's allowance of 112 kilobytes covers it: the download ends inside the fourth round trip, 320 milliseconds after it started. That is 1,600,000 bits in 0.320 seconds, about 5 megabits per second. A hundred megabit link carries 12.5 megabytes a second, so 200 kilobytes at full rate would take 200/12,500=0.016200/12{,}500 = 0.016 seconds, or 16 milliseconds. The ramp cost twenty times the transfer. Shrink the file to 100 kilobytes and it still needs four round trips, since three round trips yield only 98, so 320 milliseconds for 800,000 bits: 2.5 megabits per second, against the 8 milliseconds the link alone would have taken. Below a few hundred kilobytes the file size barely enters the arithmetic. The round trip count does.

What it is not

The tempting picture is of a fixed start-up cost, a second of nothing while something negotiates, or a server being stingy with a connection it could easily fill. Neither survives two tests. A fixed delay would not end where this ends, at the first lost packet, and it would not be remembered: the next response on a connection that has already carried traffic starts at the rate the previous one finished at, because the sender already holds its estimate. A throttle would be a rate the sender held itself to, whereas what is observable is a rate that climbs and stops climbing exactly when loss appears, doubling while nothing is dropped and cut sharply the moment something is. That is a probe, not a tariff. It also explains the shape of a slow start in the literal sense: it is not slow because the sender is being careful in a vague way, it is slow because each increase costs a full round trip to discover.

Why a faster line barely shortens it

Because the doubling happens once per round trip, its cost is counted in round trips rather than bytes, and widening the pipe does not shorten it. On a hundred megabit link with an 80 millisecond round trip the sender needs 1,000,000 bytes outstanding to fill it: 12,500,000 bytes a second times 0.08 seconds. Running the doublings out from 14: 28, 56, 112, 224, 448, 896, 1792. The allowance passes a megabyte only at the seventh doubling, so the path is filled after seven round trips, which is 560 milliseconds, and across those the sender delivered at most 14(27−1)=177814(2^{7}-1) = 1778 kilobytes. That is 14,565,376 bits over 0.56 seconds, an average of about 26 megabits per second on a link that calls itself a hundred. Give the same path a gigabit and the crossing point moves from the seventh doubling to the tenth: three round trips bought by ten times the bandwidth.

bytes in flight to fill the path=link rate×round trip time\text{bytes in flight to fill the path} = \text{link rate} \times \text{round trip time}

Where the doubling stops

Two limits end the picture, and they are easy to confuse. The doubling lasts only until the first loss; after that the allowance is halved and growth becomes far slower, which is what lets many senders share one path roughly fairly. Separately, the receiver advertises its own buffer limit in every acknowledgement, and the smaller of the two numbers governs. If the receiver's buffer is 64 kilobytes while the path could carry 512, the transfer sits flat at 64 and nothing done at the sending end moves it. That flatness is the diagnostic: a rate that climbs and collapses and climbs again is the network estimate doing its job, while a rate that is identical on a fast path and a slow one is a receiver cap. Once neither limit binds, the ramp is finished and the link rate governs for the remainder, which on anything past a few hundred kilobytes is most of the transfer.

Worth keeping

  • A sender's only way to learn what a path can carry is to increase the amount in flight until a packet is lost, so the first round trips of any transfer measure rather than transfer.
  • The ramp is counted in round trips, not bits, so a faster link barely shortens it; a shorter distance or a connection that already knows the answer does.
  • For responses under about a hundred kilobytes the sender never finishes the ramp, and the duration is set by round trips rather than by bandwidth.

Where this goes next

This question is one step of From an Address to a Page, a course that works through its subject from the beginning. The page that teaches this part of it is Deciding How Fast to Send, and it reads the whole way through whether or not you have an account.

What an account changes is the practice: problems standing under every idea, marked with a reason rather than a tick, in a copy of the course that is yours.

Read that pageThe whole course

Other questions people ask about this

  1. Why does a DNS lookup sometimes have to ask several servers before it gets an answer?Because when no cache already holds the address, the resolver has to ask one server at a time down the hierarchy, and each reply only tells it who to ask next.
  2. Why does opening a connection take three messages instead of two?Three messages are needed because the server must also learn that its own reply arrived; the third message is that proof, not a formality.
  3. What does a CDN actually change about my request?A CDN puts a machine near the reader that answers the request itself, so your origin often never sees it and the address it logs is not the reader's.
  4. Where should a session ID be stored so JavaScript can't read it?Store it in an HttpOnly cookie set by the server; that is the only browser storage JavaScript running on the page cannot read.
  5. What does it mean for an API method to be safe?A safe method is one that changes nothing on the server when it is called, so a caller may repeat it freely and a cache or a crawler may use it without anything being altered.
  6. Does signing out actually invalidate my token on the server?No. Signing out clears your browser's copy of the token, but the server keeps accepting that token until it expires.

Read alongside