Scrivio Interview library
LeadershipPrincipal5 min read · updated 12 November 2026

Your SaaS started with schema-per-tenant and now has 15,000 schemas; migrations take a day and costs are rising. Leadership asks for a multi-year tenancy strategy. What do you propose?

I would first quantify the pain, migration time, incidents, cost per tenant and onboarding time, and then propose a target of shared tables with tenant_id and row-level security for most tenants, plus dedicated cells for large or regulated customers. We would migrate in waves with dual-run verification and per-tenant cutover and rollback, starting with small low-risk tenants, tie isolation levels to commercial tiers, and invest early in tenant routing, per-tenant backup and restore, and tenant-aware observability.

Why this question is asked

Schema per tenant is a very reasonable start: it is simple to reason about and gives clean isolation for the first hundred customers. At 15,000 schemas it has become the bottleneck for the whole company, and leadership wants a plan that runs for years without stopping the product. Interviewers ask this to see whether we can build a business case, define a target, and design a migration that is safe at every step. In this answer, we will measure the current pain, define the target architecture, design the migration waves, connect it to pricing, and list the tooling we need first.

1Quantify the Current Pain

A multi-year plan needs a baseline that leadership trusts. So we measure four things. Migration time: a schema change applied to 15,000 schemas takes a day today, which means releases wait, and failed runs leave some schemas on the old version. Incidents: how many outages or degraded hours came from catalog size, connection limits, or half-applied migrations last year. Cost per tenant: infrastructure divided by tenants, including the extra instances needed because the catalog and connection overhead grow with each schema. And onboarding time: how long it takes to create a new tenant's schema and seed it.

With numbers such as one release blocked per week, six incidents last year and a cost per small tenant three times higher than it would be in shared tables, the conversation is about evidence rather than taste.

2Define the Target Architecture

For most tenants, the target is shared tables keyed by tenant_id, with tenant_id leading every key and index and row-level security as the safety net. One migration run covers all of them, the catalog stays small, and a new tenant is a row.

Large or regulated customers go into dedicated cells: a separate database, or a full stack, with the same schema. This keeps their isolation, lets us offer region choice or separate encryption keys, and keeps their load away from everyone else. A tenant routing layer in front decides where each tenant's data lives, so the code is the same for both.

Today and the target
ConcernToday: 15,000 schemasTarget: shared + cells
Migration runabout one day, partial failuresminutes per cell, few cells
Onboarding a small tenantcreate and seed a schemainsert tenant rows
Isolation for small tenantsnamespacerow-level security
Isolation for large tenantsnamespace on a shared instancededicated database or cell
Per-tenant restoreeasyneeds tooling, built first

3Migrate in Waves

We do not move 15,000 tenants at once. Each tenant's move follows the same steps, and we run them in waves of growing size. First we copy the tenant's data from its schema into the shared tables, adding tenant_id. Then a dual-run period follows: writes go to the old schema as the source of truth and are replicated or mirrored to the shared tables, and a verifier compares row counts, checksums and the results of key queries between the two. When they match for an agreed period, we switch the tenant's routing entry to the shared tables. The old schema stays read-only for a few weeks as a rollback path, then it is dropped.

The first wave is 50 small, low-risk tenants, such as internal test accounts and free-tier customers, chosen so problems hurt little. Then waves of 500, then thousands. Large and regulated tenants move last, directly into their cells, with customer communication planned in advance.

Step throughMoving one tenant
  1. Copy schema data into shared tableswith tenant_id added
  2. Dual runold schema stays the source of truth
  3. Counts, checksums and queries match?
    YesSwitch routing to shared tablesNoFix and repeat verification
  4. Problems after cutover?
    YesSwitch routing back, old schema intactNoKeep old schema read-only for weeks
  5. Drop the old schemaafter the rollback window

5 steps in order. Play them, or step through them one at a time.

4Make Isolation a Product Feature

Isolation has a real cost, so it should have a price. We align the target with commercial tiers: standard tenants live in shared tables, a business tier might get a dedicated database inside a shared cell, and an enterprise tier gets its own cell with region choice and its own keys. Sales can then answer security reviews with a clear offer, and finance sees that the expensive option pays for itself. This also prevents the slow drift back to the old model, where every large prospect asked for special treatment and got it for free.

5Build the Tooling First

Three capabilities must exist before the first wave, because schema per tenant gave them to us for free and shared tables do not. Tenant routing: a directory and a routing layer, with caching and a way to change a tenant's location safely. Per-tenant backup and restore: the ability to export or restore one tenant's rows from shared tables, tested regularly, because customers and support rely on it. And tenant-aware observability: metrics, logs and query statistics that can be filtered by tenant, so support can still answer 'why is tenant X slow' once tenants share tables.

The plan then fits naturally into years. In year one, we build the tooling, run the first waves and stop creating new schemas, so all new tenants start in shared tables. In year two, we move the bulk of existing tenants. In year three, we finish the long tail and move the largest customers into cells.

6Follow-up questions

Why not keep schema per tenant and just speed up migrations?

We can parallelise migrations and reduce the day to hours, and that is worth doing as a short-term step. But catalog size, connection handling and per-schema overhead still grow with every new tenant, so the pain returns. The structural problem is the number of schemas.

How do we handle tenants with custom columns?

Map customisations into a shared extension mechanism, such as a jsonb column with a per-tenant schema validated in the application, or a key-value extension table. Truly unusual tenants may belong in a dedicated cell.

What is the biggest risk in this migration?

A data leak between tenants in shared tables. That is why row-level security, composite keys with tenant_id, and automated isolation tests must be in place before the first tenant moves.

7Conclusion

In this answer, we saw how to turn 15,000 schemas into a multi-year tenancy strategy: quantify migration time, incidents, cost per tenant and onboarding time, aim for shared tables with tenant_id and row-level security plus dedicated cells for large or regulated customers, migrate in waves with dual-run verification and per-tenant cutover and rollback starting with low-risk tenants, align isolation with commercial tiers, and build tenant routing, per-tenant backup and restore and tenant-aware observability first.

What to say in the interviewAbout 90 seconds aloud

Open with

I would start by measuring the pain so the plan rests on evidence: how long a migration takes across 15,000 schemas, how many incidents came from catalog size, connections or half-applied migrations, what a small tenant costs us, and how long onboarding takes.

Then, if they want more

Then I would propose a target. Most tenants move to shared tables keyed by tenant_id, with tenant_id leading every key and index and row-level security as a safety net, so one migration covers them all. Large or regulated customers get dedicated cells with the same schema. A tenant routing layer decides where each tenant lives.

The migration runs in waves, starting with small, low-risk tenants. For each tenant we copy the data, run a dual-run period with the old schema as the source of truth, verify counts, checksums and key queries, then switch routing, keeping the old schema read-only for a while so rollback is just switching routing back.

Commercially, isolation becomes a tier: shared for standard, dedicated cells for enterprise. And before the first wave we need tooling that schema per tenant gave us for free: tenant routing, per-tenant backup and restore, and observability filtered by tenant.

Year one is tooling and first waves, with no new schemas created, year two the bulk, and year three the long tail and the large tenants.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Your SaaS started with schema-per-tenant and now has 15,000 schemas; migrations take a...": https://scrivio-interview-library.netlify.app/databases/data-modeling/106aee638e/