Multi-Tenancy and Isolation Questions
Serving many tenants from shared infrastructure: tenancy models (silo, pool, bridge), data isolation, per-tenant data residency, noisy-neighbor mitigation, per-tenant limits, and security boundaries between tenants. Covers the cost, isolation, and blast-radius tradeoffs of shared versus dedicated resources, and business continuity: per-tenant backup, disaster recovery, and compliant tenant offboarding and deletion. The architecture layer specific to SaaS and platform products.
Design an approach to isolate noisy neighbors in a shared cluster hosting multiple microservices from different teams and languages, where one workload's resource usage is degrading everyone else's latency. How would you contain a noisy tenant at the compute layer, and how would you detect this kind of interference before customers notice?
Sample Answer
Direct answer
Contain the noisy tenant in layers: make every workload declare what it needs (requests and limits, enforced at admission), give critical services guaranteed resources so the kernel protects them, move chronic offenders to their own node pool, and cap how far any team can autoscale so one service cannot take the whole cluster. Detect interference before customers notice by watching resource pressure signals (CPU throttling, run-queue delay, Linux PSI stall metrics, memory pressure, disk and network saturation) per node and correlating them with latency of co-located services, backed by synthetic probes on every node.
Here the "tenants" are teams' microservices sharing a Kubernetes cluster, written in different languages with different resource behaviour, and a noisy neighbour is the one whose usage degrades everyone else on the same nodes.
Containing it at the compute layer
1. Make resource needs explicit and enforced
Kubernetes turns pod requests and limits into Linux cgroup settings (cgroups are the kernel's mechanism for capping and weighting a group of processes):
- CPU request sets a relative weight (
cpu.weightin cgroup v2): under contention, CPU is shared in proportion to requests. - CPU limit sets a hard cap (
cpu.max): a quota of CPU time per 100 ms period. - Memory limit (
memory.max): exceed it and the container is OOM-killed (out-of-memory killed) instead of pushing the node into swapping or evicting neighbours.
Enforce with a LimitRange (defaults and maximums per container) and a ResourceQuota per team namespace, and an admission policy (a rule Kubernetes checks before accepting a new pod, rejecting it if it fails; Kyverno and OPA Gatekeeper from the Open Policy Agent project are two popular engines for writing these rules, alongside the built-in ValidatingAdmissionPolicy) that rejects pods with no requests. A pod without requests is scheduled as if it needs nothing, which is how nodes get overcommitted.
2. Use QoS classes deliberately
Kubernetes assigns each pod a QoS (quality of service) class: Guaranteed (requests equal limits for every container), Burstable (some requests set), BestEffort (none). Under memory pressure the kubelet evicts BestEffort first, then Burstable pods exceeding their requests. Put latency-critical services in Guaranteed, and with the kubelet's (the agent that runs on each node and manages the containers scheduled to it) CPU Manager static policy (a kubelet setting that pins a Guaranteed pod's whole-number CPU requests to specific physical cores instead of sharing them), Guaranteed pods requesting whole CPUs get exclusive cores, so no neighbour runs on them at all.
3. The CPU limit trap: a worked example
CPU limits cause their own latency. A pod with a limit of 2 CPUs gets a quota (a budget of CPU time) of 2 x 100 ms = 200 ms of CPU time per 100 ms period, checked by the kernel's CFS (Completely Fair Scheduler) every period. Suppose a request's fan-out (splitting one incoming request across several worker threads that run at the same time so it finishes faster) wakes 8 threads that are all fully busy with no waiting on I/O, and each needs 50 ms of CPU time to finish its share: 400 ms of CPU time in total, twice the pod's 200 ms-per-period quota. Running flat out, the 8 threads burn through the 200 ms quota in 200 / 8 = 25 ms of wall-clock time, and the pod is throttled (frozen: none of its threads may run at all) for the remaining 75 ms of that period, with 400 - 200 = 200 ms of work still outstanding. The next period refills the quota; the 8 threads, each with 25 ms of its 50 ms left, burn the fresh 200 ms in another 25 ms and finish, needing no second throttle. Total wall-clock time: 100 ms (period one) + 25 ms (period two) = 125 ms, against 50 ms if the pod had run unthrottled on 8 real cores: a 2.5x slowdown, all of it the one 75 ms throttle stall. So: set limits on memory always, but on CPU prefer accurate requests (which already give fair sharing) and reserve CPU limits for tenants you are deliberately capping, and watch throttling metrics wherever limits exist.
4. Language runtimes that ignore the container
Different languages size themselves differently, which is exactly why a mixed cluster gets noisy:
- JVM: set heap relative to the container (
-XX:MaxRAMPercentage), otherwise the heap plus off-heap memory can exceed the limit and get OOM-killed. - Go:
GOMAXPROCS(the number of OS threads Go's scheduler will run application code on simultaneously) defaulted, before Go 1.25, to the node's core count, so a pod limited to 2 CPUs on a 64-core node ran 64 scheduler threads and was throttled constantly. Newer Go versions read the cgroup limit; for older ones set it explicitly (or use theautomaxprocslibrary, which setsGOMAXPROCSto match the container's cgroup CPU limit instead of the node's full core count). - Node.js and Python: mostly single-threaded per process, so they scale by replicas; watch native thread pools and memory growth instead.
5. Dedicated node pools for chronic offenders
A team whose batch job saturates memory bandwidth or disk I/O (which Kubernetes does not fully isolate: CPU caches, memory bandwidth, and local disk I/O are still shared) moves to its own node pool with a taint (a marker on the node that repels every pod unless it carries a matching toleration, a marker on the pod saying it is allowed there) plus a node selector (a label on the pod requesting only nodes that carry a matching label), so ordinary workloads never land there by accident. This is the only complete fix for shared-hardware effects.
6. Autoscaling boundaries and admission control
Autoscaling can itself be the noisy neighbour: one service's HPA (Horizontal Pod Autoscaler) scales to 300 replicas and the cluster autoscaler fills every new node with it. Set maxReplicas per service, cap node counts per node pool, keep the team's ResourceQuota as the ceiling on total requests, and use PriorityClass (a ranking Kubernetes uses to decide which pods to evict, or preempt, first when a node is full) so revenue-critical services can preempt (evict to make room for) lower-priority ones when capacity runs short.
7. Network and disk
Egress bandwidth can be capped per pod with the CNI (Container Network Interface) bandwidth plugin (kubernetes.io/egress-bandwidth annotation), and ephemeral storage has its own requests and limits. Heavy disk I/O belongs on a dedicated pool or on network storage with provisioned throughput.
Detecting interference before customers notice
flowchart LR
N[Node signals: PSI, throttling, runqueue] --> A[Per-node anomaly]
P[Synthetic probe per node] --> A
A --> COR{Latency up on several services on same node?}
COR -->|yes| TOP[Rank co-located pods by resource usage]
TOP --> ACT[Alert team, cordon or move pod]
COR -->|no| APP[Probably an app issue]
| Signal | What it tells you |
|---|---|
container_cpu_cfs_throttled_periods_total / container_cpu_cfs_periods_total (cAdvisor, the node agent that collects per-container resource metrics) | Share of periods a container was throttled by its own limit |
PSI (pressure stall information, /proc/pressure/cpu, memory, io, also per cgroup) | Percentage of time tasks were stalled waiting for that resource; the most direct "someone is starving" signal |
| CPU run-queue latency (for example from eBPF tools, which run small safe programs inside the kernel to measure scheduling) | How long runnable threads wait for a core |
| Memory: working set vs limit, page-fault and reclaim rates, OOM kills | Approaching limits or node memory pressure |
| Disk and network: I/O wait, device utilization, retransmits, drops | Shared device saturation |
| Synthetic probe per node | A tiny fixed workload whose latency should be flat; if it rises, the node is contended regardless of which app notices |
The detection trick is correlation by node: if p99 latency (the response time slower than 99 out of 100 requests, the tail rather than the average) rises for three unrelated services, and all three have pods on the same two nodes, the cause is a neighbour, not their code. Alert on node-level PSI (for example CPU "some" pressure, PSI's reading for at least one task stalled waiting on that resource, as opposed to "full" pressure where every task is stalled, above 20% over 5 minutes, tuned to your baseline) and on synthetic-probe drift, which both fire before user-facing SLOs (service-level objectives, the latency or error targets you have committed to) burn (get consumed faster than expected: the early warning before you actually breach the target). Then rank the pods on that node by CPU, memory bandwidth, and I/O to name the offender.
Trade-offs and pitfalls
- Guaranteed QoS and exclusive cores everywhere wastes capacity; reserve them for the few latency-critical services.
- CPU limits everywhere create throttling latency that looks like a noisy neighbour but is self-inflicted.
- Dedicated pools per team remove interference but fragment capacity; use them for proven offenders, not by default.
- Averages hide it: interference shows up in p99 and in per-node breakdowns, not in cluster-wide means.
Design a tenant-aware backpressure and queueing system for a multi-tenant SaaS product with bursty workloads. Explain fair-share algorithms, per-tenant quotas, circuit-breakers per tenant, and how to avoid noisy-neighbor problems without over-provisioning.
Sample Answer
Direct answer
The core change is to stop putting all tenants' work in one first-in first-out (FIFO) queue. I would give each tenant its own bounded queue, have workers pull from those queues with a weighted fair-share scheduler (deficit round robin), cap each tenant's in-flight work with a quota, and push back on a tenant whose queue is full with a retryable rejection instead of letting its backlog grow. Per-tenant circuit breakers stop one tenant's failing dependency from tying up shared workers. Together these let one tenant's burst use idle capacity, while making it impossible for that burst to delay everyone else, so you do not need to provision for every tenant's peak at once.
Why a shared FIFO queue fails
With one queue, a tenant that drops 500 jobs at once puts every other tenant's next job behind all 500. Nobody did anything wrong; the queue discipline simply gives the earliest arrivals all the capacity. Adding workers only shortens the delay in proportion to the extra spend, which is the over-provisioning we want to avoid.
Backpressure is the general answer: when a system is full, it signals producers to slow down instead of accepting unbounded work. In a multi-tenant system, the signal must be per tenant, so that only the tenant causing the pressure is slowed.
Architecture
flowchart LR
C[Tenant clients] --> A[Admission: auth, tenant ID, quota check]
A -->|queue full| R[429 + Retry-After]
A --> Q1[Queue tenant A]
A --> Q2[Queue tenant B]
A --> Q3[Queue tenant C]
Q1 --> S[Fair-share scheduler]
Q2 --> S
Q3 --> S
S --> W[Shared worker pool]
W --> CB[Per-tenant circuit breakers]
CB --> D[Downstream dependencies]
1. Admission. Identify the tenant from its credentials (never from a client-supplied field), check its rate quota (for example a token bucket: a per-tenant allowance that refills at a fixed rate), and check its queue depth. If the queue is at its bound, reject with HTTP 429 and a Retry-After header. This is where backpressure becomes visible to the producer.
2. Per-tenant bounded queues. Physically these can be one table or stream partitioned by tenant, or a set of logical queues in the scheduler. The bound per tenant is set by tier (e.g. 200 queued jobs for a standard tenant, 2,000 for enterprise), which is what caps any one tenant's claim on memory and latency.
3. Fair-share scheduler. Deficit round robin (DRR) visits each non-empty tenant queue in turn and gives it a "quantum" of work credit per round (its weight); a tenant spends credit to dispatch jobs, and unspent credit carries over only while it has jobs waiting. With equal weights it is plain round robin; with weights 1:2:4 for free, standard and enterprise tiers, capacity divides in that ratio when everyone is busy. Crucially, it is work-conserving: if only one tenant has work, that tenant gets all the workers. That is how one tenant's burst uses idle capacity without taking capacity other tenants need. If job costs vary a lot, charge the quantum in estimated cost units (seconds of work) rather than job count.
4. Per-tenant concurrency quota. Independently of the scheduler, cap how many jobs a tenant can have running at once (e.g. 20% of workers for a standard tenant). This protects against a tenant whose jobs are individually slow, which fair ordering alone does not.
5. Per-tenant circuit breakers. A circuit breaker watches calls to a dependency and, once the failure rate crosses a threshold, fails further calls immediately for a cool-down period instead of letting them hang. Keyed per tenant (and per dependency), it handles the case where one tenant's jobs call something tenant-specific that is broken (its webhook endpoint, its connected database, its bad configuration). Without it, that tenant's jobs sit on shared workers waiting on timeouts. With it, the tenant's jobs fail fast (and are retried later or dead-lettered, i.e. moved to a DLQ, a dead-letter queue for jobs that keep failing) and the workers go back to everyone else.
6. Load shedding under global overload. If the whole system is saturated, shed in order: free-tier background work first, then retries, then new standard work; never an enterprise tenant's in-flight job.
Worked example (executed)
A pool completes 10 jobs per tick. Tenant a submits a burst of 500 jobs at tick 0; tenants b, c, d, e each submit 2 jobs per tick, steadily. Compare one FIFO queue with per-tenant queues (bound 200) served round robin.
from collections import deque
CAPACITY = 10 # jobs the worker pool finishes per tick
TICKS = 100
SMALL = ["b", "c", "d", "e"] # steady tenants: 2 jobs per tick each
BURST = 500 # tenant "a" dumps 500 jobs at tick 0
QUEUE_CAP = 200 # per-tenant queue bound (used by fair mode only)
def arrivals(t):
jobs = [("a", t)] * BURST if t == 0 else []
for s in SMALL:
jobs += [(s, t)] * 2
return jobs
def pct(values, p):
v = sorted(values)
return v[min(len(v) - 1, int(p / 100 * len(v)))]
def run_fifo():
q, waits, rejected = deque(), {}, 0
for t in range(TICKS):
q.extend(arrivals(t))
for _ in range(min(CAPACITY, len(q))):
tenant, arrived = q.popleft()
waits.setdefault(tenant, []).append(t - arrived)
return waits, rejected, len(q)
def run_fair():
queues = {x: deque() for x in ["a"] + SMALL}
waits, rejected = {}, 0
for t in range(TICKS):
for tenant, arrived in arrivals(t):
if len(queues[tenant]) >= QUEUE_CAP:
rejected += 1 # backpressure: caller gets 429 + Retry-After
else:
queues[tenant].append((tenant, arrived))
served = 0
while served < CAPACITY and any(queues.values()):
for tenant in queues: # round-robin, quantum = 1 job per visit
if served < CAPACITY and queues[tenant]:
_, arrived = queues[tenant].popleft()
waits.setdefault(tenant, []).append(t - arrived)
served += 1
return waits, rejected, sum(len(q) for q in queues.values())
for name, fn in [("FIFO", run_fifo), ("fair-share", run_fair)]:
waits, rejected, backlog = fn()
small = [w for s in SMALL for w in waits.get(s, [])]
print(f"{name:10s} small-tenant p99 wait={pct(small, 99)} ticks, "
f"small jobs done={len(small)}, burst jobs done={len(waits.get('a', []))}, "
f"rejected={rejected}, backlog={backlog}")
Output (Python 3):
FIFO small-tenant p99 wait=50 ticks, small jobs done=500, burst jobs done=500, rejected=0, backlog=300
fair-share small-tenant p99 wait=0 ticks, small jobs done=800, burst jobs done=200, rejected=300, backlog=0
Reading it: under FIFO the four well-behaved tenants waited up to 50 ticks at the 99th percentile (p99) and had 300 jobs still stuck at the end, because the burst went first. Under fair share their p99 wait was 0 ticks and all 800 of their jobs finished. Tenant a still got the 2 spare slots per tick (10 capacity minus 8 from the steady tenants), finishing 200 jobs, and its other 300 were rejected at admission and must be retried later. Same worker count, no extra capacity: the only thing that changed is who absorbs the burst. Tenant a does.
Avoiding over-provisioning
Provision for the sum of guaranteed shares plus a modest burst buffer, not the sum of peaks. Because DRR is work-conserving, idle capacity is still lent to whoever is bursting, so utilisation stays high. Scale out the worker pool on the metric that means "tenants inside their quota are waiting" (queue age of in-quota work), not on total queue length, which a single bursting tenant can inflate on its own and which would make you buy capacity for that tenant's backlog.
Trade-offs and pitfalls
- Rejecting work moves the problem to the client. Clients must honour
Retry-Afterwith backoff and jitter (random spread), or the rejections come straight back as a retry storm. Offer an asynchronous submit-and-poll path for tenants who legitimately send large batches. - Thousands of tenants and a naive round robin scans many empty queues; keep an "active tenants" list containing only non-empty queues.
- Fairness by job count is unfair when job sizes differ. Charge cost units, or one tenant with 10-minute jobs still dominates.
- Circuit breakers keyed globally punish every tenant for one tenant's broken webhook; key them by tenant and dependency.
- Priority tiers without a floor starve the free tier. Give every tier a minimum weight so low-tier work always progresses.
Architect a multi-tenant microservices platform serving 10,000 tenants worldwide that requires per-tenant isolation (compute and data), per-tenant cross-region failover, and cost transparency to tenants. Discuss tenant isolation models (logical vs physical), deployment strategies (shared cluster vs dedicated cluster), noise isolation, billing implications, and operational tooling needed.
Sample Answer
Direct answer
At 10,000 tenants worldwide I would build a cell-based architecture: the platform is stamped out as many independent, identical "cells" (each a Kubernetes cluster plus its own databases, hosting a few hundred tenants), placed in several regions. Small tenants share a cell with per-tenant namespaces, quotas and a per-tenant database; large tenants get a dedicated node pool (a set of machines reserved just for their workloads) or a dedicated cell. Every tenant has a home cell and a paired standby cell in another region, and a global tenant directory says which is active, so failing over one tenant means replicating its data and flipping one directory entry, not moving a whole region. Per-tenant metering runs from day one because cost transparency is a product feature here, not an internal report.
Requirements and the forces in tension
- Isolation of compute and data per tenant. Strong isolation pushes towards dedicated clusters; 10,000 dedicated clusters is operationally impossible.
- Per-tenant cross-region failover. A tenant (not just the whole platform) must be movable to another region, with a stated RPO (recovery point objective: how much recent data you may lose) and RTO (recovery time objective: how long until service is back).
- Cost transparency to tenants. Each tenant sees what it consumed and what it is billed, which means every CPU-second, byte and request needs a tenant label.
- Worldwide. Latency and data-residency rules decide the home region.
Isolation model: logical vs physical, and where each applies
| Tier | Share of tenants | Compute | Data | Why |
|---|---|---|---|---|
| Small | ~98% | Namespace per tenant in a shared cell, with CPU and memory quotas | Own logical database (or schema) on the cell's shared database servers, own encryption key | Cheap, fast onboarding, a real per-tenant boundary for data |
| Medium | ~1.8% | Dedicated node pool inside a shared cell (their pods run only on their nodes) | Own database server | Removes CPU and cache contention without a whole cluster to run |
| Large | ~0.2% | Dedicated cell | Dedicated database cluster | Contractual isolation, very large load |
A Kubernetes namespace is a named partition of one cluster; with quotas, network policies and per-tenant service accounts (a non-human identity a tenant's own workloads authenticate as, scoped so one tenant's pods cannot use another tenant's permissions) it isolates well against accidents but still shares the node's kernel, so untrusted tenant code would need a stronger sandbox. Physical isolation (dedicated nodes or clusters) is what you sell to tenants who need it.
Deployment strategy: shared cluster vs dedicated cluster
I would not run one giant shared cluster: a bad upgrade, an overloaded API server (the Kubernetes control-plane component every cluster-management request goes through) or a misconfigured network policy would hit all 10,000 tenants. Cells cap the blast radius (how many tenants one failure reaches).
Sizing, with the assumptions stated: 9,800 small and 180 medium tenants share cells, 20 large tenants get their own. At 250 tenants per shared cell:
⌈2509,800+180⌉=⌈39.92⌉=40 shared cellsSpread over 4 regions, that is 10 shared cells per region, so one bad cell touches at most 250 tenants (2.5% of the base).
flowchart TB
U[Tenant request] --> E[Global edge + tenant directory]
E -->|active| A[Home cell, region A]
E -.->|on failover| B[Standby cell, region B]
A -->|per-tenant async replication| B
A --> M[Metering pipeline]
B --> M
M --> BL[Per-tenant usage + bill]
Per-tenant cross-region failover
- Placement: the directory stores each tenant's home cell, standby cell and state (
ACTIVE,FAILING_OVER,ACTIVE_ON_STANDBY). - Data: each tenant's database replicates asynchronously to its standby cell. Asynchronous means the RPO is the replication lag (typically seconds); synchronous cross-region replication would add a cross-region round trip (tens of milliseconds between nearby regions, well over 100 ms between continents) to every write, which I would offer only as a premium tier.
- Compute: the standby cell keeps the tenant's deployment defined but scaled low; failover scales it up.
- Procedure: fence the old primary so it cannot accept a write once failover has started. Two ways to do that: revoke its write credentials at the database, or bump the tenant's epoch, a version number stored in the tenant directory that increments on every failover. Every write is required to carry the current epoch, and the datastore or proxy checks that number against the directory's latest value before accepting the write; once the epoch is bumped, any write still in flight from the old primary carries the now-stale epoch and is rejected, even though the old primary itself never learns the failover happened. Then promote the replica (make the standby's database copy the new primary and start accepting writes), flip the directory entry, and let DNS or the edge route pick it up. Because it is per tenant, the same mechanism doubles as a region-move tool for residency changes.
Capacity arithmetic. If a whole region fails and its tenants spread over the other 3 regions, each remaining region takes on one third of a region's load, reaching 4/3 of its normal load. For that to fit, normal utilisation must be at most 3/4 = 75% of capacity per region.
Replication bandwidth. If the average tenant writes 2 GB a day: 10,000 x 2 GB = 20 TB a day, and 20 x 10^12 bytes / 86,400 s = about 231 MB/s, or about 1.85 Gbit/s of cross-region traffic in total, which is also a line item on the bill (inter-region transfer is charged per GB on the major clouds).
Noise isolation
- Admission: per-tenant rate limits and concurrency limits at the edge, sized by plan.
- Compute: namespace resource quotas (caps on total CPU and memory a namespace may request) and default limits for every pod, so no tenant can schedule unbounded work.
- Data: per-tenant connection caps and statement timeouts; heavy tenants moved to their own database server when their share of a server crosses a threshold.
- Shared queues: per-tenant partitions or weighted fair queuing (giving each tenant a guaranteed proportional share of a shared queue's throughput, instead of pure first-come-first-served) so a tenant's backlog does not delay others.
Billing implications and cost transparency
Tenants see showback (a usage and cost breakdown) on a dashboard, and billing on the invoice. To make these match:
- Label every workload with
tenant_idat deploy time; the metering pipeline rejects unlabelled resources. - Measure per tenant: CPU and memory reserved versus used per pod, storage bytes per database, requests and egress bytes at the gateway, replication bytes.
- Charge dedicated resources directly; split shared ones (control plane, cell overhead, idle capacity) by a published rule, for example proportional to reserved CPU.
- Reconcile monthly: the sum of all tenant charges plus the platform's own share must equal the cloud bill.
Two billing consequences of this design: the standby is not free (a warm standby, kept running at reduced scale so it can take over quickly, as described above, still has storage and replication traffic, and that belongs on the tenant's bill, which is why cross-region failover is usually a paid tier), and dedicated tiers carry a visible minimum charge because their idle capacity cannot be shared.
Operational tooling needed
- Tenant directory and control plane (the small set of services that make decisions about tenants, placement, routing, failover, as opposed to the data plane, which actually carries each tenant's traffic) for onboarding, placement, tier changes and failover.
- Cell factory: infrastructure-as-code to stamp identical cells, plus a staged rollout that upgrades one cell at a time.
- Per-tenant observability: dashboards and alerts filtered by tenant, with care for label cardinality (the number of distinct time series; 10,000 tenant labels on every metric is expensive, so keep per-tenant metrics coarse).
- Failover runbooks and game days (scheduled practice failure drills, on purpose, not waiting for a real incident): fail over a test tenant every week, measure its RTO and RPO, and publish them.
- Tenant migration tooling: move a tenant between cells without downtime (copy, catch up, fence, flip).
Trade-offs and pitfalls
- Cells multiply fixed cost. 40 control planes (one management layer per cell), 40 sets of monitoring. The alternative (one huge cluster) is cheaper and fails for everyone at once. I would accept the overhead.
- Global dependencies defeat cells. If the tenant directory or identity service lives in one region, a regional outage still takes everyone down. Replicate the directory to every region and let cells run on a cached copy.
- Failover without fencing causes split brain (two copies both accepting writes and diverging). Always fence first.
- What would change the design: if tenants were mostly large enterprises, I would make "dedicated cell" the default and focus on cell automation instead of packing density.
Architect a multi-tenant low-latency inference platform on Kubernetes that supports many models and tenants with isolation, cost-efficiency, autoscaling, and versioned deployments. Discuss GPU/CPU packing, admission control, routing, and tenant billing considerations.
Sample Answer
Direct answer
On Kubernetes I would give each tenant a namespace (a named, walled-off slice of the cluster: its own quotas, permissions and objects) with quotas enforced at admission, run models on shared GPU node pools packed tightly (a node pool is a group of machines of the same hardware type that the scheduler places pods onto) (whole GPUs for large models, MIG partitions for small ones), put an inference layer such as KServe (a Kubernetes add-on that turns a trained model into a running, autoscaled web service, one InferenceService object per model) behind a Gateway API ingress (Kubernetes's traffic-routing layer: the front door that decides which backend service a request reaches) that routes by tenant and model version, and autoscale on in-flight requests or queue depth rather than CPU. Tenants who need hard isolation get tainted, dedicated node pools: a taint is a marker on a node that repels every pod except the ones with a matching toleration, so only that tenant's pods land there. Billing comes from GPU and CPU usage attributed to tenant namespaces and pods, plus per-request metering.
Building blocks and what each does
Start with the first three rows: tenant boundary, quotas and placement, plus standard autoscaling, already give you a working design. Kueue, custom admission policies, canary rollouts and cost tooling are refinements layered on once that base runs, roughly in the order listed.
| Concern | Kubernetes mechanism |
|---|---|
| Tenant boundary | Namespace per tenant; RBAC (role-based access control) scoped to it; NetworkPolicy (a rule object controlling which pods, the smallest deployable unit, one or more containers running together, may send traffic to which) default-deny so tenant pods cannot talk to each other |
| Quotas | ResourceQuota (caps total CPU, memory and nvidia.com/gpu requested in the namespace) and LimitRange (default and maximum per container) |
| GPU fair-share across tenants | Kueue (a Kubernetes job-queueing controller): a ClusterQueue per tenant or tier with nominal GPU quota, grouped into a cohort so idle quota can be borrowed and later reclaimed. Worked example: tenant A's queue has a nominal 4 GPUs and is only using 2; tenant B's queue has a nominal 4 and needs 6. Kueue lets B borrow A's 2 idle GPUs, so B runs at 6 immediately. When A later submits work needing its full 4, Kueue reclaims the borrowed 2 by preempting (stopping) B's lowest-priority borrowed jobs, so A gets back to its nominal share |
| Policy at admission | ValidatingAdmissionPolicy, OPA Gatekeeper (Open Policy Agent's Kubernetes admission controller) or Kyverno rejecting pods with no resource requests, wrong node selectors, or privileged settings |
| Placement | Node pools per hardware type; taints and tolerations for dedicated pools; PriorityClass (a label that ranks workloads so the scheduler preempts, evicts, lower-ranked ones first when a node is full) so production inference preempts batch jobs |
| Serving and versions | KServe InferenceService per model; canary rollout via canaryTrafficPercent |
| Routing | Gateway API (or an Envoy-based gateway) mapping tenant and model to the right service |
| Autoscaling | KServe/Knative autoscaling on concurrency, or HPA (Horizontal Pod Autoscaler) / KEDA (Kubernetes Event-driven Autoscaling, which scales on external signals such as queue length) on queue-depth metrics; Cluster Autoscaler or Karpenter adds nodes |
GPU and CPU packing
GPUs are the expensive unit, and Kubernetes by default schedules a GPU as an indivisible integer. Three ways to share one:
- Whole GPU per replica: simplest, strongest isolation, wasteful for small models.
- MIG (Multi-Instance GPU): on an A100 80GB you can create up to 7
1g.10gbslices, each with its own memory and compute. The NVIDIA device plugin exposes them as separate schedulable resources. Hardware isolation, but fixed slice sizes. - Time-slicing: the device plugin advertises one GPU as several; pods take turns. Cheap, but no memory isolation, so reserve it for dev or internal tenants.
Worked example. 12 small tenant models, each needing about 8 GB of GPU memory at modest traffic. Whole GPUs: 12 A100s. With 1g.10gb MIG slices (7 per GPU): 12 / 7 = 1.7, so 2 GPUs, a 6x reduction, and each model keeps its own memory boundary.
For CPU pods (pre/post-processing, small models), use the scheduler's NodeResourcesFit plugin with the MostAllocated scoring strategy so pods pack onto fewer nodes and the autoscaler can remove empty ones. Pair it with accurate requests; packing on inflated requests just packs air.
Admission control
Two meanings, both needed:
- Kubernetes admission (at deploy time): a tenant cannot create a pod that exceeds its namespace quota, lacks requests/limits, or targets another tenant's dedicated pool. Kueue holds GPU workloads until quota is available instead of letting them sit Pending (Kubernetes's status for a pod that is accepted but cannot yet be placed on any node) and fragment nodes.
- Request admission (at run time): the model server or gateway bounds in-flight requests per tenant. When a tenant's queue exceeds its share, return HTTP 429 quickly rather than letting latency climb for everyone.
Routing and versioned deployments
flowchart LR
R[Request with tenant token] --> G[Gateway: auth, rate limit]
G --> H{Route by tenant + model}
H -->|stable 90%| V1[InferenceService v1]
H -->|canary 10%| V2[InferenceService v2]
H -->|dedicated tenant| D[Tenant pool on tainted nodes]
Each model version is a separate revision. Setting canaryTrafficPercent: 10 on the KServe InferenceService sends 10% of that model's traffic to the new revision; promote or roll back by changing the number. Because each tenant's model is its own service, one tenant's rollout never touches another's pods.
Autoscaling
CPU utilization is a poor signal for GPU inference (the CPU is often idle while the GPU is saturated). Scale on concurrency per replica or queue depth. Scale-to-zero saves money for rarely used tenant models but brings a cold start: pulling a multi-GB image and loading weights can take tens of seconds to minutes, so keep a minimum of one replica for any model with a latency SLO (service-level objective: the latency target that model's callers were promised), and cache weights on the node.
Tenant billing
- Dedicated pools: bill the node cost to the tenant.
- Shared pools: attribute usage per pod from the resource metrics (CPU and memory from cAdvisor; GPU utilization and memory from NVIDIA's DCGM exporter, DCGM being the Data Center GPU Manager), aggregated by namespace. Tools such as OpenCost (an open-source cost-allocation tool) turn those raw metrics into a namespace-level cost breakdown. A MIG slice is billed as its fraction of the GPU (a
1g.10gbslice is one seventh). - Add per-request metering (tokens or GPU-milliseconds) when several tenants share one model replica, because pod-level metrics cannot split a shared process.
Trade-offs and pitfalls
- Namespaces are a soft boundary. They share the kernel (the core operating-system program every process on the node goes through to touch CPU, memory, disk and network) and the control plane (the cluster's own management services, separate from the node running your pods), plus the node itself. A tenant that can run arbitrary code (custom model containers) needs a sandboxed runtime (for example gVisor or Kata Containers) or dedicated nodes.
- GPU fragmentation: mixed MIG layouts and whole-GPU pods on the same nodes leave stranded capacity. Keep separate node pools per layout.
- Quota without borrowing leaves GPUs idle while another tenant queues; Kueue cohorts fix that, with preemption to reclaim.
- Autoscaling on CPU under-scales GPU services; use request-level metrics.
As an Engineering Manager designing SLIs/SLOs for a multi-tenant SaaS product, propose SLIs, SLOs, and isolation strategies to mitigate noisy-tenant impacts. Cover resource quotas, per-tenant rate limits, fairness algorithms, billing/SLA tiers, detection of noisy neighbors, and remediation/automation approaches.
Sample Answer
Direct answer
The mistake to avoid is measuring reliability only across the whole fleet: a fleet-wide 99.95% can hide one customer who has been completely down all month. I would define every SLI (service-level indicator: the measured quantity, such as the fraction of requests that succeed) per tenant, set SLOs (service-level objectives: the target for that SLI) per tier, and add one SLO that is about the fleet's fairness itself: "at least 99% of tenants meet their own SLO each month". Isolation mechanisms (quotas, per-tenant rate limits, fair scheduling) are what make those per-tenant SLOs achievable; detection and automated remediation are what keep them achieved; the contractual SLA (service-level agreement: the promise with financial credits attached) sits below the internal SLO so the team gets warning before money is owed.
SLIs: what to measure, and per whom
| SLI | Definition (per tenant, per window) | Why |
|---|---|---|
| Availability | good requests / valid requests; "good" = non-5xx and answered within a hard ceiling (e.g. 5 s) | The basic "can I use it" measure; excludes 4xx the tenant caused, and excludes 429s that are within the tenant's own contractual quota, but counts 429s issued while the tenant was below quota (those are our fault) |
| Latency | fraction of requests faster than a threshold, per endpoint class (e.g. under 300 ms for interactive reads) | Proportion-under-threshold turns latency into a budget; averages hide tails |
| Freshness / throughput for async work | fraction of jobs started within N seconds of submission | Queued work is where noisy neighbours hurt first |
| Isolation (fleet level) | fraction of active tenants meeting their own availability and latency SLOs | Directly measures whether noisy neighbours are winning |
| Worst-tenant view | the lowest per-tenant availability this week, with its tenant ID | Operational: shows who is hurting now |
The tenant ID has to be attached at the edge (from the authenticated credential) and carried into every metric and log. Metrics labelled by tenant are high-cardinality (many distinct label values, which is expensive in time-series databases), so compute per-tenant SLIs from request logs or a stream processor, and keep only tier-level labels in the real-time metrics system.
SLOs by tier, and the SLA beneath them
| Tier | Availability SLO | Latency SLO (interactive) | SLA to customer | Isolation level |
|---|---|---|---|---|
| Free | 99.5% | 95% under 500 ms | None | Shared pool, lowest scheduling weight |
| Standard | 99.9% | 99% under 300 ms | 99.5% with service credits | Shared pool, guaranteed quota |
| Enterprise | 99.95% | 99% under 200 ms | 99.9% with service credits | Dedicated cell or reserved capacity for the largest tenants |
The SLA is deliberately looser than the SLO, so that an SLO breach is an internal alarm with room to act before credits are due. Billing tiers and isolation tiers must match: a tenant paying for 99.95% cannot sit in the same unprotected pool as the free tier, or the promise is not backed by anything.
Isolation strategies that make per-tenant SLOs possible
- Resource quotas: caps per tenant on concurrent requests, queued jobs, storage and compute (e.g. in Kubernetes, a
ResourceQuotaper tenant namespace; in the application, a concurrency limit per tenant). - Per-tenant rate limits: a token bucket (an allowance that refills at a fixed rate and permits short bursts) keyed by tenant at the API gateway, sized by tier.
- Fairness algorithms: weighted fair queuing (giving each tenant's queue a share of capacity in proportion to its weight, in every round) or deficit round robin (a scheduler that visits each tenant's queue in turn and lets it send an amount proportional to its weight before moving on) across per-tenant queues, so capacity divides by tier weight when busy but idle capacity is still lent out.
- Placement: shard (a partition holding a subset of tenants' data or traffic, typically one database or node) or cell (an independent copy of the stack serving a subset of tenants) assignment that keeps very large tenants off the cells of small ones, so the blast radius (how many tenants one problem can reach) stays small.
Worked example: why fleet-wide SLOs hide the problem
Suppose 1,000,000,000 requests a month across all tenants. One tenant sends 0.05% of that traffic, 500,000 requests, and every single one fails for the month.
failedfleet availability=109×0.0005=500,000=1−500,000/109=99.95%The fleet SLO of 99.9% is met with room to spare, while that customer had 0% availability. The per-tenant SLI flags it within the first hour.
Per-tenant error budgets. An error budget is the amount of unreliability an SLO still allows: the gap between 100% and the SLO target, spent as outage minutes or failed requests. A 99.9% SLO over 30 days allows 0.1% of the window as bad: 30 × 24 × 60 × 0.001 = 43.2 minutes of full outage, or equivalently, for a tenant sending 2,000,000 requests a month, 2,000 failed requests.
Small tenants. A tenant sending 500 requests a month breaches 99.9% with a single failure (1/500 = 0.2% bad). Two fixes: evaluate small tenants over a longer window or pooled by tier, and require a minimum request count before a per-tenant SLO can page anyone. Otherwise the on-call engineer is paged by noise.
Detecting noisy neighbours
- Share of resource: each tenant's share of CPU seconds, database time, queue slots or bytes scanned, computed per minute. Flag a tenant whose share exceeds its tier entitlement while other tenants' latency SLIs are degrading. Both conditions together, because a tenant using idle capacity harms no one.
- Correlation: when a shard's p99 (99th-percentile) latency rises, rank tenants on that shard by the increase in their resource use over the same minutes.
- Burn-rate alerts per tier: alert when the error budget is being spent fast. The sustainable rate is the pace that would use up exactly the whole budget spread evenly across the 30-day window, that is, 1/720 of the budget per hour, where 720 is simply the number of hours in 30 days (30 x 24 = 720). A rate of 14.4 times that (for example 14.4 times the sustainable rate over one hour, which spends 14.4 / 720 = 2% of a 30-day budget in that hour) is fast enough that, sustained, it would use up the whole month's budget in about 720 / 14.4 = 50 hours (roughly two days), which is worth paging on within the hour rather than waiting for a slow drift to show up in a weekly review.
Remediation and automation
Automate the reversible, low-risk actions and keep humans for the rest:
- Automatic: throttle the offending tenant to its tier entitlement (tighten its rate limit or concurrency cap), lower its scheduling weight, and move its heavy jobs to a batch pool. These are reversible and already contractually allowed.
- Automatic with a notification: move the tenant to a different shard or a quarantine cell when throttling is not enough.
- Human decision: permanently upgrading a tenant's tier or dedicated capacity (a commercial conversation), and anything that could lose data.
Every automated action writes an event linked to the tenant, so the account team sees "your workload was throttled at 14:05 because..." rather than an unexplained slowdown.
Trade-offs and pitfalls
- Too many SLOs dilute attention. Keep two per tier (availability, latency) plus the fleet isolation SLO; track the rest as indicators, not objectives.
- Excluding all 429s from availability lets the platform hide its own capacity problems behind rate limiting. Only exclude throttling the tenant brought on itself by exceeding its quota.
- Per-tenant metrics in the real-time metrics store can explode cost; derive them from logs.
- SLA equal to SLO means every internal miss costs money with no warning margin.
- Automation without a kill switch: a bad detector that throttles your largest customer is its own incident. Rate-limit the remediation itself and make it easy to disable.
Unlock Full Question Bank
Get access to all 17 Multi-Tenancy and Isolation interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.