← Zettabyte Interview Insights
I knew the three models (separate database per tenant, shared database with separate schemas, shared database with a tenant_id column everywhere) but I fumbled the trade-off framing.
Start by defining multi-tenancy and the three main isolation models: shared database with shared schema, shared database with separate schemas, and separate databases. Then discuss the trade-offs in terms of cost, scalability, security, and operational complexity, and conclude with how to choose based on business needs.
Pro tip: Emphasize that the choice often depends on regulatory requirements and tenant size; a hybrid approach (e.g., separate databases for enterprise tenants, shared for SMBs) is common in practice.
Briefly explain what multi-tenancy is and why isolation matters for security, performance, and compliance.
Outline the three primary models: shared database shared schema, shared database separate schemas, and separate databases. Mention variations like separate tables per tenant.
Compare the models across dimensions: cost, scalability, isolation/security, operational complexity, and performance.
Explain how factors like tenant size, regulatory requirements, and budget influence the choice, and mention hybrid approaches.
Summarize key considerations and suggest that the decision should align with business goals and technical constraints.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.
Walk through the full request lifecycle, starting at the edge where tenant identity is first established (e.g., via subdomain, JWT claim, or API key), then explain how it is carried through each layer using a consistent mechanism like a request-scoped context or header. Emphasize that the tenant ID must be immutable and validated at every boundary, and finally show how it is enforced at the data layer via row-level security or tenant-scoped queries.
Pro tip: Mention the importance of propagating tenant identity even for asynchronous and background jobs, and highlight that you never trust client-supplied tenant IDs without verifying them against the authenticated principal.
Explain how the tenant is identified at the entry point: via subdomain, path prefix, JWT claim, or API key. Ensure it is extracted and validated before any business logic runs.
Describe how the tenant ID is attached to the request context (e.g., HTTP headers, gRPC metadata) and passed to downstream services, ensuring it cannot be spoofed or overridden.
Show how the tenant ID is stored in a request-scoped context (e.g., ThreadLocal, AsyncLocalStorage) so it is accessible throughout the call stack without explicit parameter passing.
Explain how the tenant ID is used to scope database queries, either via row-level security policies, tenant-specific schemas, or mandatory WHERE clauses, ensuring data isolation.
Discuss how tenant identity is preserved in asynchronous tasks, message queues, and scheduled jobs, often by embedding it in the message payload or job metadata.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.
Two questions kind of merged into one here.
Start by acknowledging that multi-tenancy requires a balance between isolation and efficiency. Then, outline strategies for performance isolation (e.g., resource quotas, rate limiting, noisy neighbor detection) and for managing tenant-specific configurations (e.g., metadata-driven customization, feature flags, separate schemas). Emphasize trade-offs and monitoring.
Pro tip: Mention that you would implement tenant-aware observability to detect and alert on noisy neighbors early, and that you would use progressive rollouts for tenant-specific customizations to avoid breaking others.
Ask about the scale, isolation level (shared vs. dedicated resources), and customization needs. This shows you consider context before designing.
Propose mechanisms like resource quotas, rate limiting, and workload prioritization. Mention techniques like bulkheads, circuit breakers, and autoscaling per tenant.
Use a metadata-driven approach with a configuration service, feature flags, and tenant-aware routing. Consider schema-per-tenant or shared schema with tenant ID for data isolation.
Set up tenant-aware monitoring, logging, and alerting. Use anomaly detection to identify noisy neighbors and automatically throttle or isolate them.
Discuss trade-offs (e.g., cost vs. isolation) and how you would evolve the design based on feedback and metrics.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.
Honestly the part I'd prep harder for next time.
Start by clarifying the multi-tenant architecture (shared DB vs. separate schemas) and the constraints around backups and migrations. Then explain a version-aware strategy: decouple schema versions from application code, use expand-contract migrations, and ensure backups are tenant-consistent and restorable per version. Emphasize automation, testing, and rollback plans.
Pro tip: Always design migrations to be backward-compatible for at least one version, and use feature flags to control access to new schema features. This avoids downtime and allows tenants to upgrade on their own schedule.
Ask about the isolation level (shared DB, shared schema, separate schemas, or separate DBs) and any SLAs for backup/restore and migration downtime. This determines the appropriate tooling and approach.
Ensure backups capture both data and schema version metadata. For shared databases, use logical backups per tenant or point-in-time recovery with tenant filtering. For separate schemas/DBs, back up each tenant independently and tag with schema version.
Use a phased migration pattern: first expand the schema (add new columns/tables) without breaking old code, then migrate data, then contract (remove old structures) only after all tenants have upgraded. This supports tenants on different versions.
Use a migration tool that tracks schema versions per tenant and can apply migrations incrementally. Schedule migrations during low-traffic windows and provide rollback scripts. For large tenants, consider online schema change tools.
Test migrations on a staging environment with representative tenant data and versions. Monitor performance and errors during and after migration. Have a rollback plan and communicate with tenants about expected changes.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.