Skip to main content

What are you looking for?

Explore our services and discover how we can help you achieve your goals

Multi-tenant SaaS architecture: isolation, billing, AI features and scaling choices

Multi-tenant SaaS architecture means one platform serves many customer organizations while keeping each one's data, performance and bill separate. Decide isolation layer by layer rather than once, enforce tenant context below the application code, meter usage per tenant from the first release, AI model calls included, and plan how a tenant can move to more dedicated resources.

Book a solution review See the related service

Reviewed by David (CEO) · Updated 17 Sep 2026 · 11 min read

star

This technical article is for CTOs, architects and senior engineers designing a SaaS product or reworking one that has outgrown its first design. Our SaaS platform engineering guide introduces the silo, pool and bridge tenancy models and the control plane; this article goes one level deeper into how isolation is enforced at each layer, how data is partitioned, how billing is wired, how AI features stay inside tenant boundaries and how the platform scales.

Context: tenants, users and deployments

Start by defining the tenant. In business-to-business SaaS, a tenant is usually a customer organization with many users; some customers need several tenants, for example separate subsidiaries or separate test and production environments. In business-to-consumer products, a tenant may be one person, a family or a group. Microsoft's Azure Architecture Center makes the point that this definition, and whether a tenancy model is acceptable to customers, is a commercial decision as much as a technical one.

Separate the logical tenant from the deployment that serves it. A deployment, sometimes called a stamp, is one set of infrastructure. Many tenants can share a deployment, or one tenant can have its own. Keeping a tenant-to-deployment map from the start lets you move tenants between deployments later without rewriting the application.

Isolation is decided per layer

The AWS whitepaper on SaaS tenant isolation strategies calls isolation fundamental to SaaS design and describes crossing a tenant boundary as a potentially unrecoverable event for the business. Microsoft describes isolation as a spectrum rather than a single switch. In practice, each layer gets its own answer:

Layer Shared option Isolated option What decides it
Compute Shared application servers Dedicated servers or containers per tenant Performance guarantees, noisy neighbours, customer demands
Database Shared tables with a tenant key Separate schema or database per tenant Data sensitivity, backup and restore needs, scale
File storage Shared bucket with tenant prefixes Bucket or container per tenant Access policies, data residency, retention rules
Cache Shared cache with tenant-prefixed keys Separate cache per tenant Risk of key collisions, memory pressure
Queues and jobs Shared queues with tenant-tagged jobs Queues per tenant or per tier Fairness, so that one tenant's backlog does not delay others
Search index Shared index filtered by tenant Index per tenant Index size, relevance tuning per tenant
Logs and metrics Shared pipeline tagged by tenant Separate streams for regulated tenants Support needs, audit requirements
Encryption keys Platform-managed keys Per-tenant keys Contractual demands, offboarding (destroying a tenant's key)
AI retrieval index Shared vector index with an enforced tenant filter Index or namespace per tenant Data sensitivity, index size, offboarding

A common and sensible result is a pooled application tier with isolated data for the tenants that need it. Microsoft calls splitting some components per tenant while sharing others horizontal partitioning; giving selected tenants a whole dedicated deployment is vertical partitioning.

Data partitioning options

Pattern How isolation is enforced Strengths Trade-offs Fits
Shared schema, tenant key on every row Tenant filter in every query, backed by database row-level policies Cheapest, simplest to operate, easy cross-tenant reporting One missed filter can leak data without database policies; noisy neighbours Many small tenants
Schema per tenant Separate schema per tenant in one database Clear separation, per-tenant restore is easier Migrations run once per schema; practical limits on schema count Tens to hundreds of mid-sized tenants
Database per tenant Separate database per tenant Strong isolation, per-tenant tuning, residency options Higher cost, fleet management for migrations and backups Large or regulated tenants
Deployment per tenant Separate stack per tenant Strongest isolation, independent release timing Highest cost; many deployments to operate Few very large or regulated customers

For a pooled database, enforce isolation in the database itself, not only in application code. PostgreSQL's row security policies are one way: once enabled on a table, rows are hidden unless a policy allows them, so a query without a tenant filter returns nothing instead of everything. Two details matter. Policies must be enabled per table, and table owners, superusers and roles with the BYPASSRLS attribute bypass them by default. The application should therefore connect with a role that does not own the tables, or the tables should force row security, so that the policies also apply to the owner.

Request flow and tenant context

A request in a multi-tenant platform should follow the same path every time:

  1. Resolve the tenant

    from the subdomain, a custom domain or a claim in the authentication token, never from a value the client can freely change.

  2. Authenticate the user

    and confirm that the user belongs to that tenant.

  3. Map the tenant to its deployment and data location

    using the tenant map.

  4. Set the tenant context

    for the database session, so row policies or schema selection apply automatically.

  5. Propagate the context

    to background jobs, events, cache keys, logs, metrics and AI retrieval calls.

  6. Check authorization

    with both the tenant and the user's role in that tenant.

Most tenant data leaks come from a step that was skipped in one place: a background job without context, a cache key without a tenant prefix, or an admin endpoint that trusted a tenant ID in the request.

Billing and metering architecture

Billing in multi-tenant SaaS is a pipeline, not a single integration.

  1. Usage events

    The application emits events per tenant and feature

    Design note
    Emit from the first release, even if pricing is flat today
  2. Metering

    Aggregates events into usage per tenant and period

    Design note
    Idempotent: a retried event must not be billed twice
  3. Entitlements

    Decides what each tenant may use, and up to which limit

    Design note
    Code checks entitlements, never plan names
  4. Rating

    Applies prices to usage and plan

    Design note
    Configuration, so pricing changes need no release
  5. Invoicing and payment

    A billing or payment provider charges and invoices

    Design note
    Keep card data with the provider
  6. Revenue reporting

    Finance views of revenue, churn and failed payments

    Design note
    Built on the same data as metering
  7. AI usage

    Model calls and tokens per tenant and feature

    Design note
    Capped by entitlements, so one tenant cannot consume a plan's margin
  • Flat subscription per tenant

    Needs entitlements and a billing lifecycle; metering is still useful for cost per tenant

  • Per seat

    Needs reliable user counts per tenant and rules for mid-period changes

  • Usage-based

    Needs accurate, idempotent metering and usage visible to customers

  • Hybrid (base fee plus usage)

    Needs all of the above, plus clear limits and overage rules

AI features: data isolation and model cost per tenant

Assistants, AI search and summaries read more tenant data in one request than most screens do, so they need the same boundaries enforced in the same place.

  • Filter retrieval outside the prompt. The retrieval service applies the tenant and user permissions from the session context. A prompt instruction such as "only use this customer's data" is not isolation.
  • Key every AI cache by tenant. Cached answers and embeddings without a tenant key can return one customer's content to another.
  • Keep tenant data out of shared training. Do not fine-tune a shared model on one tenant's data, and choose model providers whose terms exclude training on your requests. Regulated tenants may need a region or a dedicated model deployment.
  • Meter model cost per tenant. Tokens and calls vary widely between tenants; attribute them per feature and enforce limits through entitlements.
  • Delete on offboarding. A departing tenant's embeddings, indexes and logged prompts go with its database rows.

Scaling choices

Choice When to use it Cost and complexity
Scale the shared deployment up and out Early growth with similar tenants Lowest; watch for shared-resource limits
Shard tenants across several databases One database is reaching its limits Moderate; needs the tenant map and cross-shard reporting
Add deployment stamps Growth in regions or tenant count beyond one stack Higher; needs automated provisioning and releases
Move a large tenant to dedicated resources One tenant dominates load or requires isolation Per tenant; needs a tested migration path
Noisy-neighbour controls Always Low; rate limits, per-tenant quotas and fair job scheduling

Plan the tenant migration path early: how a tenant's data moves from the shared database to its own, how traffic is switched, and how you verify the result. It is much easier to design than to invent under pressure when your largest customer asks for it.

Operations: releases, migrations and restores

  • Release in rings. Roll out to internal tenants, then a small share of customers, then everyone, with per-tenant feature flags.
  • Automate schema migrations across the fleet. With schema-per-tenant or database-per-tenant, one release means many migrations; track which tenant is on which version.
  • Restore one tenant, not only the whole platform. Customers will ask for a single tenant's data to be restored; test it before they do.
  • Measure cost per tenant. Combine metering with the cloud bill to see which tenants and plans cover their costs.

Test evidence: what to test

These are general engineering practices, not results from a specific project:

  • Cross-tenant access tests. Automated tests for every endpoint and job that try to read or change another tenant's data and must fail.
  • Row-policy tests. Queries run without a tenant context must return no rows, including under the application's database role.
  • Noisy-neighbour load tests. One tenant generates heavy load while response times for the others are measured.
  • Single-tenant restore tests. Restore one tenant from backup into a clean environment and compare the records.
  • Metering tests. Replayed and duplicated events must produce the same usage totals.
  • Cross-tenant AI tests. An assistant asked about another tenant's records must find nothing, including through cached answers.

Example: Printcart

Printcart, one of the five Netbase Business Divisions, is a web-to-print and print-on-demand platform that turns online orders into print-ready files and routed fulfillment. It runs on a merchant's own store or as Shopify, Wix and WooCommerce apps, with setup in about 7 days, and reports 10,000+ partners over 10 years of service. Serving that many merchants from one product is the multi-tenant problem this article describes: each merchant needs its own catalog, orders and store connection on a shared platform. The Printcart portfolio record covers what Netbase engineered and operates, and printing and packaging shows the sector context.

Outside its own products, Netbase has worked since 2020 as the offshore development and managing partner on a multi-tenant cloud ERP for a US client that is not named, sold as SaaS to small and mid-sized businesses.

How Netbase approaches multi-tenant builds

Netbase works with AWS, Google Cloud, DigitalOcean and Cloudflare; no cloud partner tier or cloud certification is claimed. Typical timelines are 8 to 12 weeks for a SaaS MVP, 3 to 6 months for a mid-tier product and 6 to 12 months or more for an enterprise platform, depending on scope; these are ranges, not quotes. Security is designed in from the first sprint: secure code review, TLS in transit and AES at rest, role-based access control, MFA for admin dashboards, vulnerability scanning and disaster recovery planning. AI models are chosen per product, not tied to one vendor. The SaaS development service builds the product, and the SaaS product accelerator starts from reusable modules for accounts, tenants, roles and billing.

Limits of this article

  • It describes common patterns and general practice; the right mix depends on your tenants, data, regions and customers' contracts.
  • The AWS whitepaper cited is marked as historical reference by AWS; its isolation principles remain widely used, but check current AWS guidance for service specifics.
  • PostgreSQL is used as one example of database-enforced isolation; other databases offer different mechanisms.
  • Timelines are typical ranges. Printcart is described from its published product information; no performance metric is claimed for it here.

Next step

Share your tenant profile, data sensitivity and pricing model, and we will book a solution review to choose the isolation and billing design for your first release. You can also see the related service or browse more Netbase insights.

AI-ready SaaS development from a team that runs its own SaaS AI-ready SaaS development from a team that runs its own SaaS

Netbase provides SaaS development services for founders and product teams to launch and scale multi-tenant subscription software with AI features customers will pay for. We build and operate our own SaaS platforms, Printcart and the AI-powered Cloodo workplace, and bring that operating experience to client products. A typical SaaS MVP takes 8–12 weeks, depending on scope, integrations and review speed.

Learn More
line
SaaS product accelerator: launch an AI-ready SaaS on proven Netbase modules SaaS product accelerator: launch an AI-ready SaaS on proven Netbase modules

A SaaS product accelerator is a set of reusable Netbase modules for accounts, billing, roles and integrations that helps founders and product teams launch subscription software faster, with room for in-product AI from the first release. Reusing these productized modules can cut development time by up to 60%, and the approach is proven on Printcart, the web-to-print SaaS Netbase built and operates.

Learn More
line
Contact Netbase

Discuss a project

Netbase JSC helps organizations design, build, modernize, and operate digital products and AI-enabled business systems.
Project enquiries

[email protected]

WhatsApp

+84 937 869 689

Office address

91 Nguyen Chi Thanh, Dong Da, Hanoi, Vietnam

Get in touch

Tell us what you want to build, modernize, or operate.

Tell us what you want to build, modernize, or operate.

Contact Netbase