Usage billing
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Layer 3 · Go deeper · 7 min

    Go deeper

    Size it, build it, then make the calls an interviewer will push you on.

    Back of the envelope

    Size it up

    Tap through each step of the arithmetic.

    How many usage events do 2 billion API calls a day make?

      How much dedupe state do 7 days of event IDs need?

        What does tenant t_7f3a cost to serve each month?

          Build-up · 6 steps

          Follow one usage event to the invoice

          One event, 1,840 output tokens for tenant t_7f3a, from the service that did the work to a line on its invoice.

          Step 1 of 6

          Emit without blocking

          The request path only appends the event, its ID minted when the work completed, to a local spool, memory first, then disk. Billing can never slow down or fail the request.

          4 interview moments

          You’re the candidate

          The interviewer pushes on the hard parts. Pick an approach and see how it holds up.

          1. Deep dive 1 of 4

            Interviewer

            “Shippers resend batches when acks get lost, and consumers reprocess events after a crash. How do you stop usage being billed twice?”

            Your move. Pick an approach:

          2. Deep dive 2 of 4

            Interviewer

            “October just ended. Spools are still draining after an outage and a mobile SDK syncs tomorrow morning. When do you finalise October’s invoices?”

            Your move. Pick an approach:

          3. Deep dive 3 of 4

            Interviewer

            “Your API meter has three tiers, ₹0.50 a call to 100,000, ₹0.30 to 1,000,000, ₹0.20 beyond. How do you apply them?”

            Your move. Pick an approach:

          4. Deep dive 4 of 4

            Interviewer

            “A tenant has a hard quota of 1,000,000 calls, and the gateway gets about a millisecond per request. What does it check?”

            Your move. Pick an approach: