What cloud infrastructure taught me about building billing systems

Provisioning is a state machine, not an action

Nobody who has built infrastructure resource provisioning systems believes in just “create.” Create is a journey: validate the request, reserve capacity, allocate resources, configure, activate. Each step can fail, and when one fails halfway through, you are left with something that is neither quite a resource nor quite nothing. Half-created objects are a fact of life in provisioning systems at scale. The code that finds, finishes or sweeps them is where much of the real engineering lives.

Billing has the same shape. A subscription is not an event; it is a state machine: trial, active, past due, paused, canceled. The interesting bugs all live in the transitions: the upgrade that half-applied, the plan change scheduled for period end that fired twice, the trial that converted but kept its trial price. If you have ever chased a VM that exists in the database but not on any host, you already understand the subscription that bills for a plan the customer cannot see.

Consider a customer who upgrades mid-cycle. The plan change commits on the subscription record, but the entitlement service never hears about it. The customer pays for the upgrade but does not receive the corresponding access. Three weeks later, support gets a ticket. Support can see the charge but not the missing entitlement. This is the subscription twin of the VM that exists in the database but not on any host: the create journey got halfway and nobody swept it.

Donner Music, make your music with gear
Multi-Function Air Blower: Blowing, suction, extraction, and even inflation

Leave a reply

Please enter your comment!
Please enter your name here