Skip to main content

Module window

Module window 

Source
Expand description

Sliding-window counter math for the global (cross-instance) limit view.

A fixed window has a boundary burst: a client can spend a full window’s quota just before the boundary and another just after. The sliding-window counter smooths this by blending the current epoch’s count with a decaying fraction of the previous epoch’s, which is why the fleet-wide gate has no boundary burst even though the local shaper is GCRA.

Functions§

elapsed_in_window
How far into the current window now sits.
epoch
The epoch (window index) for now, aligned to wall-clock so every instance agrees on window boundaries.
sliding_estimate
Blend the current-epoch count with the previous epoch’s, weighted by how much of the current window remains: a request early in the window still “sees” most of the previous window’s traffic, decaying to none by the boundary.