Most SaaS products start with one customer and a database. Then the second customer arrives, and someone asks: "Can we just add a CustomerId column?" Sometimes that works. Often it becomes the most expensive decision in the product's life.
We build multi-tenant platforms for healthcare, accounting and education, so here is what we would settle before writing any code.
1. Pick your isolation model on purpose
- Shared database, shared schema. Every table has a tenant ID. Cheapest to run and simplest to deploy.
- Shared database, separate schema per tenant. Stronger separation, moderate operational cost.
- Separate database per tenant. Strongest isolation and easiest per-customer backup or restore.
2. Make tenant filtering impossible to forget
If developers must remember to add WHERE tenant_id = ... to every query, someone eventually won't. Enforce it in one place: a global query filter in your data layer, or row-level security in the database.
3. Decide how tenants are identified
Subdomain per customer, a workspace code typed at login, or a claim inside the sign-in token.
4. Plan for the noisy neighbour
Think early about rate limits, background job queues and per-tenant resource limits.
5. Onboarding and offboarding are features
Creating a tenant, seeding default data, exporting a tenant's data and deleting it completely are all flows you will need early.