Basis Lab

Answers · The systems around the model

How can I tell if my traffic is bursty or just high volume?

In shortCompare the variance of the gaps between arrivals with the square of their average gap: high volume alone does not make traffic bursty.

High volume is an average; burstiness is a variance. The test is to take the gaps between successive arrivals and compare their variance with the square of their mean: a high average with steady gaps is high volume, a lower average with wildly uneven gaps is bursty.

c=Var⁡(G)(E[G])2c = \frac{\operatorname{Var}(G)}{(\mathbb{E}[G])^2}

Write GG for the gap between one arrival and the next, in seconds. Regular arrivals, one every second, have G=1G=1 every time: the mean is 11 and the variance is 00, so c=0/12=0c=0/1^2=0. Independent random arrivals with the same mean gap have exponential gaps, whose variance equals the square of their mean: with mean 11 the variance is 11, so c=1/12=1c=1/1^2=1. That is the standard random case, not an especially bursty one. The number to compare against is 11, not 00.

Now keep the same mean gap of one second and make the arrivals clump. Suppose nine gaps in ten are zero and one gap in ten is ten seconds. The mean is 0.9×0+0.1×10=10.9\times0+0.1\times10=1 second. The second moment is 0.9×02+0.1×102=100.9\times0^2+0.1\times10^2=10, so the variance is 10−12=910-1^2=9. The clumping measure is 9/12=99/1^2=9. The average rate is unchanged at sixty a minute, but the spacing is nine times as variable as independent random arrivals. A zero gap is an idealisation of arrivals that are very close together, and the arithmetic is what matters: the same mean can carry a very different variance.

FIG 1
patternmean gap (s)variance (s)
Regular, one every second1000.5
Independent random1111
Nine zero gaps in ten, one ten-second gap1995

Checking the wait

If the raw gaps are not available, the same quantity can be recovered from waiting times. Let kk be the wait the standard random-arrival formula predicts at the observed utilisation and service time, and let WW be the wait actually observed. The relation W=k(1+c)/2W=k(1+c)/2 rearranges to the diagnostic form. The two routes measure the same gap variance. Use the first when you have timestamps of individual arrivals; use the second when you have only latency and load. If both are available they check each other: a gap-based cc of nine should appear as a wait about five times the random-arrival prediction, and a wait five times the prediction should not be explained by a gap-based cc near one.

c=2Wk−1c = \frac{2W}{k} - 1

At eighty per cent utilisation with a two hundred millisecond service time, the standard formula gives k=0.8/(1−0.8)×0.2=0.8k=0.8/(1-0.8)\times0.2=0.8 seconds. If the measured wait is two seconds, then c=2×2/0.8−1=4c=2\times2/0.8-1=4. Check: 0.8×(1+4)/2=20.8\times(1+4)/2=2 seconds. A service whose wait is three times the prediction has c=2×3−1=5c=2\times3-1=5. That is a statement about the spacing of arrivals, not about the servers being slow.

Volume and clumping compound

High volume raises the utilisation and therefore raises both kk and the wait produced by any fixed cc. Burstiness raises cc and multiplies whatever wait the utilisation already produces. The two are not alternatives. At sixty per cent load a clumping measure of nine gives a multiplier of five; at ninety per cent the same multiplier applies to a much larger kk, so the absolute wait is far larger. This is why a dashboard showing requests per second can make two systems look identical: the average rate is the same and the clumping is invisible.

The natural guess is to compare peak rate with average rate and call the difference burstiness. That can be misleading, because a single peak over a long window is diluted by the window, and a stream of small clumps can leave the peak low while making every clump wait. The variance of gaps catches the clumping at the scale that matters to the queue. A high average with cc near one is high volume, not bursty. A modest average with cc of nine is bursty, not high volume.

Where it stops being true

The measure assumes a stationary window. If the morning is smooth and noon is clumped, one cc averages two regimes; compute it over a window in which the mean gap is roughly stable, and preferably over several windows to see the spread. It also assumes the service time is known. A cc far above ten is possible for synchronised timers and retries, but it is also what a badly measured service time produces, so check that first. With few arrivals the variance estimate is noisy; a dozen gaps cannot distinguish c=1c=1 from c=3c=3 reliably.

Worth keeping

  • High volume is an average arrival rate; burstiness is the variance of the gaps between arrivals relative to the square of their mean.
  • The clumping measure is zero for regular arrivals, about one for independent random arrivals, and above one for bursty traffic.
  • If the measured wait is W and the standard formula predicts k, the clumping measure is 2W/k minus 1.

Where this goes next

This question is one step of Work That Waits in a Queue, a course that works through its subject from the beginning. The page that teaches this part of it is Arrivals Come in Clumps, 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 average latency hide the slow requests users actually feel?Waiting times are lopsided, so the average sits between the common case and the bad case and describes neither, and it is the bad case that users keep meeting.
  2. How can I estimate wait time from the number of requests in the system?Divide the average number of requests inside the system by the rate at which they arrive, and you get the average time each request spends there.
  3. What's the difference between a CDN cache and caching inside my own app?A CDN cache sits near the user and can only hold answers that are identical for everyone, while a cache inside your app can be personal but exists once per process.
  4. What's the difference between LRU and LFU, and which one should I use?LRU drops the item unused for longest; LFU drops the item requested least often. Both guess at future use, and the cheap win is refusing one-off arrivals rather than counting requests.
  5. Why can't a system just stay consistent and available when the network splits?During a split, a cut-off machine can only answer from the data it already holds, so it must either risk being wrong or refuse to answer.
  6. Should the gradients be summed or averaged across GPUs?Sum the gradients when each device already divides its loss by the global batch size; average them when each device uses its own local mean. Doing both makes the gradient too small by the number of devices.

Read alongside