</> MAANG.io
system design · 301

Advanced

Master system design interviews with scalable architecture patterns, distributed systems, and real-world design challenges.

0/480 solved 0% complete

Section 8: Ask How Much, Not May I - Deep Dive: Hierarchical Quota Leasing

Executive Summary: Section 7 left an 8-byte bucket whose rate someone else sets. Here a regional allocator sets it, turning one batched demand report per LB per second into a rate share per (LB, key). We reject three splits, derive the formula, handle unseen keys, and add up overshoot and false blocks honestly.

Interviewer: "Contoso lands on 40 load balancers, with no per-request coordination. How do they add up to 10,000?"

You: "Each LB tells a regional allocator what it wants, once a second, and gets back a rate it may use for 3 s. That rate is only the T in Section 7's bucket. The allocator is asked 'how much?' 500 times a second, never 'may I?'"

Four Ways to Split 10,000

Option Contoso at 14,000 req/s on 40 LBs Verdict Flip trigger
Static split, quota ÷ 500 40 × 20 = 800 admitted. 9,200 req/s false-blocked Rejected Traffic spread evenly over every LB
Central INCR per request Correct, but 15M ops/s, 0.5–1 ms RTT, 2M req/s on one key (Section 3) Rejected Small deployments, exact per-request counting
Token chunks via INCRBY (legacy) Tokens strand on quiet LBs. 500-token chunks cost 4,000 RPCs/s on the 2M req/s cap Rejected Billing-grade quotas, where prepaid chunks never overshoot (Section 12)
Rate-share leases 250 req/s each, ~4,000 req/s rejected (≈ 29%) Chosen (D2) —

Chunks are spent, trading RPC rate against stranded tokens. A rate share is renewed; an idle LB's drops to zero at its next report.

Sign in to continue reading

The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.

Sign in to read the full lesson

Sign in to MAANG.io

Use your Google or Microsoft account — no password to remember.

Continue with Google Continue with Microsoft

Please accept the terms above to continue.