call(back)

Design a Global Multi-Tenant Quota System

Design a quota system that enforces one limit per tenant — requests, compute seconds, storage bytes — across several backend services that each consume from it. A tenant must not exceed its quota by much, no service may be slowed noticeably by the check, and usage must be reconcilable after the fact.

Cover the usage record and where it lives, how a service checks and consumes quota, how concurrent consumption from several services is kept honest, and the consistency-versus-latency decision at the heart of it.

Hints

Hint 1

One usage record per tenant in a store with atomic increments; services reserve an amount, do the work, then commit or release.

Hint 2

Idempotent usage events — keyed by (service, request id) — so a retried request does not double-count.

Hint 3

Strict consistency on every check versus local token leases per service that trade a little over-admission for latency.

Asked at