पाठ 31 / 32
Common Interview and Exam Questions
यह पाठ अभी हिंदी में अनुवादित नहीं है, इसलिए अंग्रेज़ी में दिखाया जा रहा है।
Practise concise, structured answers to the multi-tenancy questions that appear most often in system design interviews and exams.
लेखक: Rahul Agarwal · 15 साल से वेब डेवलपर
Design and isolation questions
"Design a multi-tenant SaaS for invoicing." Start with tenants, users and memberships; choose pool with tenant_id everywhere for small businesses, and a catalogue allowing silo placement for large ones; resolve tenant from subdomain plus token; describe RLS, scoped repositories and isolation tests; finish with sharding by tenant and noisy-neighbour limits. "Silo vs pool?" Compare isolation, cost per tenant, operational effort, blast radius and compliance, then say most products mix them per layer and per tier. "How do you stop data leaks between tenants?" Layered: edge resolution and membership checks, request context, scoped data access, database policies, tenant-prefixed caches and storage, tests that assert cross-tenant reads fail, and audit logs. "How do you shard?" Tenant as shard key, directory placement, single-shard queries, a separate warehouse for cross-tenant analytics, and an online move procedure for rebalancing.
Draw the request path
In a whiteboard interview, sketch one request end to end: host and token, tenant resolution, context, repository, RLS-protected table, cache key, log line. Pointing at where the tenant is checked at each hop is the clearest way to show you understand isolation.
Operations and business questions
"How do you migrate schemas for 2,000 tenant databases?" Expand-and-contract so old and new code both work, versioned migrations recorded per tenant in the catalogue, canary then waves, halt on failure, resume where it stopped. "One customer is slowing everyone down. What do you do?" Confirm with per-tenant metrics, apply rate limits or fair queuing immediately, investigate the workload, then consider quotas, a higher plan or moving them to a dedicated shard. "How do you delete a customer's data?" Suspension and grace period, export, deletion across every store from a data map, backups handled by retention or crypto-shredding, and a record of completion. "How do you bill on usage?" Durable usage events with idempotency keys, per-tenant aggregation per period, raw events kept for disputes, reconciliation against independent measures.
Like a viva
A system design interview is closer to a college viva than a written exam. The examiner cares less about one perfect answer and more about whether you can explain why you chose it and what you would do when they change a requirement.
त्वरित जाँच: An interviewer asks: "Your pooled product just signed a bank that requires dedicated storage. What changes?" Which answer is strongest?
- Fork the codebase for the bank
- Refuse, because pooled products cannot host such customers
- Move every tenant to dedicated databases
- Provision a dedicated database for that tenant, record it in the catalogue, and keep the same application code routing by lookup
Answer
Provision a dedicated database for that tenant, record it in the catalogue, and keep the same application code routing by lookup — Tier-based placement through a catalogue lets one tenant be siloed without a fork and without changing everyone else's placement.