Multi-Tenant SaaS Architecture
Free template — view it below, open it in draw.io, or customize it with AI in seconds.
The prompt behind this diagram
A multi-tenant SaaS architecture: CloudFront, tenant-aware API gateway with JWT auth, shared application tier, PostgreSQL with row-level security per tenant, per-tenant S3 prefixes, tenant provisioning service, usage metering to a billing service (Stripe), admin plane.
Paste your own description (or Terraform / docker-compose / SQL schema) into draft1 and get a diagram like this for your exact system.
What this diagram shows
A multi-tenant SaaS system where multiple customers share a single application instance and database, with tenant data segregated through row-level security (RLS) policies rather than separate databases. The diagram shows how incoming requests flow through a tenant router that identifies which customer made the request, then to application servers that enforce data isolation via RLS rules in the database layer. It also depicts the supporting systems for provisioning new tenants, metering usage, and generating billing records based on consumption.
Key components
- Tenant Router — Intercepts incoming requests and identifies the tenant context from authentication headers or subdomains, then forwards to application servers with tenant ID attached.
- Application Servers — Process business logic while reading the tenant context from the request and passing it to the database layer for query filtering.
- Shared Database — Single PostgreSQL or equivalent instance storing data from all tenants with row-level security policies that filter results based on tenant ID.
- RLS Policies — Database rules that automatically restrict SELECT, UPDATE, and DELETE operations to rows belonging to the current tenant context.
- Usage Metering — Collects events such as API calls, storage used, or feature invocations from application servers and aggregates them per tenant.
- Provisioning Service — Creates new tenant records, sets up RLS roles, configures billing parameters, and initializes tenant-specific settings when customers sign up.
- Billing Engine — Consumes metering data and provisioning records to calculate charges, generate invoices, and prepare subscription or consumption-based billing records.
When to use it
Choose this architecture when you have multiple customers who accept shared infrastructure, need predictable scaling, and benefit from lower operational overhead compared to dedicated databases. Suitable for horizontal SaaS products like project management tools, CRM systems, or analytics platforms where tenants have similar feature sets and performance requirements. Not appropriate when tenants require strict data residency, custom schemas, or complete database isolation for regulatory reasons.
Common mistakes
- Failing to propagate tenant context consistently through all application layers, causing queries to return data from other tenants when RLS policies are bypassed or not set correctly.
- Overloading a single database with too many tenants without partitioning or sharding strategies, leading to noisy neighbour problems where high-usage tenants degrade performance for others.
- Implementing metering at application code level without atomic guarantees, resulting in duplicate or lost usage events that cause billing discrepancies between what customers consumed and what they were charged.
Adapting it to your system
Start by identifying your tenant identifier (customer ID, account UUID, or subdomain). Configure your authentication system to extract and attach this identifier to every request context. Implement RLS policies for each table by creating a tenant_id column, setting up a session variable at connection time, and writing policies that filter based on tenant_id matching that variable. Build your provisioning flow to create tenant records and initialize RLS roles and policies automatically. Add metering by instrumenting key actions (API endpoints, database writes, file uploads) to log usage events with tenant ID and a timestamp. Connect your billing system to aggregate metered data on a schedule and reconcile with provisioning records.
More templates
AWS VPC Multi-AZ Architecture
A production AWS VPC layout template: public/private/data subnets across two AZs with NAT, RDS multi-AZ and S3 endpoin
AWS EKS Cluster Architecture
An EKS reference template: control plane, node groups, ALB ingress, ECR, IAM roles for service accounts and storage.
AWS ECS Fargate Architecture
Serverless containers on AWS: ALB, Fargate services, SQS decoupling, RDS and Redis — a production ECS template.
Azure 3-Tier Web Architecture
The Azure counterpart of the classic 3-tier stack: Front Door, App Gateway, App Services, SQL and Redis in a VNet.
GCP Web Application Architecture
A serverless GCP stack template: Cloud Run, Cloud SQL, Memorystore, Pub/Sub and CDN-fronted load balancing.
Kafka Event Streaming Pipeline
End-to-end event streaming: CDC ingestion, a three-broker cluster, stream processing and analytical sinks.
Data Lakehouse Architecture
Bronze/silver/gold lakehouse template: ingestion, Delta Lake zones, Spark + dbt transforms and a BI serving layer.