Designing Multi-Tenancy Architecture

1. Designing Database-per-Tenant Architecture

AspectDetail
IsolationStrongest; per-tenant DB
Backup / restorePer tenant easy
CostHigh at scale
Cross-tenant queriesHard
Best forFew large enterprise tenants

2. Designing Shared Database with Tenant Isolation

AspectDetail
Tenant_id columnOn every row
RLSPostgres row-level security; defense-in-depth
App-enforced filterAlways WHERE tenant_id
CostMost efficient
RiskCross-tenant leak bug catastrophic

3. Designing Schema-per-Tenant Architecture

AspectDetail
Per-tenant schemaSame DB
Migration challengeApply across N schemas
ConnectionSet search_path per request
Best forMid-tier isolation

4. Designing Tenant Data Isolation

LayerDetail
NetworkPer-tenant VPC for premium
ComputePool / silo / hybrid
DataEncryption with per-tenant DEK
LogicalTenant_id everywhere

5. Designing Tenant Customization

MechanismDetail
Config per tenantBranding, features
Custom fieldsJSONB / EAV / per-tenant table
Workflow customizationTemplates / DSL
Plugin modelExtension points

6. Designing Tenant Provisioning

StepDetail
Self-serve signupAuto-create tenant
Resource allocationSchema, queue, namespace
Default configPlan-based
IdempotentSafe retry
WorkflowStep-based with rollback

7. Designing Cross-Tenant Operations

NeedDetail
Aggregate analyticsPipe to separate analytics store
Admin / supportPrivileged audited access
Cross-tenant searchAvoid; use per-tenant indexes
Background jobsAlways include tenant_id

8. Designing Tenant Rate Limiting

AspectDetail
Per-tenant quotaPrevent noisy neighbor
Plan-based limitsFree / Pro / Enterprise
Burst allowanceToken bucket per tenant
HeadersExpose limit / remaining

9. Designing Tenant Billing and Metering

ElementDetail
Usage eventsCaptured per tenant
AggregationHourly/daily rollup
Metering pipelineIdempotent, audit-ready
Billing engineStripe Billing, Metronome, Orb
InvoiceItemized usage

10. Designing Tenant Migration

ScenarioDetail
Pool → siloFor tier upgrade
Region migrationCompliance / latency
ProcessSnapshot → copy → cutover → verify
Read-only windowOr dual-write

11. Designing Tenant Resource Quotas

ResourceDetail
StoragePer-tenant cap
API callsPer minute / day
Concurrent jobsWorker share
Users / seatsPlan-based
Soft / hard limitsWarn vs reject

12. Designing Tenant Onboarding

StepDetail
Signup flowEmail + verify
Provision tenantAsync if heavy
Sample dataDemo workspace
IntegrationsOAuth connect to data sources
Activation trackingFunnel analytics