Designing SaaS architecture means making four decisions before you write infrastructure code: how tenants share compute and data, where identity and entitlements live, how requests flow from edge to database, and how you isolate noisy or regulated customers. Everything else—serverless versus containers, one database versus many—follows from those choices. The order matters because each layer constrains the next, and reversing them is the most common reason teams rebuild their platform at the worst possible moment. What follows is a workable sequence you can apply at small scale and grow into, with the trade-offs and failure modes spelled out at each step.
Start With the Constraints That Actually Shape the Design
Most architecture advice starts with technology. Start with the four constraints that will override your technology preferences.
Tenancy model. Decide how customers (tenants) share resources. In a pool model, all tenants share the same application instances and often the same database, with a tenant identifier on every row. It's the cheapest to operate and the hardest to isolate. In a silo model, each tenant gets dedicated infrastructure—its own database or its own deployment—which simplifies isolation and data residency but multiplies operational cost. Bridge models mix the two: shared application tier, dedicated database for enterprise customers, for example.
Compliance and data residency. A customer contract or regulation may require that data never leaves a region, or that a specific tenant's data be physically separated. This is a constraint, not a feature: it can force a silo for one customer even if your whole product is pooled. Collect these requirements from sales and legal early, because retrofitting residency into a pooled system is expensive.
Scale shape. Total data volume matters less than per-tenant volume and query distribution. A system with 10,000 small tenants and one giant tenant needs different partitioning than 50 medium ones. Ask what your largest customer will look like in three years, not today.
Team size and operational budget. A five-person team cannot operate per-tenant clusters for 2,000 customers without heavy automation. Honest capacity planning here prevents choosing an architecture you can't run.
Write these four constraints down in a one-page architecture decision record before evaluating any product. It becomes the tiebreaker later.
Design the Tenant and Identity Model First
Identity is the spine of a SaaS system. Get it wrong and every downstream service inherits the confusion.
Separate users from tenants. A user is a person with credentials; a tenant is a billing and isolation boundary. Model them as distinct entities with a membership table linking them, because real businesses have users who belong to multiple tenants (an accountant serving several client organizations, a contractor working across companies), and staff who need cross-tenant access for support.
Model the relationship explicitly: User —< Membership >— Tenant, where membership carries roles and status. Don't encode tenant as a column on the user row; that quietly assumes one user, one tenant and blocks the multi-tenant case later.
Put the tenant in the token, not just the request. When a user authenticates, issue a token or session that carries the active tenant identifier and the user's roles within that tenant. Downstream services then derive tenant context from the verified token rather than trusting a header or query parameter the client sends. A tenant ID accepted from client input is a cross-tenant data leak waiting to happen; a tenant ID inside a signed token is one an attacker can't forge.
Centralize entitlements. Plans, feature flags, seat counts, and rate limits belong in one entitlement service that answers "can this tenant do X, and how much of it?" Everything else—billing, the UI, API gateways—queries that service rather than scattering plan checks through the codebase. This pays off when a customer upgrades mid-cycle or a sales deal includes a custom limit.
Plan for lifecycle events. Sign-up, tenant provisioning, suspension for non-payment, export on churn, and deletion under a data-retention policy are all architecture concerns. Provisioning in a silo model might create a database; in a pooled model it inserts rows and seeds defaults. Deletion must be auditable and complete, since "we'll delete it manually" rarely survives contact with a privacy request.
Choose a Tenancy and Data Isolation Strategy
This is the decision people mean when they argue about SaaS architecture, and it deserves an equivalent-criteria comparison rather than a slogan.
| Criterion | Pooled (shared DB, tenant column) | Bridge (shared app, DB per tenant or per tier) | Silo (dedicated stack per tenant) |
|---|---|---|---|
| Operational cost per tenant | Lowest | Medium | Highest |
| Isolation blast radius | A query bug can expose all tenants | Contained to one database | Contained to one deployment |
| Data residency flexibility | Weak; needs regional sharding | Good; place tenant DBs by region | Strong |
| Noisy-neighbor risk | High unless throttled | Medium | Low |
| Schema migrations | One migration, high blast radius | Many databases, orchestrated | Per deployment, slowest |
| Typical fit | Self-serve SMB product | Mixed tiers, regional needs | Regulated or very large accounts |
The comparison is only fair if you hold the tenant population constant—a pooled design serving 20 enterprise tenants is a different problem from a pooled design serving 20,000 self-serve accounts.
A practical default for most startups is pooled data with a mandatory tenant column, enforced at the data-access layer, plus a documented path to promote large or regulated tenants into a bridge (their own database) without rewriting the application. That promotion path is the real design work: your connection routing must be able to resolve "tenant → database" from configuration, so a promoted tenant simply points elsewhere. If your code hard-codes a single database handle, promotion means a rewrite.
Enforce tenancy below the application, not just in it. The strongest pattern is row-level security in the database, where the session sets a tenant context and the database itself filters rows, so a forgotten WHERE tenant_id = ? in a hand-written query returns nothing rather than everything. Application-layer enforcement alone is one code review away from a leak. Where row-level security isn't available, wrap all data access in a repository layer that injects tenant scope automatically and forbid raw queries outside it.
Sketch the Request Path From Edge to Data
Map a single request end to end before you pick products. A typical SaaS request path looks like this:
1: DNS and edge. The request lands at a CDN or edge proxy that terminates TLS, serves static assets, and applies coarse rate limiting and WAF rules. 2: API gateway or ingress. It authenticates the token, resolves the tenant, applies per-tenant rate limits and quotas from the entitlement service, and routes to the right service or region. 3: Application service. A stateless service reads the verified tenant context, applies business logic, and calls the data layer. Statelessness here—no tenant-specific state held in memory across requests—is what lets you scale and deploy freely. 4: Data layer. The tenant resolves to a database connection (shared with tenant filter, or dedicated), and the query executes under tenant-scoped session context. 5: Async work. Anything slow—emails, exports, report generation, webhooks—goes to a queue with the tenant ID attached, so workers can apply per-tenant concurrency limits and so a failing job can be traced to a customer.
The design rule: tenant context flows through every hop, propagated from the verified token, never re-derived from untrusted input. Background workers, scheduled jobs, and admin tools need the same discipline; a nightly report job that loops over all tenants must set tenant context per iteration or it will read across boundaries if scoping lives only in request middleware.
Draw this path and mark where tenant context is established and where it is consumed. Gaps in that chain are where multi-tenant bugs live.
Pick a Data Architecture: Partitioning, Migrations, and Per-Tenant Data
Assuming pooled storage, the tenant column becomes a first-class indexing and partitioning concern. Every table that holds tenant data gets the tenant ID in its primary key or in a leading index position, and large tables are partitioned by tenant (or tenant hash) so that one big tenant's rows don't degrade queries for everyone else.
A worked sizing check. Suppose your largest tenant writes 40 million rows a year at roughly 400 bytes each—about 16 GB of raw row data per year before indexes, which commonly add 30–100% depending on index count. If you have three tenants of that size, pooled single-table storage is likely fine on a modern relational database with partition pruning; if you expect fifty, per-tenant partitioning, archival, or promotion to dedicated databases becomes a capacity question, not just an isolation one. Run the same arithmetic with your own row size and growth rate; the point is to make the largest tenant's trajectory explicit rather than discovering it during an incident.
Schema migrations are the hard part of shared storage. With pooled data, one migration touches every tenant at once, and a locking change on a large table can stall the whole product. Adopt expand-and-contract migrations: add new nullable columns and backfill in batches, deploy code that reads both shapes, then remove the old column in a later release. Test migrations against a production-sized copy, and set a stop condition—if a migration requires a table rewrite that would hold locks beyond your maintenance window, schedule it as a deliberate operation with a rollback plan rather than shipping it with a feature.
Per-tenant configuration and customization. Customers will ask for custom fields, workflows, and integrations. Store tenant-specific configuration as data (a settings table, JSON configuration validated against a schema) rather than as code branches, and keep custom logic in extension points—webhooks, rules engines, plugin interfaces—so one tenant's request doesn't fork your codebase. Feature flags scoped to tenant are the simplest version of this and belong in the entitlement service.
Backups and restores must be tenant-aware. A pooled database backup restores everyone; a "restore just this tenant" request from a customer who deleted data accidentally is common enough to plan for. Point-in-time recovery plus a tenant-scoped export/import path covers most cases. For silo tenants, per-tenant backup is trivial; that's a genuine advantage of isolation worth weighing in the comparison above.
Handle Async Work, Integrations, and Noisy Neighbors
Multi-tenancy fails most often under load, not under correctness. Design for fairness.
Per-tenant rate limits and quotas. Enforce limits at the gateway for synchronous calls and inside workers for async jobs. A queue that processes one tenant's 500,000-record export ahead of everyone else's password-reset emails is a noisy-neighbor incident. Use fair queuing—round-robin across tenants, or weighted by plan—and cap concurrent jobs per tenant.
Idempotency and retries. Webhooks to customer systems and calls to third-party APIs (payments, email) fail and retry. Attach idempotency keys to outbound operations and deduplicate on the receiving side where you control it, so a retried payment doesn't double-charge and a retried webhook doesn't create duplicate records in the customer's system.
Webhooks and integrations are part of your architecture. Outbound webhooks need signing, retry with backoff, and per-tenant delivery queues so one unreachable customer endpoint doesn't back up deliveries to everyone else. Inbound integrations need their own credentials vault per tenant, encrypted and access-controlled—never shared API keys across customers.
Dead-letter handling and observability by tenant. Every queue needs a dead-letter path, and every log line and metric should carry the tenant ID as a dimension. Without tenant-tagged metrics you can't answer "is this customer's latency bad or everyone's?"—and that question decides whether you're debugging a code path or a single tenant's data.
Bake In Security, Observability, and Cost Attribution
Three concerns that are cheap early and painful to retrofit.
Security. Authentication and authorization happen once, centrally: verify tokens at the edge, authorize tenant-scoped actions against roles from the membership model, and never trust client-supplied tenant identifiers. Encrypt data at rest and in transit, keep per-tenant secrets in a managed vault, and audit administrative cross-tenant access—support engineers viewing a customer's data should generate an audit record with who, when, and why. A tenant-isolation test in CI—two tenants, assert tenant A's token cannot read tenant B's row—catches regressions in the data-access layer before they ship.
Observability. Instrument request latency, error rate, and queue depth with tenant as a label, and build a per-tenant health view. Distributed tracing should propagate tenant context so a slow request can be followed across services. Set alerts on the aggregate, but keep the per-tenant breakdown for diagnosis; aggregate alerts tell you something is wrong, per-tenant data tells you who.
Cost attribution. In pooled infrastructure, the total bill doesn't tell you which customers are profitable. Tag compute, storage, and egress by tenant where the platform allows it—or estimate with per-tenant request counts, storage bytes, and job duration—and compare against plan revenue. This is how you discover that your pooled model is subsidizing three enormous tenants, which is exactly the signal to promote them into a dedicated tier. Attribution doesn't need to be exact to be useful; a defensible estimate with stated assumptions beats no number.
Plan Deployment, Migration, and Growth Paths
SaaS architecture is a trajectory, not a snapshot. Design the moves before you need them.
Deployment topology. Run stateless application services in multiple instances behind a load balancer, deploy with rolling or blue-green releases, and keep configuration (including connection routing) external so tenant promotion is a configuration change plus a data copy, not a code release. Feature flags decouple deploy from release, letting you roll out to one tenant first.
Regional expansion. If residency requirements appear, your connection-routing layer is the lever: add a region, place new tenants there, and migrate existing tenants with an export/import and a DNS or routing cutover. This works only if nothing assumes a single region—no global singletons, no hard-coded endpoints in background jobs.
The promotion path, spelled out. Moving a tenant from pooled to dedicated storage: export its rows, import into the new database with the same schema version, update routing configuration, verify row counts and checksums, run both in parallel briefly with reads pointed at the new store, then cut writes over and delete the pooled rows after a retention window. The success check is a reconciliation query comparing tenant record counts and key business totals between old and new stores; the stop condition is any mismatch that reconciliation can't explain—pause the cutover and investigate rather than proceeding.
Common failure modes to design against. Cross-tenant leaks from unscoped queries (mitigate with database-level row security and isolation tests); migration lockups on large shared tables (expand-and-contract, tested against production-sized data); noisy neighbors in shared queues (fair queuing, per-tenant concurrency); runaway storage costs from one tenant's data (partitioning, archival policies); and a single region becoming a compliance blocker (routing layer and region-agnostic code from day one).
Frequently Asked Questions
Should a small SaaS start pooled or siloed?
Start pooled with a tenant column and enforced database-level scoping, unless a specific contract or regulation requires isolation on day one. Pooled is cheaper to operate and faster to build; the promotion path to dedicated storage preserves the option. Starting siloed for a hypothetical future enterprise customer usually costs more than it saves.
How many databases should a multi-tenant system use?
There's no universal number—it depends on the largest tenants' volume, write patterns, and residency needs. The durable design is a routing layer that resolves tenant to database from configuration, so the count can change per tier without application rewrites.
Where should tenant context be enforced?
At the database whenever possible (row-level security tied to a session variable set from the verified token), with an application repository layer as a second guard. Request middleware alone isn't enough because background jobs, admin tools, and raw queries bypass it.
Does serverless fit SaaS architecture?
It can, particularly for spiky or per-tenant workloads, but watch connection limits to relational databases and cold-start latency against your per-tenant latency targets. The tenancy, identity, and routing decisions above are independent of the compute model.