Design a Global Multi-Tenant Quota Service (Single Global Quota per User)
Context
Multiple upstream products (e.g., Drive, Photos) share a single global storage quota per user (e.g., 100 GB per user). The quota service must prevent overdrafts at all times while serving millions of daily active users and QPS across regions.
Functional Requirements
-
Consume quota.
-
Release quota.
-
Optionally query current quota state.
Non-Functional Requirements
-
Never allow overdraft at any time.
-
High consistency and high availability.
-
Low latency where possible.
-
Scale to millions of DAU and QPS.
Design Prompts
-
Define APIs (consume, reserve, confirm, release, query) and idempotency.
-
Choose storage and data model; justify ACID needs.
-
Describe read/write paths and replication/ack strategy to prevent double-spend.
-
Handle concurrency across services/regions and race conditions.
-
Model quota states (Available, Reserved with TTL, Occupied) and timeout/recovery.
-
Choose sync vs async for consume/release and failure handling/retries.
-
Propose sharding and multi-region disaster recovery/failover.
-
Decide on caching or no-caching and keep it consistent.
-
Add backpressure/rate limiting and hot-key mitigation.
-
Outline monitoring, SLOs, and capacity planning.