[{"data":1,"prerenderedAt":366},["ShallowReactive",2],{"insight-\u002Finsights\u002Fmulti-tenant-saas-architecture":3,"insight-service-\u002Finsights\u002Fmulti-tenant-saas-architecture":363},{"id":4,"title":5,"author":6,"body":7,"category":332,"date":333,"description":334,"extension":335,"faq":336,"meta":351,"navigation":352,"path":353,"seo":354,"service":314,"sitemap":355,"stem":356,"tags":357,"updated":361,"__hash__":362},"insights\u002Finsights\u002Fmulti-tenant-saas-architecture.md","Multi-Tenant SaaS Architecture: How to Choose a Tenancy Model","Cinnamon Digital",{"type":8,"value":9,"toc":317},"minimark",[10,18,23,28,36,52,56,59,71,75,78,90,94,200,204,207,218,222,225,265,268,272,304,308],[11,12,13,17],"p",{},[14,15,16],"strong",{},"Most SaaS products should start with a shared database where every tenant-owned row carries a tenant ID, enforced by row-level security."," Separate schemas or databases per tenant offer stronger isolation, but at a higher operational cost that early-stage products rarely need. The right choice depends on your customers' isolation requirements, scale, and the size of your team.",[19,20,22],"h2",{"id":21},"the-three-main-models","The three main models",[24,25,27],"h3",{"id":26},"_1-shared-database-shared-schema","1. Shared database, shared schema",[11,29,30,31,35],{},"All tenants share the same tables. Every tenant-owned table has a ",[32,33,34],"code",{},"tenant_id"," column, and every query filters by it.",[37,38,39,46],"ul",{},[40,41,42,45],"li",{},[14,43,44],{},"Pros:"," Simplest to build and operate, lowest cost, one migration updates everyone, and easy cross-tenant reporting for your own analytics.",[40,47,48,51],{},[14,49,50],{},"Cons:"," A missed filter can expose data between tenants, one heavy tenant can slow others, and some enterprise or regulated customers may require stronger separation.",[24,53,55],{"id":54},"_2-shared-database-schema-per-tenant","2. Shared database, schema per tenant",[11,57,58],{},"Each tenant gets its own schema with identical tables inside one database.",[37,60,61,66],{},[40,62,63,65],{},[14,64,44],{}," Stronger logical separation, easier per-tenant backup and restore, and simpler data deletion.",[40,67,68,70],{},[14,69,50],{}," Migrations must run across every schema, the number of database objects grows with each tenant, and connection pooling and tooling become more complex.",[24,72,74],{"id":73},"_3-database-per-tenant","3. Database per tenant",[11,76,77],{},"Each tenant has a dedicated database, sometimes on dedicated infrastructure.",[37,79,80,85],{},[40,81,82,84],{},[14,83,44],{}," Strongest isolation, per-tenant performance tuning, data residency options, and a straightforward story for security reviews.",[40,86,87,89],{},[14,88,50],{}," Highest cost and operational overhead, migrations and monitoring across many databases, and harder cross-tenant reporting.",[19,91,93],{"id":92},"comparison","Comparison",[95,96,97,115],"table",{},[98,99,100],"thead",{},[101,102,103,106,109,112],"tr",{},[104,105],"th",{},[104,107,108],{},"Shared schema",[104,110,111],{},"Schema per tenant",[104,113,114],{},"Database per tenant",[116,117,118,133,147,161,173,186],"tbody",{},[101,119,120,124,127,130],{},[121,122,123],"td",{},"Isolation",[121,125,126],{},"Logical (policies)",[121,128,129],{},"Logical (schemas)",[121,131,132],{},"Physical",[101,134,135,138,141,144],{},[121,136,137],{},"Cost per tenant",[121,139,140],{},"Lowest",[121,142,143],{},"Low to moderate",[121,145,146],{},"Highest",[101,148,149,152,155,158],{},[121,150,151],{},"Migrations",[121,153,154],{},"One run",[121,156,157],{},"One per schema",[121,159,160],{},"One per database",[101,162,163,166,168,171],{},[121,164,165],{},"Noisy-neighbor risk",[121,167,146],{},[121,169,170],{},"Moderate",[121,172,140],{},[101,174,175,178,181,183],{},[121,176,177],{},"Per-tenant restore",[121,179,180],{},"Hard",[121,182,170],{},[121,184,185],{},"Easy",[101,187,188,191,194,197],{},[121,189,190],{},"Best for",[121,192,193],{},"Most B2B and B2C SaaS",[121,195,196],{},"Mid-size tenant counts with stronger separation needs",[121,198,199],{},"Enterprise, regulated, or data-residency customers",[19,201,203],{"id":202},"the-hybrid-model","The hybrid model",[11,205,206],{},"Many mature SaaS platforms combine models: most customers live in a shared database, while large or regulated customers get a dedicated database on a premium plan. To make this possible later, design from day one so that:",[37,208,209,212,215],{},[40,210,211],{},"Every tenant-owned table has a tenant identifier.",[40,213,214],{},"All data access goes through one layer that knows the current tenant.",[40,216,217],{},"Tenant routing, meaning which database a tenant lives in, is a lookup rather than hard-coded.",[19,219,221],{"id":220},"making-the-shared-model-safe-in-postgresql","Making the shared model safe in PostgreSQL",[11,223,224],{},"If you choose a shared schema, defend against cross-tenant leaks at several layers:",[226,227,228,237,245,253,259],"ol",{},[40,229,230,233,234,236],{},[14,231,232],{},"Row-level security policies"," that compare each row's ",[32,235,34],{}," to the current tenant set for the session or derived from the authenticated user.",[40,238,239,244],{},[14,240,241,242],{},"Indexes that start with ",[32,243,34],{}," on large tables, so per-tenant queries stay fast.",[40,246,247,252],{},[14,248,249,250],{},"Foreign keys that include ",[32,251,34],{}," where practical, so records cannot reference another tenant's data.",[40,254,255,258],{},[14,256,257],{},"Automated tests"," that log in as one tenant and confirm they cannot read or change another tenant's records.",[40,260,261,264],{},[14,262,263],{},"Per-tenant rate limits and quotas"," to reduce noisy-neighbor problems.",[11,266,267],{},"Platforms such as Supabase build on PostgreSQL row-level security, which makes this pattern a natural fit.",[19,269,271],{"id":270},"other-tenancy-decisions","Other tenancy decisions",[37,273,274,280,286,292,298],{},[40,275,276,279],{},[14,277,278],{},"Identity:"," Can one user belong to several tenants? Most B2B products need this, so model memberships separately from users.",[40,281,282,285],{},[14,283,284],{},"Configuration:"," Store per-tenant settings, feature flags, and plan limits in their own tables.",[40,287,288,291],{},[14,289,290],{},"File storage:"," Prefix object storage paths with the tenant ID and apply the same access rules as the database.",[40,293,294,297],{},[14,295,296],{},"Background jobs:"," Pass the tenant ID explicitly to every job and log it for debugging.",[40,299,300,303],{},[14,301,302],{},"Data deletion:"," Plan how to export and fully delete a tenant's data when a customer leaves.",[19,305,307],{"id":306},"where-to-start","Where to start",[11,309,310,311,316],{},"Write down your likely customer mix for the next two years, including whether any will require dedicated infrastructure or data residency. If not, start shared, enforce isolation in the database, and keep the door open for dedicated tenants later. If you want help designing or reviewing your architecture, our ",[312,313,315],"a",{"href":314},"\u002Fservices\u002Fcustom-saas-backends","custom SaaS backends"," team builds multi-tenant platforms on PostgreSQL, Supabase, and Node.js.",{"title":318,"searchDepth":319,"depth":319,"links":320},"",2,[321,327,328,329,330,331],{"id":21,"depth":319,"text":22,"children":322},[323,325,326],{"id":26,"depth":324,"text":27},3,{"id":54,"depth":324,"text":55},{"id":73,"depth":324,"text":74},{"id":92,"depth":319,"text":93},{"id":202,"depth":319,"text":203},{"id":220,"depth":319,"text":221},{"id":270,"depth":319,"text":271},{"id":306,"depth":319,"text":307},"SaaS & Engineering","2026-11-10","Compare the three main multi-tenancy models for SaaS, a shared database, schema per tenant, and database per tenant, with trade-offs for isolation, cost, scaling, and compliance, plus practical tips for PostgreSQL.","md",{"title":337,"items":338},"Multi-tenancy questions",[339,342,345,348],{"label":340,"content":341},"What is multi-tenancy in SaaS?","Multi-tenancy means one running application serves many customers, called tenants, while keeping each tenant's data separate. It lets a SaaS company run and update a single system instead of a separate copy for every customer.",{"label":343,"content":344},"Which multi-tenant model should a new SaaS product use?","Most new SaaS products start with a shared database and a tenant ID column on every tenant-owned table, enforced with row-level security. It is the simplest and cheapest to run, and you can move specific large or regulated customers to dedicated databases later.",{"label":346,"content":347},"What is row-level security?","Row-level security (RLS) is a database feature, available in PostgreSQL, that filters which rows a query can see or change based on policies. In multi-tenant apps it ensures queries only return rows for the current tenant, even if application code forgets to filter.",{"label":349,"content":350},"Can we change tenancy models later?","Yes, but it is a significant migration. Designing with a tenant ID on every tenant-owned record from the start, and routing all data access through a single layer, keeps your options open.",{},true,"\u002Finsights\u002Fmulti-tenant-saas-architecture",{"title":5,"description":334},{"loc":353,"lastmod":333},"insights\u002Fmulti-tenant-saas-architecture",[358,359,360],"SaaS architecture","Multi-tenancy","PostgreSQL",null,"EKFnSwhQXm763ycwMneSC0Ki7ExT3hQKxKL_Hiqg39g",{"path":314,"title":364,"description":365},"Custom SaaS Backends","Backend architecture and implementation for SaaS products.",1794506505266]