SaaS Tenant Data Isolation: Cost & Operations
- Monthly storage cost
- USD
- Result
- Number of tenants
- 100
- You entered
- Rows per tenant
- 10000
- You entered
This article explains what tenant data isolation in a SaaS product costs to implement and operate, and how those costs break down across engineering, infrastructure, and ongoing maintenance. You get a clear comparison of the main isolation models—shared database, schema-per-tenant, and database-per-tenant—with their operational trade-offs, so you can estimate the real price of the isolation level your product needs.
Formula
The calculator above estimates the raw storage cost of tenant data. The formula is:
Total storage (GB) = (Number of tenants × Rows per tenant × Bytes per row) / (1024³)
Monthly cost = Total storage (GB) × Cost per GB-month
Variables:
- Number of tenants – how many customer accounts (or organizations) you store data for.
- Rows per tenant – average number of records per tenant in the largest table (e.g., orders, messages, documents).
- Bytes per row – average size of one row, including indexes and overhead. A typical value is 200–500 bytes for simple text data, but can be much higher for JSON blobs or large text fields.
- Cost per GB-month – the price you pay for managed database storage, e.g., $0.25 per GB-month for a typical cloud relational database. This does not include backups, IOPS, or compute.
Worked Example
Using the defaults: 100 tenants, 10,000 rows per tenant, 200 bytes per row, $0.25 per GB-month.
- Total bytes = 100 × 10,000 × 200 = 200,000,000 bytes.
- Convert to GB: 200,000,000 / (1024³) = 200,000,000 / 1,073,741,824 ≈ 0.186 GB.
- Monthly storage cost = 0.186 × $0.25 ≈ $0.047.
So for that tenant volume, raw storage is under a nickel a month. The real costs come from operations, not the bytes themselves.
Why Isolation Matters
Tenant isolation is the security boundary between customers in a multi-tenant SaaS application. If one tenant can read or modify another tenant’s data, you have a critical vulnerability. Isolation isn’t just about privacy—it also affects performance (a noisy neighbor can slow down everyone) and regulatory compliance (some industries require physical separation). The level of isolation you choose directly drives both your infrastructure bill and your engineering workload.
Isolation Models and Their Costs
There are three common approaches, each with a different cost profile:
- Shared database, shared schema – all tenants in the same tables, distinguished by a tenant_id column. This is the cheapest to operate: one database, one set of backups, simple scaling. But it requires careful query design to always filter by tenant_id, and a bug could leak data across tenants. Operational cost is low, but risk is higher.
- Schema-per-tenant – each tenant gets its own schema (set of tables) in the same database. This gives better logical separation and makes it easier to drop or restore a single tenant. However, you now have hundreds or thousands of schemas to manage. Backups become more complex (you may need per-schema backup tools), and migrations must run across all schemas. Cost is moderate.
- Database-per-tenant – each tenant gets its own database. This offers the strongest isolation, simplifies compliance, and lets you move a tenant to a dedicated server if needed. But it multiplies infrastructure: more databases to monitor, patch, back up, and tune. Cost scales with tenant count, not just data volume.
Operational Costs Beyond Storage
Storage is only a fraction of the total cost. The bigger expenses are:
- Backups and restore – per-tenant backups require tooling to snapshot and restore individual tenants. Restoring one tenant from a shared backup is slow and risky (you might overwrite others). Database-per-tenant makes restore trivial but requires automating backup for each database.
- Schema migrations – every time you change the database schema, you must apply it to all tenants. With shared schema, it’s one migration. With schema-per-tenant, you need a script that loops over all schemas. With database-per-tenant, you need to run migrations across potentially thousands of databases, which takes time and can cause inconsistency if it fails midway.
- Monitoring and alerting – you need to watch for slow queries, connection limits, and disk space. With many databases, you need aggregated dashboards and automated alerts, which add development time.
- Connection management – databases have connection limits. With database-per-tenant, you can’t keep a connection open for every tenant; you need connection pooling and possibly a proxy like pgbouncer. That’s extra infrastructure to run and tune.
- Tenant lifecycle management – creating a new tenant (provisioning a schema or database) and deleting one (cleanly removing data) must be automated. This is often an overlooked engineering cost.
How to Choose the Right Model
There’s no one-size-fits-all answer. Consider these factors:
- Number of tenants – under 100, database-per-tenant is manageable; over 10,000, shared schema is almost mandatory for cost reasons.
- Data sensitivity – healthcare, finance, or legal data may require stronger isolation for compliance. Database-per-tenant makes audits easier.
- Tenant size heterogeneity – if a few tenants have huge data volumes, database-per-tenant lets you move them to bigger hardware without affecting others.
- Engineering team size – a small team can’t afford to manage thousands of databases; shared schema is simpler to operate.
- Compliance requirements – some regulations require data to be stored in specific regions or with specific encryption keys. Database-per-tenant makes region-pinning easier.
Common Misconceptions
A frequent mistake is assuming that database-per-tenant is always more secure. In reality, security depends on your application code and access controls. A shared schema with strict row-level security (e.g., PostgreSQL’s Row Level Security) can be just as secure if implemented correctly. The real difference is operational complexity, not inherent security.
Another misconception is that storage cost is the main driver. As shown in the example, storage is cheap. The cost is in engineering hours spent building automation for provisioning, backups, migrations, and monitoring. That’s why many SaaS companies start with shared schema and move to schema-per-tenant only when they need better data portability or compliance.
Cost Comparison Table (Illustrative)
For a product with 1,000 tenants and 1 GB of data per tenant (total 1 TB), here’s a rough comparison of monthly operational costs (excluding compute):
- Shared schema – storage ~$250 (1 TB × $0.25). One database to manage. Backup cost is included in storage. Total operational overhead: low.
- Schema-per-tenant – storage same ~$250. But you need automation to run migrations across 1,000 schemas. Backup tools may charge per schema. Expect additional $100–$500/month in tooling or engineering time.
- Database-per-tenant – storage same ~$250, but each database has overhead (e.g., minimum storage allocation, connection limits). You might need 10–20 databases per physical server, so you need more servers. Costs can easily double or triple the shared schema bill.
Operational Best Practices
Whatever model you choose, these practices reduce cost and risk:
- Always include a tenant_id in every query and enforce it with a database-level policy (e.g., RLS) as a safety net.
- Automate tenant provisioning and deprovisioning with Infrastructure-as-Code (Terraform, CloudFormation) so you don’t manually create databases.
- Use a migration tool that supports multi-tenant (e.g., Flyway with a loop over schemas).
- Monitor query performance per tenant to spot noisy neighbors early.
- Test backup/restore procedures regularly, especially for per-tenant restore.
Frequently Asked Questions
What is the cheapest way to isolate tenants?
Shared database with a tenant_id column is the cheapest to build and operate. It requires no extra infrastructure, and you only pay for one database. The cost is in development discipline to avoid cross-tenant data leaks.
Does database-per-tenant cost more?
Yes, typically. You pay for more database instances, which means more compute, storage overhead, and management. The cost difference is most significant when you have many small tenants, because each database has a minimum footprint.
Can I start with shared schema and migrate later?
Yes, but migration is non-trivial. You’ll need to write scripts to split data by tenant_id into new schemas or databases. It’s easier if you design your data model with a clear tenant_id from day one.
How do I handle backups for per-tenant databases?
Most cloud databases allow automated snapshots. You can script per-database backup and restore. For schema-per-tenant, you may need to use pg_dump per schema or rely on point-in-time recovery of the whole database.
Is isolation only about databases?
No. You also need to isolate application-level caches, file storage (S3 buckets), and search indexes. For example, each tenant should have a separate search index or at least a filter on tenant_id in queries.
What is row-level security and does it help?
Row-level security (RLS) is a database feature that automatically filters rows based on the current user. It acts as a safety net, preventing accidental cross-tenant access even if your application code has a bug. It adds a small performance overhead but is worth it for shared schema.
Conclusion
Tenant data isolation is not a one-time decision; it’s an ongoing operational commitment. The cheapest option (shared schema) is fine for most startups. As you grow, you may adopt schema-per-tenant for better data portability, and only move to database-per-tenant when compliance or tenant size demands it. Use the calculator above to estimate your raw storage cost, but remember that the real budget goes to engineering time for automation and monitoring.
Related
Formula used
in t | Number of tenants | - | 100 | 1 in d | Rows per tenant | - | 10000 | 1 in c | Cost per GB-month (USD) | - | 0.25 | 0 in s | Storage per row (bytes) | - | 200 | 1 out storage_gb | Total storage (GB) | GB | (t * d * s) / (1024^3) | 2 out cost_month | Monthly storage cost | USD | ((t * d * s) / (1024^3)) * c | 2
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.