Definition · The two transfer timesFor a payload of size bytes, a link of bw bytes a second, a compressor running at rate bytes of input a second and a compression ratio k (so the output is size/k):
raw takes size/bw;
compressed takes size/rate + size/(k·bw).
Decompression at the far end is counted only when it is on the critical path; here the receiver stores the compressed form, so it is not.
size = 10 GB = 10 000 MB bw = 1 000 Mbit/s = 125 MB/s
k = 4 rate = 250 MB/s
raw 10 000 ÷ 125 = 80 s
compressed squeeze 10 000 ÷ 250 = 40 s 66.7%
send 2 500 ÷ 125 = 20 s 33.3%
------
60 s
verdict compress, by 80/60 = 1.33×
on the wire 2.5 GB instead of 10 GB
The 66.7% is worth noticing: two thirds of the compressed plan’s time is the compressor, not the network. That is the usual shape once links are fast, and it is why the break-even is about the compressor’s throughput rather than about the ratio alone.
Setting them equal
The break-even is one equation. Write the two times, set them equal, and divide both sides by size — which is legitimate because size appears exactly once in every term.
size/bw = size/rate + size/(k·bw)
divide by size:
1/bw = 1/rate + 1/(k·bw)
1/bw − 1/(k·bw) = 1/rate
(1/bw)(1 − 1/k) = 1/rate
bw* = rate·(k − 1)/k = 250 × 3/4 = 187.5 MB/s
rate* = bw·k/(k − 1) = 125 × 4/3 = 166.67 MB/s
Two readings of one equality. Fix the compressor and you get a bandwidth: above 187.5 MB/s — 1 500 Mbit/s — raw is faster, so a datacentre link defeats this compressor and a wide-area link does not. Fix the link and you get a throughput: on 125 MB/s the compressor must beat 166.67 MB/s, and many do not.
Example · Why the same file gets a different answer on two linksSend the same 10 GB over a 10 Gbit/s link, which is 1 250 MB/s. Raw: 8 s. Compressed: 40 s to squeeze plus 2 s to send, which is 42 s. Compression is now more than five times slower, and nothing about the file changed. The file never mattered: 1 250 MB/s is above bw* = 187.5, and 125 MB/s is below it.
Where the ratio helps, and where it does not
(k − 1)/k is 1/2 at k = 2, 3/4 at k = 4 and 9/10 at k = 10, so it saturates fast. Doubling the ratio from four to eight moves the break-even bandwidth from 187.5 to 218.75 MB/s, a gain of 17%; doubling the compressor’s throughput moves it from 187.5 to 375 MB/s. When both are on offer, the faster compressor is nearly always the better trade.
That is the arithmetic behind a decade of compression libraries choosing speed over ratio. Past k = 4 or so, extra ratio buys very little on the wire and is usually paid for with a great deal of processor time, which enters the plan at full weight.
When decompression counts
If the receiver has to expand the payload before doing anything with it, the far end’s time is on the critical path and the compressed plan gains a third term, size/(k·drate) in the compressed domain. The equality is the same shape with that term added to the per-byte cost, and it moves the break-even against compression. Whether it applies is a question about what the receiver does, and it should be answered before the arithmetic rather than after.
One units caution, because it causes more wrong answers here than the algebra does. Links are quoted in bits a second and payloads in bytes, so a 1 000 Mbit/s link is 125 MB/s and a factor of eight separates them. On this course MB/s is 10⁶ bytes a second and Mbit/s is 10⁶ bits a second, and the lab divides by eight rather than leaving it to be remembered.