Pidoku

Multi-Tenancy and Quotas

Module 21 Lesson 21.f 1h 15m Difficulty 4/5

Prerequisites 20.k, 23.i, 23.j


Before you start: words you need#

WordPlain meaning
TenantA customer or team whose traffic shares the platform with others.
QuotaThe most a tenant may use: tokens per minute, concurrent requests, GPUs.
FairnessWhat happens when everyone wants their maximum at once: who gets served first.
Weighted fair queueingServing tenants in proportion to agreed weights, however fast each one submits.
Deficit round robin (DRR)A simple, cheap way to implement weighted fair queueing: each tenant earns credit every round and spends it on requests.
Showback / chargebackShowing each team what it used and what it cost (showback), or actually billing them (chargeback).
Noisy neighbourA tenant whose traffic degrades other tenants’ latency or capacity.

1. What is it?#

Multi-tenancy is letting many teams or customers share one fleet. It has to provide four things:

1. ISOLATION       one tenant cannot see another's data
2. FAIRNESS        one tenant cannot starve another
3. ACCOUNTABILITY  you know who used what
4. FLEXIBILITY     tenants can have different SLOs and limits

Security isolation is in 23.i, and the enforcement of limits (token buckets, rate limits) is in 23.j. Priority classes inside one server are in 20.k. This lesson is the platform design: how tenants share a cluster, how quotas are structured, and how fairness is enforced across a fleet.

Facts checked on 12 November 2026.


2. Why does it matter?#

Sharing is where most of the money is:

5 teams, each with its own deployment:
  each sized for its own peak, at 60% target utilisation
  each peaks at ~15 req/s and needs 2 replicas → 10 replicas
  average running batch per replica: 11

One shared platform:
  the teams' peaks do not coincide, so the combined peak is ~45 req/s, not 75
  6 replicas at the same target utilisation
  average running batch per replica: 28

→ 40% fewer GPUs, and higher tokens per GPU from the bigger batches (14.m)

Two effects compound: peak smoothing and batch concentration. That is the core value of an inference platform.

The organisational cost: teams give up control, and they will only accept that if the fairness guarantees are believable. That is mostly a trust problem, solved by visible per-tenant numbers (section 8).


3. Simple analogy#

A shared motorway with toll lanes. Quotas are the number of trips your pass allows per day. Fairness is the merge rule at the bottleneck: without one, the company running a hundred lorries blocks the commuter. Reserved lanes are like reserved capacity; the open lanes are burst capacity anyone can use when they are empty.


4. Tiny example: quotas are not fairness#

tenant A: quota 100k tokens/min    tenant B: quota 10k tokens/min
both submit continuously, both are within quota.

First come, first served → A gets ~90% of the GPU because it submits more.
B is starved despite never breaking its quota.

Weighted fair queueing with weights 3:1 → A gets 75%, B gets 25%,
however fast each submits.

Quotas bound the maximum. Fairness decides what happens under contention. You need both.


5. Technical explanation#

The isolation spectrum#

LEVEL                                 ISOLATION   EFFICIENCY   USE
Shared model, shared engine, shared   weak        highest      one team's own services
  prefix cache
Shared model and engine, prefix       weak-med    high         internal teams, same trust
  cache salted per tenant                                       domain
Separate engine process per tenant    medium      medium       untrusted tenants, same model
MIG slice per tenant (21.d)           strong      medium-low   regulatory isolation
Separate node pool                    strongest   low          dedicated contracts
Separate cluster                      strongest   lowest       sovereign / air-gapped

Most internal platforms should default to the second row. Shared prefix caches are a timing side channel: a tenant can measure time to first token and learn whether someone else’s prompt started with a guessed prefix. vLLM mitigates this with a cache_salt request field, mixed into the hash of the first KV block so only requests with the same salt share cached blocks. Two rules from vLLM’s own security guide:

  • the gateway (21.i) sets the salt from the authenticated tenant; never trust a client-supplied one,
  • the salt must be a secret random value per tenant (for example 256 random bits), not a guessable tenant name.

vLLM’s guide is also explicit that a shared server process is not an isolation boundary. Tenants that must be isolated need separate engine instances or stronger.

The cost of salting: a system prompt shared by five tenants is cached five times. For a 2,000-token prompt at 128 KiB per token that is 5 × 256 MB = 1.28 GB instead of 256 MB, usually acceptable.

Quota models#

ModelHow it worksTrade-off
Hard partitionTenant A owns nodes 0–3, B owns 4–7Perfect isolation; no sharing benefit. Only when a contract demands it
Reserved + burst20 req/s guaranteed, may burst to 50 when capacity is freeCredible guarantees and most of the sharing benefit. The usual answer
Pure weighted shareNo guarantee; each gets weight/Σweights under contentionMost efficient; hard to sell to teams with SLOs
Credit / budgetUsage draws down a budgetAligns with billing; does nothing about instant contention. Combine with one above
RESERVED + BURST, IN PRACTICE
  Σ reserved ≤ ~70% of capacity        (room for burst and for failures)
  reserved traffic: always admitted, highest priority
  burst traffic: admitted while capacity is free, shed first under load

Two levels of quota#

A platform enforces quota at two levels, with different tools:

CAPACITY LEVEL (minutes)   how many GPUs or replicas each team may hold
   → Kueue ClusterQueues and cohorts (borrowing idle quota, giving it back),
     KAI Scheduler's hierarchical queues with fair share and over-quota weights,
     Kubernetes ResourceQuota for the simple case (21.e)

REQUEST LEVEL (milliseconds) how many tokens, requests and concurrent streams per tenant,
                             and who is served first when replicas are full
   → gateway token buckets (23.j), the router's flow control (below),
     the engine's priority scheduling (20.k)

Fairness in the fleet: flow control#

When every replica is full, someone has to wait. Doing that well across a fleet is now built into the open routers:

  • llm-d v1.0 (October 2026) added priority- and fairness-aware flow control in its router: it queues requests per priority and per tenant, admits them as replicas free up, and sheds load in a controlled way.
  • The InferenceObjective resource, which gives a workload a priority, moved from the Gateway API Inference Extension to llm-d in August 2026.
  • Dynamo 1.6 (October 2026) added pluggable flow control to its router, with a policy queue ordered by deadline.

Underneath they all do a version of weighted fair queueing, shown in section 6.

Noisy neighbours#

HOW ONE TENANT DEGRADES ANOTHER                    MITIGATION
1. fills the KV cache with long-context requests   per-tenant KV block / concurrency limits (23.j)
2. long prefills stall others' decode              chunked prefill; long prompts to their own pool (21.g)
3. submits continuously and wins first-come        weighted fair queueing (section 6)
4. pushes memory to the limit, causing preemption  per-tenant concurrency limits, headroom
5. pathological requests (huge n, bad grammars)    validation limits at the gateway (20.b)
6. floods the prefix cache with unique prompts     per-tenant cache salt and cache quota

Item 6 is subtle. A tenant sending millions of unique prompts fills the prefix cache with entries nobody will reuse and evicts other tenants’ useful prefixes. A per-tenant salt keeps them apart but does not stop the eviction; a per-tenant share of cache capacity does.

Onboarding a tenant#

□ tenant ID and scoped API keys
□ tier (free / standard / premium / reserved) and SLO tier
□ quotas: token rate, concurrency, KV share, requests/min; GPU quota if they run their own models
□ model access list and capability scope (tools, structured output, logprobs)
□ data handling: logging, retention, training use
□ cost centre for showback or chargeback
□ incident contact and dashboard access
CAPACITY CHECK
□ does their projected peak fit in today's headroom?
□ if reserved: is Σ reserved still ≤ 70%?

The capacity check is the item that gets skipped, and it is how platforms end up oversubscribed.


6. Under the hood: deficit round robin#

Each tenant has a queue and a credit balance (its “deficit”). On each visit a tenant earns its weight in credit and is served while its credit covers the next request. A tenant with an empty queue loses its credit, so it cannot save up and burst.

Go
// drr.go — deficit round robin over tenants, weighted by their share.
package main

import "fmt"

type Request struct {
	Tenant string
	Cost   float64 // weighted tokens
}

type FairScheduler struct {
	weights map[string]float64
	deficit map[string]float64
	queues  map[string][]Request
	order   []string
	idx     int
}

func NewFairScheduler(order []string, weights map[string]float64) *FairScheduler {
	return &FairScheduler{weights, map[string]float64{}, map[string][]Request{}, order, 0}
}

func (s *FairScheduler) Enqueue(r Request) { s.queues[r.Tenant] = append(s.queues[r.Tenant], r) }

func (s *FairScheduler) Dequeue() (Request, bool) {
	pending := false
	for _, q := range s.queues {
		pending = pending || len(q) > 0
	}
	for pending {
		t := s.order[s.idx]
		q := s.queues[t]
		if len(q) > 0 && s.deficit[t] >= q[0].Cost { // keep serving this tenant while its credit lasts
			s.deficit[t] -= q[0].Cost
			s.queues[t] = q[1:]
			return q[0], true
		}
		if len(q) == 0 {
			s.deficit[t] = 0 // don't accumulate credit while idle
		}
		// move on: the next tenant earns its weight in credit
		s.idx = (s.idx + 1) % len(s.order)
		s.deficit[s.order[s.idx]] += s.weights[s.order[s.idx]]
	}
	return Request{}, false
}

func main() {
	s := NewFairScheduler([]string{"big", "small"}, map[string]float64{"big": 300, "small": 100})
	for i := 0; i < 40; i++ { // both tenants flood the queue with identical requests
		s.Enqueue(Request{"big", 100})
		s.Enqueue(Request{"small", 100})
	}
	served := map[string]int{}
	for i := 0; i < 40; i++ {
		r, _ := s.Dequeue()
		served[r.Tenant]++
	}
	fmt.Println(served) // map[big:30 small:10] — a 3:1 split, matching the weights
}

Output:

map[big:30 small:10]

Measure cost in weighted tokens, not requests: input tokens × w_in + output tokens × w_out, plus a term for KV memory held over time if long contexts are common. A tenant sending few, huge requests otherwise gets far more than its share. 23.j shows a simpler “lowest service / weight first” picker for a single gateway; DRR is the version that stays O(1) per decision with many tenants.


7. Performance implications#

  • Fair queueing costs almost nothing. A DRR decision is a few map operations; the expensive part is measuring cost accurately.
  • Isolation costs efficiency. Each step down the isolation table loses some sharing: salted caches lose cross-tenant hits, separate engines lose shared batches, MIG loses the ability to lend idle capacity.
  • Reserved capacity left idle is paid for. Burst traffic and low-priority batch work (21.g) are how you use it without breaking the reservation.
  • Fairness at the router uses stale load data. Admit conservatively and let the engine’s own scheduler (20.c, 20.k) make the final call.

8. Production implications#

  • Default to a shared model with prefix caches salted per tenant, salts set by the gateway and kept secret. Separate engines when tenants must be isolated.
  • Weighted fair queueing at the router, priorities in the engine, quotas at the gateway and the capacity scheduler.
  • Reserved + burst for mixed SLO needs, with Σ reserved at about 70% of capacity.
  • Per-tenant limits on concurrency and KV, not just token rate.
  • Publish per-tenant numbers: requests, input and output tokens, cost, their latency percentiles, quota used and headroom, rejection rate and reasons. Showback alone often changes behaviour, because teams discover spend they did not know about.
  • Use the onboarding checklist, capacity check included.

9. Common mistakes#

  1. Quotas without fair queueing. A tenant within quota starves others.
  2. Limiting tokens but not concurrency or KV. The scarce resource is memory.
  3. A shared, unsalted prefix cache across untrusted tenants. Timing side channel (23.i).
  4. Using the tenant name as the cache salt, or accepting a client’s salt. Guessable.
  5. No per-tenant cache share. One tenant evicts everyone’s useful prefixes.
  6. Overcommitting reserved capacity. No room for burst or for failures.
  7. Onboarding without a capacity check.
  8. Only fleet-wide dashboards. Teams cannot see their own experience and stop trusting the platform.

10. Hands-on exercise#

  1. Quantify the sharing benefit. For five synthetic tenants with daily peaks at different hours, compute GPUs needed for dedicated deployments and for one shared platform. Include the batch-size effect using a throughput-vs-batch curve from 12.q.
  2. Run drr.go. Give small requests a cost of 400 and big a cost of 100. Is the split still fair in tokens? Then let small go idle for 1,000 rounds and come back: does it burst? Remove the idle reset and try again.
  3. Noisy neighbour. Simulate a tenant sending 64k-token prompts into a shared pool. Measure the other tenants’ p99 time to first token, then add a per-tenant concurrency limit and re-measure.
  4. Salting. On a vLLM server with prefix caching, send the same long prompt from two “tenants” with and without different cache_salt values, and compare time to first token for the second request.

11. Interview questions#

  1. What is the economic case for a shared inference platform? Quantify it.
  2. Why do quotas alone not give fairness?
  3. Explain deficit round robin, and why an idle tenant must not accumulate credit.
  4. What is the reserved + burst model, and why cap total reservations?
  5. Name four ways one tenant can degrade another, with the mitigation for each.
  6. Why salt the prefix cache per tenant, how should the salt be chosen, and what does it cost?
  7. Where do quotas live at the capacity level and at the request level?

12. Further reading#

Checked on 12 November 2026.

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in