skip to content

Why do configuration agents on a 4,000-host fleet pulling from one configuration server every 20 minutes need random splay, and what does it cost?

level: middleimportance: should knowfreq 36%

answer

  1. average rate versus peak rate
  2. what lines the agents up
  3. hosts divided by the window
  4. time until every host agrees

basics

~20 s

Agents sharing a schedule hit the configuration server together, so requests queue and time out. A random delay spreads them across a window, which lowers the peak. The cost is a longer worst-case wait before every host has a new revision.

solid answer

~40 s

In this scenario, 4,000 hosts on a 20-minute interval average only about 3.3 requests per second, but only if they are spread out. When schedules line up, such as cron on the same minute or a mass agent restart, the server sees 4,000 requests almost at once. Queues grow, agents time out and retries add more load. **Splay** adds a random delay to each host's start, so the peak is set by the window: 600 seconds gives about 6.7 requests per second. The cost is time to agree: with those numbers, a host can wait up to 30 minutes for a new revision, plus its run time. A run-now trigger for an urgent change skips the schedule, so it needs its own batching or it recreates the stampede.

code

pseudocode · 13 lines
pseudocode
hosts    = 4000   # scenario value
interval = 1200   # seconds, scenario value
splay    = 600    # seconds, scenario value
capacity = 8      # requests per second the server can answer, scenario value

mean_rate  = hosts / interval   # 3.33 per second: the cycle's average
peak_rate  = hosts / splay      # 6.67 per second: all arrive inside the window
utilisation = peak_rate / capacity   # 0.83: below capacity, with little headroom
worst_wait = interval + splay   # 1800 seconds: early fetch, then late next cycle

# on each host, every cycle
at cycle_start + random(0, splay):
    fetch_and_apply()

go deeper

for a junior

Recall that many agents on a shared schedule can hit one server together, and that splay is a random delay added to spread those requests out over a window.

for a middle

Do the arithmetic aloud: hosts divided by interval gives the average, hosts divided by the splay window gives the peak, and interval plus splay gives the worst-case wait for a new revision.

for a senior

Name what re-synchronises a spread fleet, such as mass restarts or power returning, and show the operational fixes: a delayed first run, retries with backoff and jitter, and batched run-now signals.

for a principal

Treat interval and splay as a stated promise about how long the fleet takes to agree. Set it from the urgency of your changes and the server capacity you are willing to fund.

## Average load is not peak load A **configuration agent** is a background service on a host that wakes on an **interval**, asks a **configuration server** what the host should look like and applies the answer. Every number below belongs to one worked scenario, not to any tool's defaults: 4,000 hosts, a 20-minute (1,200-second) interval, and a server that can answer 8 requests per second. The average looks harmless: 4,000 / 1,200 is about 3.3 requests per second, or 42% of capacity. That figure holds only if the hosts are evenly spread across the interval. An interval says how often each host runs. It says nothing about whether hosts run at different moments. ## How agents end up lined up A fleet can start out spread and become synchronised by a single event: - **Cron on fixed minutes.** A schedule such as every 20 minutes from the top of the hour fires on every host at once when clocks agree. - **A mass agent restart.** Upgrading the agent or changing its settings fleet-wide can reset every host's timer at the same moment. - **A power return.** Hosts booting together after a data-centre outage start their agents together. - **Hosts created in a batch.** A group built at once shares a starting moment. If 4,000 hosts arrive within 10 seconds, that is 400 requests per second, 50 times this server's capacity. Clearing the backlog takes 4,000 / 8 = 500 seconds, a little over 8 minutes. Meanwhile, agents whose requests wait too long time out and retry, which adds load at the worst moment. Immediate retries can keep the server overloaded even after the first wave would have drained. ## What splay does **Splay** gives each host a random delay inside a window, so the arrival rate becomes hosts divided by window. The window, not the interval, sets the peak when hosts share a cycle start. Worst-case wait is how long a host can take to pick up a revision published just after its last fetch, ignoring run time and queueing: | Spread | Peak rate | Share of 8 per second | Worst-case wait | |---|---|---|---| | None, all within 10 s | 400/s | 5,000% | 20 min | | 300 s splay | 13.3/s | 167% | 25 min | | 600 s splay | 6.7/s | 83% | 30 min | | 1,200 s splay | 3.3/s | 42% | 40 min | | Fixed per-host offset across 1,200 s | 3.3/s | 42% | 20 min | The smallest window this server survives is 4,000 / 8 = 500 seconds, and at that size it has no headroom. The trace in the code example shows the 600-second row. ## What it costs - **Time until all hosts agree.** A host's run lands anywhere in its window, so a host that ran at the very start of its window just before a revision was published can run at the very end of its window next cycle. The worst case is interval plus splay. - **A less regular gap between runs.** With a new random delay each cycle, one host's runs can be as close as 600 seconds or as far apart as 1,800 seconds at a 600-second splay. - **Harder reasoning during an incident.** It takes longer before you can say every healthy host has seen a change, so the wait belongs in your rollout estimate. A random delay does not reduce the total work. The same 4,000 requests still arrive each cycle, just spread more thinly. ## Other ways to spread the load Implementations differ: some draw a delay each cycle, some delay only at startup, and some derive a fixed offset from the host's name. 1. **Fixed per-host offset.** It gives the same peak as full-interval splay with a regular gap and no added wait, as the table shows. It needs the offsets to spread well, and a fleet-wide restart must not reset them. 2. **Delay the first run after start.** Splay that applies only to later cycles does nothing for the first run after a power return. 3. **Back off retries with jitter.** Agents that wait longer, by a random amount, after each failure stop feeding the overload. 4. **Add capacity or reduce the cost per request.** More server replicas, or caching prepared answers, raise the 8 per second instead of spreading demand. ## What a team watches - **Request rate over a cycle.** A spike that recurs once per interval means the fleet is lined up. - **Request queue time and agent timeouts.** These show overload before hosts stop reporting. - **Age of the last report per host.** The maximum, against interval plus splay, tells you whether the fleet is really agreeing on time.

  • After a data-centre power cut, every host boots at once. Does a per-cycle splay protect the configuration server?
    Only if the first run after start is delayed too. An agent that runs immediately on start herds with every other host, whatever its later cycles do. So the first run needs a random startup delay, and failed requests need backoff with jitter, because retries from the first wave can keep the server down.
  • An urgent security fix cannot wait 30 minutes for every host. How do you speed it up without overloading the configuration server?
    Signal agents to run now, but in batches sized to the server. In this scenario, 8 requests per second means the whole fleet needs at least 500 seconds, a little over 8 minutes, even if nothing else is running. Sending the signal to everyone at once recreates the stampede splay was added to prevent.

  • Splay reduces the total work the configuration server has to do each cycle.
  • An interval alone guarantees hosts stay evenly spread, whatever started or restarted them.
  • Splay has no real cost, so a longer window is simply better.
  • Agents learn about a new revision the moment it is published, so splay delays nothing.
  • Quick retries on timeout help a struggling configuration server clear its backlog.