Skip to content

Bounce methods

Dave Cuza edited this page Oct 3, 2026 · 1 revision

A bounce replaces a Service's replicas with ones running the new spec. bounce_method picks the shape. All four use the same planner loop; they differ in how many extra replicas may exist (surge), how many of the N may be missing (unavailable), and whether health gates the change.

bounce_method Surge Unavailable Health gates draining Kubernetes equivalent
crossover (default) ceil(N × overprovision) floor(N × (1 − margin)) yes RollingUpdate
upthendown N 0 yes, all N new first none
downthenup 0 N no (old go first) Recreate
brutal N N no RollingUpdate with maxUnavailable: 100%

The animations below replace three v1 replicas with three v2 ones. Each is generated from the real planner (bounce.Plan) against a simulated world.

crossover

Animation: crossover with three replicas. app-4 (v2) starts, joins Envoy's list and turns healthy, then app-1 (v1) leaves the list, finishes its in-flight requests and is removed; app-5 and app-6 replace app-2 and app-3 the same way. Three replicas serve throughout and at most four exist.

Shown with bounce_overprovision_factor: 0.33 (surge 1): each new replica joins before an old one leaves, so three replicas always serve and at most four exist.

New replicas start while the surge allows; an old replica drains whenever enough new ones are happy (healthy for min_task_uptime) that capacity stays at or above N − unavailable. Choose it for production services: it is the default, never drops below the margin you set, and the two factors trade speed for extra containers.

upthendown

Animation: upthendown with three replicas. app-4, app-5 and app-6 (v2) start, join Envoy's list and turn healthy while app-1 to app-3 (v1) keep serving; only then are app-1, app-2 and app-3 drained and removed one at a time.

All N new replicas start and must all be happy before any old one drains; then the old ones drain one at a time. Up to 2N replicas exist. Choose it when the host has room for twice the Service and you want the whole old version serving until the whole new one is proven.

downthenup

Animation: downthenup with three replicas. app-1, app-2 and app-3 (v1) are drained and removed one at a time; with nothing serving, requests fail while app-4, app-5 and app-6 (v2) start, until each turns healthy and receives traffic.

Every old replica is drained (with the configured drain method) and removed first, one at a time; only then do new ones start. Requests fail from the moment the last old replica leaves until a new one is healthy. At most N replicas exist. Choose it when two versions must never run side by side (an exclusive lock on a file or port, an incompatible migration) or the host has no room for even one extra replica.

brutal

Animation: brutal with three replicas. app-4, app-5 and app-6 (v2) start and join Envoy's list; app-1, app-2 and app-3 (v1) are then taken off the list and removed at once, before any new replica is healthy, so requests fail until app-4 turns healthy.

All N new replicas are created (up to 2N exist); as soon as they are running, the old ones are taken off Envoy's list and stopped without a drain wait. Health is not checked: "running" counts as healthy, min_task_uptime and the drain method are ignored, and up can return before Envoy has seen a new replica pass its health check. Requests fail until a new replica is healthy. The stop itself still honours each container's stop_grace_period. Use it for development loops only.

Surge and unavailable

For crossover, with N = deploy.replicas:

surge       = ceil(N × bounce_overprovision_factor)
unavailable = floor(N × (1 − bounce_margin_factor))
if surge == 0 and unavailable == 0: surge = 1
  • A tolerance of 1e-9 is applied before rounding so floating-point error does not change the result: 10 × (1 − 0.9) counts as 1, not 0.999…, and 3 × 0.33 (0.99) still rounds up to 1.
  • The surge-1 guard exists because with no room to add and no room to remove, a crossover could never make progress.
  • upthendown, downthenup and brutal ignore both factors.

Each pass of the loop, after the health-deadline, dead-replica and list checks described in How it works:

  1. Drain the next old replica (old replicas that serve nothing first, then oldest first) if happy(new) + live(old) − 1 ≥ N − unavailable. Draining a replica that is not serving costs nothing, so the − 1 is dropped for it.
  2. Otherwise start one new replica if fewer than N new ones exist and the total is below N + surge.
  3. Otherwise wait for a Docker event or one second, and look again.

happy(new) counts new replicas healthy in Envoy (and Docker, if they have a healthcheck) for at least min_task_uptime; live(old) counts old replicas that are running and healthy in Envoy.

Worked examples

N = 3

Settings Surge Unavailable Most replicas What happens
defaults (margin 0.95, overprovision 1.0) 3 0 6 All three new start at once; each old one drains as a new one becomes happy
overprovision 0.33 1 0 4 One new starts; once happy, one old drains; repeat (the animation)
overprovision 0, margin 1.0 0 → 1 0 4 Same as above via the surge-1 guard
overprovision 0, margin 0.5 0 1 3 One old drains first (2 serve), then one new starts; once happy, the next old drains
margin 0.9, overprovision 0 0 → 1 0 4 floor(0.3) = 0, so the guard applies

N = 10

Settings Surge Unavailable Most replicas What happens
defaults 10 0 20 All ten new start; old drain one by one as new become happy
margin 0.9, overprovision 0 0 1 10 Drain one old (9 serve), start one new, wait until happy, drain the next
margin 0.9, overprovision 0.2 2 1 12 One old drains right away, then three new start (12 exist); each happy new releases another old; capacity never below 9
overprovision 0.33 4 0 14 Four new start; each happy one releases an old one, which makes room for the next new
margin 0.5, overprovision 0.5 5 5 15 Five old drain first (5 serve), then all ten new start (15 exist); fast, at half capacity

With the defaults, unavailable stays 0 until N reaches 20 (floor(20 × 0.05) = 1), so a default crossover never drops below N healthy replicas.

Failure and partial bounces

A new replica that is not healthy by its bounce_health_timeout fails the bounce: every new replica that is not healthy is removed, healthy new ones stay, and up exits 1. Old replicas are drained only as new ones become happy, so the old version keeps serving. With N > 1 a failed crossover can leave a mix of happy new and remaining old replicas serving together, so keep schema changes expand/contract. Undo is explicit: docker bouncer undo, or up with the previous file. See Operations.

Regenerating the animations

The SVGs in docs/bounce-<method>.svg are generated from the real planner; regenerate them after changing it:

go run ./docs/animations

The generator only writes those four files; docs/how-it-works.svg is hand-made and left alone.

Clone this wiki locally