Usage Metering & Billing Pipeline  ·  View 02 of 22  ·  Context and scope

High-Level Architecture

The seven stages from a produced event to a consumed invoice, and the one place the serving path touches them.

Editable source SVG draw.io All views
Produce Product services durable buffer Edge nodes Partner feeds Ingest Ingest API API Gateway Dedup index 7-day TTL Quarantine with reason Record Event stream Kinesis Event ledger S3 Iceberg Audit tail Glacier, locked Meter Aggregation Managed Flink Aggregate store DynamoDB Rate Rating service Plan registry versioned Entitlement service p99 10 ms Invoice Invoice run Step Functions Anomaly gate Invoice ledger Aurora Consume Usage & invoice API Payment, tax, ERP Evidence query Athena event id rejected lifecycle replay, evidence cap decision outbox High-Level Architecture — Produce to Invoice Application we own External / third party Interface / broker Data store Queue / topic Decision point synchronous failure / alternate batch event / async The spine is the billing path. The serving path touches it only at the cap decision. v 1.0 · owner Architecture Practice · date 2026-10

Decisions

  • Ingest acknowledges only after the event is durably replicated into the ledger, so a 202 is a billing guarantee rather than a receipt.
  • Rate and Invoice are separate stages because they fail differently: rating is per-account and retryable, the invoice run is per-period and must not double-issue.
  • Evidence query reads the ledger directly rather than the aggregate store, so a dispute is answered from the record and not from a projection of it.

Targets

  • Event acceptance p99 ≤ 50 ms, p99.9 ≤ 200 ms in-region (stated assumption).
  • Usage visible to customers p95 within 5 minutes, p99 within 15 (stated assumption).
  • Invoice run closes every account within 6 hours of period close (stated assumption).

Risks

  • The cap decision is the one synchronous dependency the product has on this platform; its availability requirement is therefore the product's, not billing's.
  • The spine hides back-pressure: a stalled aggregator shows up as stale usage views long before it shows up as a wrong invoice.