Tutorials SaaS Entrepreneurship & Scaling for Software Architects
The Architecture of a SaaS: Multitenancy and isolation strategies
On this page
Designing for Multiple Customers
In SaaS, you build one system that serves thousands of customers. This is called Multitenancy. The challenge is ensuring that Customer A never sees Customer B's data.
1. Multitenancy Models
- Database-per-Tenant: Highest isolation. Every customer has their own physical DB. expensive but extremely secure and easy to back up individually.
- Schema-per-Tenant: One DB server, multiple schemas. Good balance of cost and isolation.
- Shared Database (Row-Level): Every table has a `TenantId` column. The most cost-effective but requires rigorous coding (Global Query Filters in EF Core) to prevent data leaks.
2. The "Noisy Neighbor" Problem
If Customer A runs a giant report that consumes all the CPU, Customer B's experience will suffer. To scale, you must implement **Resource Quotas** and **Rate Limiting** at the tenant level to ensure one customer's heavy usage doesn't crash the party for everyone else.
4. Career Mastery
Q: "Which and why?"
Architect Answer: "Start with **Shared Database (Row-Level)** for your MVP. It is the easiest to manage and the cheapest to run. Use **Entity Framework Core Global Query Filters** to automatically inject `WHERE TenantId = X` into every query. Only move to 'Database-per-Tenant' when an Enterprise customer with a $100k contract demands it for compliance reasons."