A practical guide to multi-tenant SaaS: choosing a tenancy model, SSO and roles, billing with GST, taming noisy neighbours and avoiding mistakes that are costly to undo.
Most SaaS products do not fail because the first version was slow. They stall somewhere between the fiftieth and the thousandth customer, when an enterprise prospect asks for SSO and a data residency answer, finance asks why invoices do not reconcile with usage, and one large tenant's nightly import slows everyone else down. Each of those problems traces back to decisions made in the first few weeks: how tenants are isolated, where identity lives, how usage becomes money. This guide walks through those decisions in the order they tend to bite, with the trade-offs we would weigh before writing the first migration.
Make the tenant the unit of everything
The single most useful rule in multi-tenant design is that nothing exists outside a tenant. Every business table carries a tenant_id, every background job is enqueued with one, every log line and trace span is tagged with one, and every cache key is prefixed with one. If a piece of data genuinely belongs to no tenant, such as a plan catalogue or a feature-flag definition, it lives in a clearly separate global schema that application code reads but tenant requests never write.
Resolve the tenant exactly once, at the edge of the request, from the subdomain, a verified custom domain or a claim in the session token, and pass it through an explicit request context. Code that re-derives the tenant from a URL parameter halfway down the stack is where cross-tenant leaks come from. The same applies to background work: a job should carry its tenant in the payload and establish the context before it touches data, rather than inferring it from whichever record it loads first.
Model the organisation, not the user, as the tenant. People change jobs, consultants work for three clients and agencies manage dozens of accounts, so a user should reach tenants through a memberships table with a role per membership. Retrofitting that after launch means rewriting authentication, billing and every permission check at once, usually under pressure from the one large customer who needs it.
Choose a tenancy model you can live with for three years
There are three mainstream ways to isolate tenant data, and the right answer depends far more on your customers' contracts than on your traffic. Shared tables with a tenant_id column, enforced by PostgreSQL row-level security, are the default we recommend for most B2B products: one schema to migrate, one connection pool and cheap tenants. Schema-per-tenant gives each customer its own set of tables inside one database. Database-per-tenant gives each customer a physically separate database, sometimes in their chosen region.
Row-level security is only a safety net if it is configured properly. Set the tenant inside each transaction with set_config and the local flag, so a pooled connection never carries the previous request's tenant. Enable FORCE ROW LEVEL SECURITY, because table owners otherwise bypass policies, and make sure the application role is not a superuser and does not hold BYPASSRLS. Include tenant_id in every unique constraint and use composite foreign keys on tenant_id and id, so the database itself refuses a cross-tenant reference.
Moving between models later is a migration project, not a configuration change, so design for the move you expect. Globally unique identifiers such as UUIDv7 let you lift a tenant's rows into another database without key collisions, and a tenant directory that maps each tenant to its database lets you place one large customer on dedicated infrastructure while everyone else stays shared.
- Shared schema with row-level security suits thousands of small and mid-sized tenants, keeps migrations to a single run and gives the lowest cost per tenant.
- Schema-per-tenant offers cleaner per-customer backup and restore, but migrations run once per schema and catalogue bloat becomes noticeable at a few thousand schemas.
- Database-per-tenant is the right answer for regulated customers who need contractual isolation, their own encryption keys or data in a specific region, and it is the most expensive to operate.
- A hybrid, with a shared pool for most tenants and dedicated databases for a handful of large ones, is where most successful products end up, so build the tenant directory early.

Identity, SSO and roles that survive enterprise deals
Your first enterprise prospect will ask for single sign-on, and they will mean SAML 2.0 or OpenID Connect with their own identity provider, configured per tenant. Use a mature identity service or library rather than writing SAML parsing yourself; signature validation bugs in hand-rolled SAML are a well-documented source of account takeovers. What you do need to own is the mapping: which email domains a tenant has verified, whether SSO is optional or enforced, and what happens to existing password users when a tenant switches SSO on.
Provisioning follows SSO within months. SCIM 2.0 lets the customer's directory create, update and deactivate users automatically, and the deactivation part is what their security team cares about. A leaver who keeps access to your product for three weeks is an audit finding for them, and a reason to choose a competitor. Plan for just-in-time provisioning on first SSO login as the simple path, and SCIM as the complete one, with clear rules for which source wins when the two disagree.
Keep roles boring at first. Three or four fixed roles per tenant, with permissions defined in code and checked in one authorisation layer, will carry you a long way. Custom roles are a genuine enterprise requirement, but build them on top of named permissions you already have, never as ad hoc flags scattered through controllers. Check permissions on the server for every request, and treat hidden buttons in the interface as a convenience rather than a control.
- Store an append-only audit log of logins, role changes, exports and settings changes per tenant from the first release.
- Let tenant admins see and download their own audit log, because enterprise buyers will ask for it during security review.
- Require re-authentication for destructive actions such as deleting a workspace or rotating API keys.
- Support support-staff impersonation only through a logged, time-boxed and customer-visible mechanism.
Billing, metering, dunning and GST
Treat billing as its own bounded context with its own tables, not a few columns on the tenant record. A subscription has a plan, a quantity of seats, add-ons, a billing interval and a history of changes with proration. Let a billing platform such as Stripe Billing own invoices, payment methods and retries, and keep your application as the source of truth for entitlements: what a tenant is allowed to do right now.
Usage-based pricing needs a metering pipeline you can audit. Emit a usage event with an idempotency key at the moment value is delivered, such as a document processed or an API call served, aggregate events per tenant per period, and send aggregates to the billing system. Never compute an invoice by querying raw application logs at month end; when a customer disputes a charge, you need to show the exact events behind it.
For Indian customers, GST shapes the invoice itself. Software services currently attract 18 percent GST, B2B customers need their GSTIN and place of supply on a tax invoice to claim input credit, the place of supply decides between IGST and CGST plus SGST, and invoice numbers must be consecutive and unique within each financial year. Services exported to overseas customers can usually be zero-rated under a Letter of Undertaking. Recurring card payments in India also follow RBI e-mandate rules with additional authentication and pre-debit notifications, so offer UPI AutoPay and bank transfer against invoice alongside cards.
- Collect GSTIN, legal name and billing state at checkout for Indian B2B tenants, and validate the GSTIN format before issuing an invoice.
- For international customers, decide early between calculating VAT and sales tax yourself with a tax engine or selling through a merchant of record.
- Run dunning as a sequence: smart retries, reminder emails, a grace period, then read-only mode, and never delete data for non-payment.
- Reconcile billing events against your entitlements table nightly and alert on any tenant whose access and subscription disagree.
Noisy neighbours, limits and per-tenant visibility
In a shared system, one tenant's bulk import, runaway integration or unindexed report can degrade everyone. The defence is layered limits that are tenant-aware: API rate limits per tenant rather than per IP, quotas on storage and seats, a per-statement timeout for reporting queries, and job queues that schedule fairly across tenants instead of first in, first out. A queue where one customer's fifty thousand jobs sit ahead of everybody else's ten is the most common noisy-neighbour incident we see.
You cannot manage noise you cannot see. Put tenant_id on every log line and trace span so you can answer which tenant is slow and why. Be careful with metrics, though: a tenant label on every time series multiplies cardinality and your monitoring bill, so record per-tenant detail in logs and traces, and keep metrics to aggregates plus the top few tenants by load.
Measure cost per tenant as well as latency. On CloudVault, our multi-tenant FinOps platform that monitors more than 100,000 nodes across customers' cloud estates, cost visibility per tenant is the product itself, and the same discipline belongs inside any SaaS. Knowing that a handful of tenants drive most of your database load is what lets you price fairly, or move them to dedicated capacity before they hurt the shared pool.

Onboarding in minutes, leaving with dignity
Tenant provisioning should be a single idempotent workflow: create the tenant record, the owner membership, default settings, the billing customer and any per-tenant infrastructure, then mark the tenant active. If any step fails, the workflow retries from where it stopped rather than leaving a half-created workspace that support has to repair by hand. Sample data and a guided first task do more for activation than any onboarding video.
Data export is both a sales argument and a legal duty. Buyers ask how they leave before they sign, and data protection law, including India's Digital Personal Data Protection Act and the GDPR for European users, gives individuals rights over their data. Offer a full tenant export in documented CSV or JSON, run it as a background job and deliver it through an expiring link.
Offboarding needs the same care. Define how long a cancelled tenant's data is retained, delete it on schedule with a job that can prove what it removed, and be honest in your contract about backups, which typically age out on their own retention cycle rather than being edited. Files in object storage, search indexes and analytics copies are where forgotten tenant data usually survives.
Mistakes that are expensive to undo
Some decisions can be revisited in a sprint. The ones below are different: in multi-tenant systems they routinely take quarters to unwind, usually while customers are waiting and sales is promising dates. Each is cheap to avoid in the first month and painful to fix after a few hundred tenants have real data in the system.
The common thread is that each one hides tenancy, money or identity inside application logic where nothing enforces it. When the product grows, nobody can say with confidence which code paths respect the rule, so the fix becomes an audit of the whole codebase rather than a change in one place. Push each rule down to where it is enforced once: the database, the entitlements table, the ledger.
- Treating the user as the tenant, which breaks the moment one person belongs to two organisations.
- Using sequential integer IDs everywhere, which leak customer counts and collide when tenants move between databases.
- Enforcing isolation only in application code, so one missed WHERE clause becomes a data breach.
- Hard-coding plan limits in conditionals instead of an entitlements table that billing can update.
- Storing invoices only in the payment provider, leaving finance unable to reconcile GST returns without exports and spreadsheets.
- Shipping without per-tenant audit logs, then reconstructing them from application logs during a customer's security review.
How we would approach your platform
On a SaaS Product Development engagement we start with a short architecture sprint: who your first fifty customers are, which contracts and regions they bring, and how you intend to charge. From that we choose the tenancy model, sketch the tenant directory, identity and billing contexts, and write the isolation tests before feature work begins. Where infrastructure, data residency or cost per tenant matter, our Cloud Solutions & Infrastructure team designs the Terraform-managed environments alongside it.
If you want a first view of effort, the Budget Calculator on this site gives a range in a few minutes, and a scoping call lets us pressure-test your tenancy, identity and billing decisions before they become expensive. Bring your pricing model, your target markets and the requirements your largest prospects have already raised; those two documents usually decide the architecture.
- Multi-tenancy
- Row-Level Security
- Usage-Based Billing
- GST Invoicing
- SaaS Architecture
Written by
JP INFOTECH Product Engineering
SaaS & Platforms Practice, JP INFOTECH









