Skip to main content

You are building document Q&A as a product for 500 customer companies. Each uploads up to 1 million documents. Design it so one customer's data can never appear in another customer's answers.

System design · Pro 3

Short answer

Clarify isolation needs, tenant sizes and compliance. Carry a tenant ID from authentication through every layer: storage, index, cache, logs and prompts. Choose isolation per tier: shared index with a mandatory tenant filter for small tenants, separate indexes or keys for large or regulated ones. Add per-tenant rate limits, cost tracking, deletion, and cross-tenant leak tests.

Deeper answer

Requirements: how strong isolation must be by contract, whether some tenants need their own region or encryption key, the size spread between tenants, and whether customer data may be used for training (normally no). The key metric is zero cross-tenant leaks, then answer quality and cost per tenant.

Design: the tenant ID comes from the verified login token, never from the request body. Every store is scoped by it: object storage prefix, database rows with row-level security, vector index namespace, cache keys, logs and traces. The retrieval layer adds the tenant filter itself, so a developer cannot forget it. Small tenants share one index with namespaces, which is cheap. Large or regulated tenants get a separate index and key, which costs more to run but limits the damage of a bug.

What breaks first: one large tenant slows the others, so add per-tenant rate limits, queues for ingestion and quotas. Also shared caches and any fine-tuning on mixed data. Test with planted canary documents in one tenant and automated queries from another, in CI and in production. Support full deletion when a tenant leaves.

What a strong answer covers

Answer it out loud in the mock interview about 3 min

Follow-ups to expect

Common mistakes

Learn it

Security and privacy

Practice System design questions

More on this topic

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.