Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 12.5 — Multi-Tenant Limits and Isolation
LLM Engineering · Example 1 of 1

A leak, its fix and per-tenant quotas

Acme must never see Globex's discount code. Prints the bug, the fix and a quota burst.

When many customers share one LLM service, each needs their own quota, their own data and their own failure domain. The core rules: identify the tenant first, put the tenant into every query, cache key and limit, and test that tenant A can never see tenant B.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 6 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write cache_key(tenant, model, question) that returns one string that differs for each of the three inputs and normalises the question to lower case with single spaces. Show that two tenants asking the same question get different keys.

02

Write TenantLimiter(limit) with allow(tenant) that counts per tenant and refuses after the limit. Show that one tenant's burst does not affect another.

Explain it without notes

01

What is a noisy neighbour and how do you contain it in an LLM service?

02

Where can cross-tenant data leaks happen in an LLM application?

03

How should the tenant id be established and passed around?

04

How do you test tenant isolation?

A leak, its fix and per-tenant quotas
Sign in to run this example in your browser.

Expected output

shared: acme asks about 'discount' -> discount code is SAVE20
scoped: acme asks about 'discount' -> no match
scoped: globex asks about 'discount' -> discount code is SAVE20
acme:ok acme:ok acme:ok acme:429 acme:429 globex:ok