Multi-Tenancy and Isolation Questions
Serving many tenants from shared infrastructure: tenancy models (silo, pool, bridge), data isolation, noisy-neighbor mitigation, per-tenant limits, and security boundaries between tenants. Covers the cost, isolation, and blast-radius tradeoffs of shared versus dedicated resources. The architecture layer specific to SaaS and platform products.
Design an approach to isolate noisy neighbors in a shared cluster hosting multiple microservices (polyglot workloads). Include resource controls (CPU/memory/shares), QoS classes, cgroup/namespace strategies, scheduling decisions, and monitoring/alerting to detect unseen interference.
Sample Answer
Requirements:
- Isolate noisy neighbors while supporting polyglot microservices
- Minimize impact on latency-sensitive services, allow best-effort for batch
- Detect unseen interference and automate remediation
High-level approach:
- Admission & resource controls
- Enforce CPU/memory requests and limits via Kubernetes LimitRange and ResourceQuota.
- Use cgroup v2 features (CFS shares, cpu.max, memory.high/memory.max) at kubelet/containerd level.
- Enable CPUManager static policy and reserved CPUs for latency-critical pods (cpuset pinning) to avoid CPU steal.
- Use memory.high to trigger proactive throttling and memory.max for hard limits.
Example LimitRange snippet:
apiVersion: v1
kind: LimitRange
spec:
limits:
- type: Container
defaultRequest:
cpu: "100m"
memory: "128Mi"
default:
cpu: "500m"
memory: "512Mi"
- QoS and scheduling
- Classify pods into Guaranteed (requests==limits), Burstable, BestEffort. Run latency-sensitive services as Guaranteed with dedicated CPUs.
- Use node pools (taints/tolerations) and labels: dedicated nodes for Guaranteed, mixed nodes for Burstable/batch.
- Use PriorityClasses to protect critical workloads.
- Scheduler decisions: affinity/anti-affinity to spread noise, PodTopologySpread, and scheduler profiles to favor low-latency placement. Use Descheduler to evict and migrate noisy pods when needed.
- cgroup/namespace strategies
- Leverage cgroup v2 unified hierarchy for precise control; enforce cpu.max and memory.high per container.
- Use network namespaces + traffic shaping (tc) to limit noisy network consumers.
- Use RuntimeClass to select runtimes with different isolation (gVisor for untrusted tenants).
- Detection & monitoring
- Metrics:
- Node: CPU steal, load, frequency, softirq, page faults, NUMA imbalance
- Container: cgroup cpu.stat (nr_periods, throttled_time), memory.oom_kill, memory.pressure, blkio latency, network queues
- Tools: Prometheus + node_exporter/cadvisor + eBPF (bcc/tracee) to detect syscall saturation, cache-misses, and tail latency. Collect perf counters for cache/memory hot spots.
- Alerts:
- High container throttling rate (throttled_time/periods > threshold)
- CPU steal > X% on nodes hosting Guaranteed pods
- Memory.pressure or high page-faults
- Tail latency SLI breach (p95/p99)
- Automated remediation
- Graceful throttling: automatically lower BestEffort/Burstable limits via Vertical Pod Autoscaler or scale down HPA for noisy tenants.
- Evict/migrate offending pods with Descheduler + cordon/drain policy to isolate.
- If persistent, move noisy workloads to separate node pool or apply cpuset pinning.
- Provide feedback loop: annotate offending deployments and notify owners via alerting/incident playbook.
Trade-offs:
- Strict pinning increases fragmentation and reduces bin-packing efficiency.
- gVisor increases latency; use only for untrusted workloads.
Why this works:
- Combines proactive placement (dedicated CPUs/nodes), reactive controls (cgroups, throttling), and deep telemetry (eBPF, cgroup stats) to both prevent and detect noisy neighbor effects while allowing automated, owner-notified remediation.
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
Requirements recap:
- 10,000 tenants worldwide
- Per-tenant isolation: compute + data
- Per-tenant cross-region failover
- Cost transparency (showback/chargeback)
Recommendation (hybrid isolation): mix logical and physical isolation based on tenant size and SLA.
- Logical isolation (namespaces, network policies, RBAC, separate DB schema): good for small/standard tenants (majority). Lower cost, high density.
- Physical isolation (dedicated node pools, dedicated clusters or VMs, separate DB instances): required for high-risk, high-traffic, or compliance tenants. Ensures cryptographic, noisy-neighbor, and regulatory separation.
Deployment strategies:
- Fleet model: multiple Kubernetes clusters per region. Use cluster templates and automation (GitOps) to spin dedicated clusters for large tenants and multi-tenant clusters for many small tenants.
- Tenant grouping: bucket tenants by SLA/cost tier. E.g., Tier A (1% tenants): dedicated clusters + dedicated DB instances. Tier B (9%): dedicated node pools within shared clusters. Tier C (90%): logical isolation in shared clusters.
- Cross-region failover: per-tenant DNS + global LB (Anycast or cloud global load balancer). For data:
- Active-passive: primary in region A, async replicate to region B (cheaper, eventual consistency).
- Active-active for critical tenants: multi-master DB with conflict resolution or sharded write routing. Offer as premium.
- Orchestration: control plane that knows tenant placement and automates failover (health checks, promoted replicas, DNS failover with low TTL).
Noise isolation techniques:
- K8s QoS + resourceRequests/limits; enforce PodPriority and Preemption for critical tenants.
- Node taints/tolerations and dedicated node pools to pin heavy tenants to nodes.
- cgroups and kernel-level limits for CPU/memory/io.
- Network QoS and per-tenant egress shaping; API rate limiting and circuit breakers.
- Storage IO isolation: provisioned IOPS volumes or separate storage clusters for noisy tenants.
- Admission controllers to block runaway deployments and limit concurrency.
Data isolation & security:
- Small tenants: separate schemas per tenant with row-level security and encryption-at-rest + tenant keys.
- Large/regulated tenants: separate DB instances/clusters, VPC/Network isolation, HSM-managed keys, audited access.
- Backups: per-tenant backup/restore automation and per-tenant retention policies.
Billing & cost transparency:
- Metering: instrument CPU (cpu-seconds), memory-hours, storage bytes & IOPS, egress GB, DB connections, snapshot storage, and managed services usage.
- Labels/tags on all resources (tenant-id) and export metrics via Prometheus node-exporter, cAdvisor, cloud billing APIs.
- Aggregation pipeline: scrape → normalize → cost model (unit pricing) → per-tenant ledger in data warehouse.
- Offer showback dashboards + chargeback APIs; produce monthly invoices and realtime estimated spend.
- Support cost controls: budgets, alerts, autoscaling limits, and optional cost caps (soft-stop or suspend for non-payment).
Operational tooling & SRE processes:
- Provisioning API & GitOps templates to create tenant environments (namespace/cluster/DB) with policy-as-code.
- Placement engine: decides region & isolation level based on SLA, latency, compliance.
- Observability: per-tenant metrics, distributed tracing (tenant-tagged spans), logs (tenant-id) with multi-tenant retention controls and RBAC.
- SLOs & error budgets per tenant tier; automated remediation and runbooks per failure mode.
- Chaos engineering and canary deploys per cluster and per-tenant group to validate isolation and failover.
- Capacity planning: demand forecasting by tenant cohort; autoscaling node pools and reserve capacity for failover.
- Security: automated compliance checks, vulnerability scanning, per-tenant audit logs.
- Billing ops: reconciliation workflows, anomaly detection on spend, dispute handling.
- Incidents: tenant-scoped incidents, centralized incident commander, per-tenant communication templates.
Trade-offs and cost control:
- Logical isolation maximizes utilization but increases risk of noisy neighbors and complex billing attribution. Physical isolation increases cost but simplifies guarantees and security.
- Offer tiered pricing: base price covers X resources; overages metered. Let customers choose isolation level.
- Implement quotas and graceful degradation rather than full isolation for mid-tier tenants to balance cost.
Example flows:
- Onboard tenant (small): create namespace, RBAC, schema, service-account, apply policies, enable metrics + billing labels. Default active in region closest to tenant.
- Failover (medium): control plane detects region outage → promote replica, update DNS entry (low TTL) and database endpoint, run data catch-up. Notify tenant and SRE.
- Billing: Prometheus metrics aggregated hourly, mapped to prices, visible to tenant via dashboard; anomalies trigger billing review.
Why this design:
- Scales to 10k tenants by combining high-density multi-tenancy with selective physical isolation.
- Provides predictable SLAs and per-tenant failover options.
- Enables accurate cost attribution for transparency and chargeback.
- Operational automation and SRE practices keep operational overhead manageable.
Key implementation technologies:
- Kubernetes (multi-cluster), cluster API/GitOps, service mesh for traffic control, Prometheus/Thanos for metrics, Jaeger for tracing, ELK/Opensearch for logs, Terraform/Crossplane for infra, global LB (cloud provider), DB replication solutions (Aurora Global, CockroachDB for active-active), billing pipeline in data warehouse (BigQuery/Snowflake).
Metrics to monitor:
- Per-tenant resource usage, request latency, error rates, failover time, replication lag, billing deltas, noisy-neighbor incidents.
This hybrid, policy-driven approach balances cost, isolation, and reliability while giving tenants clear options and transparent billing.
That is every published Multi-Tenancy and Isolation question for Site Reliability Engineer (SRE) so far. Browse the other topics in this category, or practice this one interactively.