176
multi-tenancy
Many customers share a system. A bug that forgets the tenant id is a data breach, not a glitch.
What is multi-tenancy?
Multi-tenancy means one deployment serves many tenants. Isolation is logical (a tenant column and policies) or physical (a database per tenant). Logical is cheaper and easier to get wrong. Noisy neighbors are a performance version of the same sharing.
Why does multi-tenancy matter when vibe coding?
Models add `account_id` to one table and query another without it. Say the isolation model and the test that crosses tenants.
How do you do multi-tenancy?
Pick: shared tables with a mandatory tenant key, or a database per tenant. Every query includes the key. One test always runs as tenant B against tenant A’s id. Pool limits stop one tenant from eating the database.
How do you ask a model for multi-tenancy?
Multi-tenant isolation for (data): every query is scoped by tenant id. Add a test that tenant B cannot read tenant A. Do not rely on the client to pass the filter alone. Bound one tenant’s resource use.
What goes wrong with multi-tenancy?
A tenant id on the row and a cache key that omits it. The second tenant gets the first tenant’s cached page.