Stackbook Logo
resilienceestablished · low operational burden

Jitter

Also known as: randomized-delay, backoff-jitter

Intent

Add randomness to delays and schedules so many clients do not act at the same instant.

Problem

Clients that retry, refresh, or poll on identical schedules synchronize with each other, creating periodic spikes. After an outage ends, thousands of clients retrying in lockstep can knock the recovering service down again.

Forces

  • •Deterministic schedules cause synchronization
  • •Randomness makes behavior harder to predict and test
  • •Delay bounds must remain acceptable
  • •Many clients share a common trigger

Solution

Overview

Jitter breaks synchronization. Exponential backoff alone spaces retries out for one client, but a thousand clients that failed together still retry together at each step. Randomness spreads them across the interval.

How it works

The AWS Architecture Blog compared several variants. Full jitter performs well for most retry cases.

cap   = min(maxDelay, base * 2^attempt)
sleep = random(0, cap)            # full jitter

# decorrelated jitter
sleep = min(maxDelay, random(base, prev * 3))

The same idea applies outside retries. Add plus or minus ten percent to cache TTLs so entries do not expire together, offset cron jobs by a random number of seconds, and stagger client reconnects after a server restart.

Pitfalls

  • A fixed seed, or seeding from the second, makes instances pick identical delays. Use a proper per-process source of randomness.
  • Small jitter, such as plus or minus one percent, does not break up large synchronized groups.
  • Jitter can push a call beyond its timeout budget, so cap total delay.
  • Tests become flaky unless the random source is injectable.
  • Jitter does not limit total retry volume. Combine it with a retry budget.

Key takeaways

  • Randomize retries, TTLs, and periodic jobs.
  • Prefer full or decorrelated jitter over fixed backoff.
  • Use independent randomness per instance.
  • Keep the total delay inside the request budget.
  • Verify the effect in load tests by plotting request arrivals after a simulated outage, where jittered clients should form a smooth ramp rather than spikes.

✓ When to Use

  • •Retry and reconnect logic
  • •Cache TTLs and scheduled jobs shared by many clients
  • •Periodic polling from large fleets

✗ When Not to Use

  • •Operations that need exact timing such as financial cutoffs
  • •Single clients with no contention
  • •Tests that require deterministic ordering, without a seeded random source

Pros

  • +Spreads load and removes spikes
  • +Trivial to implement
  • +Greatly improves recovery from outages

Cons

  • −Less predictable latency for individual requests
  • −Harder to reproduce in tests
  • −Adds some average delay

Cost Profile

Infrastructure

None, one line of code

Operational

Low, occasional tuning

Cognitive

Low, simple idea

Failure Modes

  • Same random seed across instances recreates synchronization

  • Jitter range too narrow still leaves spikes

  • Added delay exceeds a timeout budget

Real-World Examples

Alternatives

    Related Patterns

    • retry-with-backoff
    • retry-budget

    Competency Domains

    reliability opsdistribution communication