All jobs / Backend developer / Architecture
Backend developer interview question · 5+ years
The interviewer asks: “How do you isolate tenants in a multi-tenant backend?” Strongest answer?
The strongest answer
Pick a model on purpose: row-level with a mandatory tenant predicate (and tests that fail closed), schema-per-tenant, or db-per-tenant for the ones that need it. I never “remember to add WHERE tenant_id” in each query by folklore.
Why it works
Exactly. Isolation is a security property. ORM global filters, row-level security, or separate stores — plus tests that try to read another tenant and must fail.
What a good answer covers
- Choose row / schema / database isolation.
- Enforce in the data layer, not the UI.
- Tests must fail closed on cross-tenant reads.
- Cache keys include tenant.
Answers that fall short
- Close, but not the strongest: One database, no tenant column — we filter in the UI.
UI filters are not isolation. That's a cross-tenant leak with extra steps. - Weak: A global cache of all tenants' data keyed only by id so lookups are fast.
IDs collide across tenants or leak by enumeration. Cache keys include tenant, or you don't cache. - Red flag: If a query forgets tenant_id, return the row anyway so support can debug.
Failing open is how one missing WHERE becomes a breach. Fail closed; support gets an admin tool with audit.
Who gets asked this
More Architecture questions
- The interviewer asks: “A bad deploy took all regions with it. What architecture would have contained it?”…
- A team proposes ports and adapters for a service that reads a queue, writes to one database, and will never…
- The interviewer asks: “Two years of events, consumers you don't own. How do you evolve the schema?” Strongest…
- The interviewer asks: “Auth, TLS, and WAF — in every service or at the gateway?” Strongest answer?
- An interviewer says: “Design a URL shortener.” What do you do first?
- What does a load balancer do, and what does it not do?
- What is the difference between scaling up and scaling out?
- Why do interviewers keep asking whether a service is stateless?