Software Engineering

Multi-tenant data isolation strategies for SaaS

Comparing schema-per-tenant, row-level security and silo models.

Back to Engineering Journal

Engineering guide · General design considerations, not a client case study or a claim of certified compliance.

Choose isolation according to risk

Shared tables can simplify operations and reduce overhead, but every access path must enforce tenant scope. Separate schemas provide a naming boundary while sharing the database’s resources. Separate databases offer stronger operational separation at the cost of more migrations, backups and connection management. The right choice depends on contractual isolation requirements, data volumes, recovery needs and the team’s ability to operate the chosen model.

Derive tenant scope from a trusted session

A tenant identifier supplied in a request is a lookup value, not proof of access. Resolve the caller’s membership and permissions on the server before selecting a tenant. In a shared-table model, row-level policies can provide an additional boundary, but privileged service credentials may bypass them. Background jobs, exports and administration tools must apply their own explicit scope checks. Never assume that protecting the main dashboard protects every data path.

Follow data beyond the database

Tenant isolation also covers cache keys, object-storage paths, search indexes and queued messages. Include tenant scope in cache keys and check access before issuing download links. Ensure that retries preserve the original tenant context. Test with two tenants that have similarly named records so accidental cross-tenant lookups are observable. Include reporting, full-text search and support workflows in those tests, not just standard create and update operations.

Plan migrations and recovery

A fleet of databases needs version tracking, staged migrations and failure recovery. A shared database needs a tested strategy for tenant-level export or restore; restoring the entire database may affect unrelated customers. Enforce resource limits to reduce noisy-neighbour effects and monitor consumption by tenant. Document how a tenant is provisioned, suspended and deleted, including retained backups and contractual retention rules. These lifecycle operations are part of the isolation design.