Course contentsShow
← Software Engineering
Lesson 1529 of 1,93344. Cloud Architecture PatternsFree lesson

Multi-Tenancy Models

Comparing tenant isolation approaches: shared database/shared schema, shared database/separate schema, and separate databases.

Multi-Tenancy Models

What you'll learn: How different multi-tenancy architectural patterns trade off isolation, cost, and operational complexity.

The Core Trade-off

When you build a multi-tenant application (one application serving many customers or "tenants"), you must decide how much infrastructure each tenant shares. The three most common models form a spectrum from maximum sharing to complete isolation:

Three Isolation Approaches

1. Shared Database / Shared Schema

All tenants store data in the same database tables. Each row includes a tenant_id column to distinguish ownership. Think of this like a massive shared apartment building where everyone uses the same hallways, elevators, and utilities—just different apartment numbers.

  • Pros: Lowest cost, easiest to scale, simplest operations
  • Cons: Highest "noisy neighbor" risk, complex queries with tenant filters everywhere, data leak risk

2. Shared Database / Separate Schema

Each tenant gets its own schema (namespace) within a shared database instance. Like separate wings in a building with shared infrastructure but private internal spaces.

  • Pros: Better isolation, per-tenant customization possible, backup/restore per tenant
  • Cons: Schema count limits, more complex migrations, moderate cost increase

3. Separate Databases

Each tenant gets a dedicated database instance. Like standalone houses—complete isolation.

  • Pros: Maximum isolation, independent scaling, regulatory compliance easier
  • Cons: Highest cost, complex operations (managing thousands of databases), harder to implement cross-tenant features

Choosing Your Model

The right choice depends on your security requirements, tenant size distribution, and operational capabilities. Many systems use hybrid models: small tenants share schemas while enterprise customers get dedicated databases.

Key Takeaway: Multi-tenancy models represent a spectrum from shared infrastructure (low cost, high complexity) to isolated infrastructure (high cost, simpler per-tenant logic), with no universally correct answer—only context-dependent trade-offs.