Skip to content

CONCEPT Cited by 1 source

Declarative quota rule

A declarative quota rule expresses the quota's intent as structured data — subject + scope + predicate + limit + action — so that a platform can read, validate, reason about, and automate the rule, rather than as imperative code or ad-hoc thresholds buried inside each service.

Imperative / ad-hoc vs declarative

Imperative

// ad-hoc: if-statement buried in a service
if (request.getUser() == heavyUserId) {
  if (currentRps > 500) throw new TooManyRequestsException();
}

Problems:

  • The full set of rules is hidden across N services.
  • A tool can't validate that a user's rules sum to the cluster's capacity.
  • A UI can't display "show me user X's rate limits".
  • An auto-rightsizing service can't recompute and rewrite these — they live in code.

Declarative

# declarative: structured rule in a rule store
- subject: user:heavy
  scope: read-path
  predicate:
    query_type: scan
  limit:
    type: rps
    value: 500
  action: throttle

Properties the platform can now offer:

  • UI rendering — list, search, filter, edit rules.
  • Validation — cross-rule invariants (sum of rules per cluster ≤ cluster capacity — see pluggable validation framework).
  • Automated rightsizing — the rightsizing service can produce new structured rules from historical usage.
  • Auditability — structured diffs of rule changes.

Named as a prerequisite at Pinterest

Pinterest's prior online-storage rate limits named non-declarative-ness as their first limitation:

"The existing rules are not declarative, hindering support for diverse and complex use cases, such as sophisticated queries or specific request properties." (Source: sources/2026-02-24-pinterest-piqama-pinterest-quota-management-ecosystem)

The Piqama redesign makes rules first-class declarative definitions so that the other pieces (Piqama lifecycle, PinConf distribution, SPF local enforcement, rightsizing service) all have a structured artifact to operate on.

Applies beyond rate limits

Capacity quotas benefit equally: declarative {project: X, resource: memory, guarantee: 100GB, max: 500GB, max_concurrent_apps: 10} is directly consumable by the Yunikorn Config Updater and by the rightsizing strategy generating the next value. Imperative if (project == 'X') { queue.maxMemory = 500 * GB } is not.

Seen in

  • sources/2026-02-24-pinterest-piqama-pinterest-quota-management-ecosystem — canonical wiki introduction. Listed explicitly as the first prerequisite for the rate-limit redesign. "As we design our next-generation rate limiting framework, we'd like to streamline the lifecycle management of rate limits, and also treat rate limits as a notion of 'quota' that's linked to the actual system resource usage, for better cost control and budgeting management."
Last updated · 319 distilled / 1,201 read