Skip to content

Fairness and quota

Two separate controls decide how much work is dispatched and in what order. Quota is a ceiling and answers whether anything may go; fairness is an ordering and answers what goes first. This page is both, and both are deterministic.

Quota resolves the narrowest scope that has state

flowchart TB
  subgraph WS["WORKSPACE"]
    direction TB
    WQ[("window state")]
    subgraph PR["PROJECT"]
      direction TB
      PQ[("window state")]
      subgraph BD["BINDING<br/>by name, then project:binding"]
        direction TB
        BQ[("window state")]
      end
    end
  end

The scopes nest, and the search starts in the innermost box and moves outward. The first scope with recorded window state wins, and the search stops there. A binding-level window therefore overrides the project's, and a project's overrides the workspace's, rather than the three composing.

Where no scope has state, nothing is blocked and the full request is allowed.

The admission decision

Quota admission takes the recorded window state and the number of dispatches requested, and returns a decision rather than a boolean:

blocked, reason, retry_after_ms
allowed_dispatch_count
scope_kind, scope_name
throttle_state, window_seconds
max_dispatch_units, consumed_dispatch_units, remaining_dispatch_units

Four outcomes are possible, in this order:

Condition Outcome
throttle_state is hard_throttle Blocked with assignment_dispatch_quota_hard_throttle, nothing allowed
No maximum is set Allowed in full
Nothing remains in the window Blocked with assignment_dispatch_quota_exceeded
Some remains Allowed up to what remains

A partial allowance is the normal case near a ceiling: the request is trimmed to the remaining units rather than refused outright.

Retry timing comes from the window

A blocked decision carries retry_after_ms, computed from the window length with a floor of one second. A caller that respects it retries when the window could plausibly have moved, rather than on a timer of its own choosing.

The window defaults to 60 seconds where none is recorded.

Fairness orders what quota allows

Fairness is a two-level ordering. Candidates are grouped into three priority classes, and within each class they are distributed round-robin across projects:

high     taken first
normal   taken next
low      taken last

An unrecognised priority normalises to normal, so an unexpected value orders predictably instead of sorting to an edge.

Round-robin within a class is what keeps one busy project from consuming a class. Ten candidates from one project and one from another interleave rather than running in submission order.

The two controls compose

Quota decides how many dispatches this pass may make. Fairness decides which candidates fill that allowance. A project at the front of the fair-share rotation still yields nothing when its workspace is hard-throttled, and a workspace with quota to spare still dispatches in priority and round-robin order.

See The scheduler for the in-flight ceilings applied before either of these.