Preparing your design workspace

Loading the problem and your latest saved attempt…

Design Cloud Usage Billing Infrastructure

Design retry-safe usage metering, versioned pricing, account invoices, reconciliation, and portal-visible usage across many cloud services.

Problem statement

Design billing infrastructure that accepts usage from different cloud services at any granularity, generates bills for accounts, and lets account users inspect service usage.

For this exercise, assume every producer emits immutable usage events with an account, service, meter, quantity, event interval, producer event ID, and schema version.

The platform validates and deduplicates exact retries, preserves accepted raw evidence, and prices usage with the rate-card version effective for the metered interval.

One invoice period can remain provisional for bounded late events, then closes to an immutable invoice version; an explicit correction creates a later auditable version rather than rewriting the closed bill. Account users read authorized usage aggregates, cost breakdowns, invoice status, and freshness.

Assume five million accounts, 20 million usage events per second, p95 portal queries below two seconds, events up to 24 hours late, and seven years of invoice history. Payment collection, tax calculation, service provisioning, and product-specific quota enforcement are outside scope.

What to build

  1. Cloud services can submit usage at their natural granularity and retry without charging one logical event twice.
  2. The platform retains accepted usage evidence and applies the rate-card version effective for each metered interval.
  3. The platform generates account invoices with provisional, closed, and corrected versions whose totals are auditable.
  4. Authorized account users can inspect service usage, cost breakdowns, invoice status, and data freshness.

At scale

  • Five million accounts and 20 million usage events per second are authored practice assumptions.
  • Usage events may arrive up to 24 hours late and portal queries complete below two seconds at p95 under admitted load.
  • Immutable invoice history is retained for seven years and acknowledged evidence survives one availability-zone failure.