# Design tenant isolation for my multi-tenant SaaS app

A recommended tenancy model with data isolation, noisy-neighbor controls, and tests that prove one customer can't see another's data.

- Topic: Software Development
- Framework: RTF
- Level: Standard
- Tags: Analyze, Fill-in Template
- Source: https://www.thinkwithprompt.com/prompts/design-tenant-isolation-for-my-multi-tenant-saas-app

## Prompt

```text
Help me design tenant isolation for my multi-tenant SaaS application.

**Stack:** [language, framework, database, cloud, auth provider]
**Current tenancy model:** [shared tables with tenant_id / schema per tenant / database per tenant / not decided]
**Number and size of tenants:** [e.g. "2,000 small tenants, 10 large enterprise"]
**Customer requirements:** [data residency, dedicated infrastructure, customer-managed keys, audit logs]
**Pain points:** [noisy neighbors, slow migrations, data leakage scare, cost]

Cover:
1. Tenancy model options (pool, bridge, silo) compared in a table: isolation strength, cost per tenant, operational complexity, migration effort, and fit for my tenants. Recommend one, or a tiered mix.
2. Data isolation: how tenant context is set and enforced (middleware, row-level security, scoped repositories), and how to stop queries that forget the tenant filter.
3. Isolation beyond the database: caches, search indexes, file storage, queues, background jobs, logs, and analytics exports.
4. Noisy-neighbor controls: rate limits, per-tenant quotas, workload separation.
5. Encryption and keys: per-tenant keys if needed.
6. Operations: schema migrations across tenants, backups and per-tenant restore, tenant deletion and export.
7. Testing: automated cross-tenant access tests, and what to include in a penetration test.

Give code-level examples in my stack for enforcing tenant context. Flag assumptions, and say where my data volumes would change the recommendation.
```

## What to fill in

- language, framework, database, cloud, auth provider
- e.g. "2,000 small tenants, 10 large enterprise"
- noisy neighbors, slow migrations, data leakage scare, cost

Free to copy and use. From ThinkWithPrompt (https://www.thinkwithprompt.com/), a library of 2,663 curated AI prompts.
