Skip to content
All articles

Usage billing is a data-engineering problem

Why metering breaks at scale, and how counting each line against its records keeps 41M events honest.

Anubhav DubeyFounder, Verlix · 9 min read

Most billing systems treat usage as a number you are given. At scale it is not a number, it is a stream, and streams lose events, duplicate them, and arrive late.

The 3 failures

  • Late arrival: an event for the 30th lands on the 2nd, after you billed
  • Duplication: a retry writes the same event twice and the customer is billed twice
  • Silent loss: an event never lands and you under-bill without ever knowing
An invoice you cannot reproduce from the event stream is a guess with a due date on it.

Counted before invoices

The fix is to make the invoice line a claim about its usage records that can be checked. Each metered line carries the window it covers, duplicates come out before it is rated, and before the bill goes out the line is counted against the records inside that window; a line that does not match is held for review.

In the example workspace, that check ran across 41 million events a month and measured zero variance. Without it, the alternative is a monthly credit-note habit that quietly trains your customers to audit you.

See it in the product: BillingInvoices built from the signed contract, for seats, usage, credits and milestones.

Related