System Design Atlas

Subscription billing, usage and service entitlements

08 / 10Worked example

Investigating bottlenecks

Which measurement locates the bottleneck when invoices are queued?

The failure sequence shows where load and retries interact. The diagnostic plan treats measured waiting time, processing duration and business conflicts separately.

Starting point Query the same Z-161.

Assumptions for the example case

Original fictional example design: one monthly contract in EUR, positive integer usage units, a fixed tariff version per period, one invoice and one payment order, and separate correction records. Figures and quality targets are illustrative test assumptions. Tax law, multiple currencies, prorated tariff changes and debt collection are outside the scope.

Diagnose the limiting resource

Finalisation backlog and watermark contention

Month-end finalisation27.78 invoices/s
Finalisation ageQueue + throughput
Usage versus finalisationN-161
Total across records1,200 total

27.78 invoices/s determines processing duration; the invoice plus correction verifies the correct business ordering.

Invoices are queued despite fast usage ingestion. Measure tariff calculation, lock waits and the payment queue separately. Expand capacity at the actual bottleneck.

From signal to action

SignalValidationReaction
Locate the finalisation backlogInvoices are queued despite fast usage ingestion.Measure tariff calculations, locks and the payment queue separately.
Conflicts on the shared entityPeriod finalisation and N-161 compete. Ingestion wins: R-161 totals 1,200 cents. Finalisation wins: R-161 totals 1,000 cents, and N-161 produces a separate 200-cent correction record after review. In either order, the 100 units are billed only once overall.Count expected conflicts separately from technical errors.
Peak test profile exceededMonth end 100,000 invoices in 3,600 s = 27.78 invoices/sA tariff becomes computationally more complex.

Locate the finalisation backlog

Validation
Invoices are queued despite fast usage ingestion.
Reaction
Measure tariff calculations, locks and the payment queue separately.

Conflicts on the shared entity

Validation
Period finalisation and N-161 compete. Ingestion wins: R-161 totals 1,200 cents. Finalisation wins: R-161 totals 1,000 cents, and N-161 produces a separate 200-cent correction record after review. In either order, the 100 units are billed only once overall.
Reaction
Count expected conflicts separately from technical errors.

Peak test profile exceeded

Validation
Month end 100,000 invoices in 3,600 s = 27.78 invoices/s
Reaction
A tariff becomes computationally more complex.

Locate the finalisation backlog

Locate the finalisation backlog

Measure tariff calculations, locks and the payment queue separately.

Invoices are queued despite fast usage ingestion.

Expand capacity at the actual bottleneck.

Alternative considered
More ingestion APIs do not accelerate invoice generation.
Trade-off
Measurements need a billing-period reference.
Reassess
A tariff becomes computationally more complex.

Terms in this step

Locate the finalisation backlog
Expand capacity at the actual bottleneck.

Try it yourself

Usage ingestion is fast, but invoices are queued. Which three causes do you check separately?

A hint for your attempt

Use the specific entities and conditions from this step. The two solution parts distinguish the decision from its evidenced outcome.

Compare with a possible solution
First part of the solution
Measure tariff calculation time, lock waiting time during finalisation and the payment queue separately.
Second part of the solution
Expand only the slow stage; additional ingestion APIs do not remove an invoice-generation bottleneck.

Apply to your project

Which corresponding assumption in your project would you check first when tariff calculations become more complex?

Step 9 examines how to explain entitlement restrictions.