Exponential backoff needs jitter or everything retries together

Backing off exponentially stops a failing dependency being hammered. What it does not stop is synchronisation: every client that failed at the same moment retries at the same moment, so the recovering service is hit by the whole fleet at once and fails again.

// synchronised: 1s, 2s, 4s, 8s — for everyone at once
$delay = pow(2, $attempt);

// jittered: the same envelope, spread out
$delay = mt_rand(0, (int) pow(2, $attempt) * 1000) / 1000;

Full jitter — a random value anywhere between zero and the computed delay — spreads the retries across the whole window and is what actually lets the dependency recover. It looks wasteful because some retries happen sooner than the backoff suggests, and it converges faster in practice than the tidy doubling. Cap the exponent as well, or the twentieth attempt is scheduled for next week.