Sooner or later every multi-tenant SaaS platform has to move a customer. A tenant outgrows its shard. A noisy neighbor starts hurting latency for everyone else. A cell has to be drained for decommissioning. An enterprise contract requires a different region or dedicated infrastructure. In each case the question is the same: how do you move one tenant between shards or cells while the tenant keeps working, without losing a single acknowledged write, and with a rollback you can actually trust?
This article is written for the tech lead or solution architect who owns that move. It does not cover which sharding scheme to pick; for that, see our guide to database sharding strategies. It covers the narrower and riskier problem of the move itself: copying, catching up, fencing writes, flipping the route, and reversing if something is wrong.
The design below is a proposed design, not a product and not a method we claim is already standard across your stack. It combines well-documented patterns (dual-phase online migrations, replication-based cutover, fencing tokens, conditional writes) into one tenant-scoped state machine. Where we mention numbers, they are illustrative unless attributed to a source, and you should replace them with your own measurements.
- Who it is for: tech leads and architects running shard- or cell-based multi-tenant systems.
- What you get: a state machine, a fenced cutover sequence, mandatory go/no-go controls, failure patterns, and a decision matrix.
- What it assumes: you already have a tenant-to-shard routing layer, or are willing to build a minimal one first.
Key Takeaways
- A tenant move is a distributed state change, not a data copy. The copy is the easy part. The hard part is guaranteeing exactly one writer for the tenant at every instant.
- Make the move a durable, tenant-scoped state machine. Bind each move to an immutable, hashed plan, claim it atomically, and advance it only with conditional updates.
- Route with an epoch and enforce it at the data plane. A routing table alone cannot stop a stale cache or a paused worker from writing to the old shard.
- Never blindly retry an ambiguous cutover timeout. Read the authoritative routing record first. An unknown result means completion could not be confirmed. It is neither success nor verified failure.
- Tenant state hides outside the main database. Idempotency records, outbox rows, queued jobs, object storage, search indexes and secrets must move or be explicitly accounted for.
- Use all-required go/no-go controls, not a score. One failed control means no cutover, regardless of how many others pass.
- Keep a rollback path that survives post-cutover writes. If no reverse replication exists, rollback is a data-loss decision, not a switch.
Why Moving One Tenant Is Harder Than Moving a Table
Key point: a tenant is not one table or one database. It is a bundle of state spread across several systems, and all of it has one logical owner at a time.
Teams usually start with the data model they know best: rows in a relational database. That is where the first surprise lives. When engineers say "the tenant's data," they often mean the rows keyed by tenant_id in the primary store. But production tenants leave state in many other places, and any of it can silently stay behind on the source shard.
Common reasons teams move a tenant
- Capacity and noisy neighbors: one tenant's write rate or query shape degrades its shard-mates.
- Rebalancing: a shard or cell is full, or a new one has been added and load should spread.
- Isolation tiers: a customer is promoted to a dedicated shard or a dedicated cell under contract.
- Residency: data must live in a particular geography. Note that moving across regions changes where personal data is physically stored, so a privacy owner must approve the move before it starts.
- Decommissioning: hardware, a database version, or a whole cell is being retired.
Where tenant state hides
| State | Why it gets missed | Consequence if left behind |
|---|---|---|
| Primary database rows | Usually covered first | Obvious data loss, caught quickly |
| Idempotency-key records | Stored in a separate table or cache; treated as plumbing | Client retries after cutover create duplicate side effects |
| Outbox and inbox rows | Owned by a messaging library, not the domain model | Lost or double-sent events and webhooks |
| Queued and scheduled jobs | Live in a shared queue, keyed by tenant only in the payload | Jobs run against the old shard after the move |
| Object storage and search indexes | Different team, different bucket or cluster | Broken attachments, stale or missing search results |
| Caches and routing caches | Assumed to be disposable | Stale routes cause writes to the wrong shard |
| Secrets, API keys, webhook endpoints | Managed by a security or platform team | Authentication or delivery failures after the move |
| Audit trail | Append-only store treated as separate | Gaps in the history for the very window you most need it |
Notice that most of these are also where consequential side effects live. If you have read our pieces on the outbox pattern and multi-tenant isolation patterns, you already know the isolation boundary was designed for steady state. A tenant move deliberately crosses that boundary, which is why it needs its own design.
How Most Teams Approach Tenant Moves, and Why Copy-and-Flip Fails
Key point: the common approaches differ mainly in how long writes are paused and whether a rollback survives new writes. Few of them make the single-writer guarantee explicit.
The default approach is "copy-and-flip": export the tenant's rows, import them to the target, update the routing table, and tell the support team to watch for problems. It works for small tenants in quiet hours. It fails for the tenants you most need to move, because they are large, busy and contractually sensitive.
| Approach | Write pause | Main risk | Rollback after new writes on target? |
|---|---|---|---|
| Maintenance-window export/import | Entire copy duration | Window overruns; long outage for large tenants | Only by discarding target writes or re-exporting |
| Copy, then flip route | None until flip, then ambiguous | Writes between snapshot and flip are lost or split | Usually no |
| Application-level dual write | None, in theory | Partial failure leaves stores diverged; every write path must be changed | Possible if the old store stays authoritative until late |
| Replication or change-data-capture with fenced cutover | Short, bounded pause at the end | Replication lag never converges; incomplete tenant scope | Yes, if reverse replication is set up before reopening writes |
The dual-write pattern is well documented. Stripe's engineering team described a four-step version in Online migrations at scale: dual write to the old and new stores, move reads to the new store, move writes to the new store, then remove the old data. Two details from that account are worth borrowing: they verified read paths by comparing results from both stores before switching, and they made every step incremental so the old store stayed available as a fallback. That pattern was described for moving a data model within one system. A tenant move adds a harder requirement, which is that two different physical locations must never both accept writes for the same tenant.
Why copy-and-flip fails, structurally
- No fence. Nothing stops the old shard from accepting a write after the route changes. Routers are cached, connection pools are long-lived, and background workers hold stale assignments.
- Verification by row count. Counts match while content, ordering, sequences and sidecar state differ.
- No operation identity. If the migration script is re-run after a timeout, nothing tells the system whether it is the same move or a new one.
- No post-cutover reversibility. The rollback plan is "flip the route back," which silently discards every write made since the first flip.
Replication-based tooling addresses several of these. Vitess's MoveTables workflow is a good public reference for the shape of a safe cutover: per its documentation, switching write traffic temporarily makes the source read-only and waits for the target to catch up, refuses to switch if replication lag exceeds a configurable limit, and by default sets up reverse replication so the cutover can be reversed after writes begin on the target. That is vendor-documented behavior of one specific tool for table or keyspace moves. It is a useful model, not a guarantee that your own stack, or any tenant-level move you build, behaves the same way.
A Proposed Design: The Tenant Move as a Durable State Machine
Key point: give every move a durable identity bound to an immutable plan, claim it atomically, and advance it only through conditional updates on a routing record that carries an epoch.
The design below is our proposed framework. It is not an established proprietary method, and you should adapt the names and storage to your platform. It has three components: a move record, a routing record with an epoch, and a data-plane gate that enforces the epoch on every write.
1. The move record: identity, plan hash, atomic claim
A move is identified by (tenant_id, move_id). At approval time, the plan (tenant, source, target, scope manifest, cutover policy) is serialized and hashed. That hash is stored with the move and is immutable. If anyone resubmits the same move_id with a different plan, reject it. Do not silently merge it. A legitimate later operation, such as moving the tenant back next quarter, gets a new move_id and a new plan, and the database enforces that only one move per tenant can be active at a time.
-- Illustrative schema; names are hypothetical CREATE TABLE tenant_move ( tenant_id text NOT NULL, move_id text NOT NULL, plan_hash text NOT NULL, -- hash of the immutable approved plan state text NOT NULL, version bigint NOT NULL DEFAULT 0, claimed_by text, claim_expires timestamptz, PRIMARY KEY (tenant_id, move_id) ); -- Only one non-terminal move per tenant CREATE UNIQUE INDEX one_active_move_per_tenant ON tenant_move (tenant_id) WHERE state NOT IN ('COMPLETE', 'ROLLED_BACK'); -- Register: same key + same hash is a harmless repeat INSERT INTO tenant_move (tenant_id, move_id, plan_hash, state) VALUES ($1, $2, $3, 'PLANNED') ON CONFLICT (tenant_id, move_id) DO NOTHING; -- Then read the row back. If plan_hash differs from $3, reject: changed-payload key reuse. -- Atomic claim: exactly one worker wins UPDATE tenant_move SET claimed_by = $4, claim_expires = now() + interval '60 seconds' WHERE tenant_id = $1 AND move_id = $2 AND (claimed_by IS NULL OR claim_expires < now()) RETURNING version; -- zero rows: another worker holds the claimA claim is a lease, and a paused worker can wake up after its lease expired. So the claim alone is not enough. Every state transition must also be conditional on state and version, which is the same fencing idea we describe in our article on worker leases and fencing tokens. Martin Kleppmann's essay How to do distributed locking explains why a lock or lease without a monotonically increasing token cannot protect a downstream resource.
2. The routing record: epoch plus fence
The routing record answers one question: which location may accept writes for this tenant right now? It carries shard_id, epoch (incremented on every ownership change), write_state (OPEN or FENCED), fenced_by and last_move_id. All changes use target-side conditional updates, so two actors cannot both succeed:
-- Fence: only succeeds if the tenant is open at the epoch we planned against UPDATE tenant_routing SET write_state = 'FENCED', fenced_by = $move_id WHERE tenant_id = $tenant AND epoch = $expected_epoch AND write_state = 'OPEN' AND shard_id = $source; -- Flip: only succeeds if this same move holds the fence UPDATE tenant_routing SET shard_id = $target, epoch = epoch + 1, write_state = 'OPEN', last_move_id = $move_id WHERE tenant_id = $tenant AND epoch = $expected_epoch AND write_state = 'FENCED' AND fenced_by = $move_id AND shard_id = $source RETURNING epoch;This matters because "read the route, compare it, then write the new route" is not a compare-and-swap. Two workers can both read OPEN and both write. The condition has to be evaluated inside the same atomic statement on the store that owns the record. If your routing store cannot do conditional updates, you must disclose that limitation and serialize all tenant moves through a single coordinator, accepting the availability trade-off. Our article on lost updates and conditional writes covers the underlying mechanics.
3. The data-plane gate: why the routing table is not enough
Routers cache. Connection pools persist. A worker may have resolved the route ten minutes ago. If the only protection is the routing table, a stale caller can still write to the old shard after cutover. So each shard holds a small per-tenant gate row, and every tenant write checks it inside the same transaction:
-- Illustrative: inside every tenant write transaction on a shard SELECT 1 FROM tenant_gate WHERE tenant_id = $tenant AND epoch = $request_epoch AND writable = true FOR SHARE; -- No row returned: abort with a retriable 'route changed' error. -- Otherwise proceed with the actual write in the same transaction. -- Closing the gate during fence (needs an exclusive row lock, so it waits for -- in-flight writers and blocks new ones until it commits): UPDATE tenant_gate SET writable = false WHERE tenant_id = $tenant AND epoch = $expected_epoch;Share locks do not conflict with each other, so normal writers do not block one another, but the closing update waits for in-flight transactions and then excludes new ones. Measure the added per-write overhead in your own environment, and note that this specific mechanism is relational-database oriented. For stores without row locks, the equivalent is a conditional write that includes the epoch in the write's precondition, or a proxy that enforces the epoch before the request reaches storage.
The state machine
| State | Entry condition | Exit evidence |
|---|---|---|
| PLANNED | Plan hash recorded | Privacy, capacity and scope sign-off |
| COPYING | Claimed by one worker | Snapshot position recorded |
| CATCHING_UP | Bulk copy complete | Lag below threshold and trending down |
| VERIFYING | Lag within bound | Content comparison passes for every manifest item |
| FENCED | Conditional fence succeeded, gate closed | In-flight work drained, final lag is zero |
| FLIPPED | Conditional flip succeeded, epoch advanced | Target accepts writes; reverse replication healthy |
| SOAK | Writes reopened on target | Agreed soak period with no divergence |
| COMPLETE or ROLLED_BACK | Source retired or route restored | Source data erased under a verified process |
| UNKNOWN | A step's outcome could not be confirmed | Authoritative read resolves it, or a human decides |
Cutover Mechanics and the Tenant-Owned State People Forget
Key point: the cutover is a short, fenced sequence in which each step requires evidence. Anything that cannot be confirmed puts the move in UNKNOWN and keeps writes fenced.
The fenced cutover sequence
| Step | Action | Evidence required before next step |
|---|---|---|
| 1 | Conditional fence on routing record; close source gate | Conditional update returned one row; gate close committed |
| 2 | Drain in-flight transactions, jobs and outbox dispatches for this tenant | No open tenant transactions; job and outbox counters at zero or transferred |
| 3 | Apply final change set to target | Replication position on target equals source position at fence time |
| 4 | Final verification of manifest items | Content checks pass, not just counts |
| 5 | Ensure reverse replication target-to-source is established | Reverse stream reports healthy before any target write |
| 6 | Conditional flip: new shard, epoch + 1, open | Returned epoch matches expectation, or reconciliation confirms it |
| 7 | Open target gate with the new epoch; invalidate router caches | Test write and read through the real path succeed |
The write-pause window is steps 1 through 7. Its length depends on your drain time and final lag, which is why the go/no-go controls later in this article include a measured pause budget rather than a hope. Tell the tenant's integrations what to expect: clients should receive a retriable error with a clear route-changed signal, not a generic 500.
Handling an ambiguous timeout during the flip
The routing store may time out after committing. If the orchestrator simply retries, it can misread its own success as failure or collide with a rollback. The rule is the one from our guide to ambiguous timeouts in consequential API calls: reconcile against authoritative state first.
# Illustrative pseudo-code, not a specific library API def commit_flip(tenant, move): try: rows = routing.conditional_flip(tenant, move.id, move.source, move.target, move.expected_epoch) if rows == 1: return 'COMMITTED' except Timeout: pass # outcome unknown: do NOT retry blindly cur = routing.read_authoritative(tenant) # strong read from the owning store if cur.last_move_id == move.id and cur.shard_id == move.target: return 'COMMITTED' # the earlier attempt did apply if (cur.shard_id == move.source and cur.fenced_by == move.id and cur.epoch == move.expected_epoch): return 'NOT_APPLIED' # safe to re-issue the same conditional update return 'UNKNOWN' # keep tenant fenced; escalate to a humanThe terminology matters. UNKNOWN means the completion of the step could not be confirmed. It is not success and it is not verified failure. Dashboards and runbooks should show it as its own state, and the tenant stays fenced until it is resolved.
State teams forget, and how to treat it
- Idempotency records are tenant data. If a client sent a request with an idempotency key just before the fence and retries after the flip, the target must know about that key and its stored result. Move these records with the tenant, keyed per tenant, and keep their payload fingerprints so a changed payload under the same key is still rejected. Our idempotency framework covers key design.
- Identifier generation. PostgreSQL's logical replication documentation lists restrictions, including that sequence data is not replicated. If the tenant uses sequence-generated IDs, advance the target sequences past the source values with headroom, or move to tenant-safe generated IDs, before reopening writes. Verify this against the version of your database you actually run.
- Outbox and webhooks. Pending outbox rows must either be drained and acknowledged before the fence or moved with their delivery state intact. Acknowledgment should mean the receiving system confirmed, not that a message was handed to a queue. Review durable receiver design for the consumer side of this boundary.
- Queued and scheduled jobs. Jobs resolved to the old shard should fail the gate check and be rescheduled, rather than run against stale state. Make sure the job payload carries
tenant_idin a place the queue can filter on, so you can pause only that tenant's work. - Object storage, search, caches. Declare in the plan manifest whether each is copied, re-pointed, rebuilt or ignored. "Rebuilt" needs a completeness check and an expected duration. "Ignored" needs a named owner who accepted the risk.
Privacy and identifier handling
A move duplicates personal data into a second location, even temporarily. Treat the plan as a data-processing event: a named privacy owner confirms the target location is permitted, the copy path is encrypted in transit, and the source data has a defined, verified erasure step after the soak period. See our verified erasure workflow for how to prove deletion across stores. Also remember that identifiers can themselves be sensitive: tenant IDs, shard names and move IDs often appear in logs, metrics labels and tickets, and may reveal customer relationships. Pseudonymize them in telemetry where your policy requires, and keep the mapping in a restricted system. Whether any of this satisfies a specific legal obligation depends on your jurisdiction and contracts. This article does not constitute legal advice, so confirm requirements with your counsel.
Why This Fails in the Real World
Key point: capable teams still fail here because the failures sit between systems and owners. No single review covers the whole tenant.
None of these are exotic. Each is a plausible pattern that emerges when an experienced team treats a tenant move as a one-off script. These are illustrative composites of common failure modes, not reports about any specific customer.
Pattern 1: The stale route that writes to the old shard
The team updates the routing table and sees traffic shift. An hour later a support ticket reports missing edits. A subset of application instances cached the old route with a long time-to-live, and one background worker pool never refreshed. Both kept writing to the source shard, which nobody was watching because it was "retired." Why smart teams miss it: the flip was verified at the router, not at the data plane. There was no per-write epoch check, so the system had no way to say no to a stale caller. The ownership gap was architectural: routing belonged to one team, shard operations to another.
Pattern 2: Verified by counts, broken by sidecars
The migration passes a row-count comparison for every table in the manifest. After the flip, a client retries a payment-related request with the same idempotency key, and it is processed twice because the idempotency table was never in the manifest. A separate part of the system re-sends a batch of webhooks because outbox state stayed behind. Why smart teams miss it: the manifest was built from the domain schema, and cross-cutting plumbing belongs to platform libraries that no domain engineer reviewed. The process had no step that asks "what else knows this tenant's ID?"
Pattern 3: The blind retry of an ambiguous timeout
The orchestrator times out waiting on the routing store and retries the whole cutover. The first attempt had in fact committed. The second attempt fences the tenant again against an outdated expectation, and a concurrent operator, seeing the failure, starts a rollback. Now two procedures are racing over one tenant. Why smart teams miss it: the runbook treated timeouts as failures, the move had no durable identity to recognize "this already happened," and nothing prevented two actors from operating on the same tenant.
Pattern 4: Rollback that destroys the evidence
The post-cutover monitoring shows elevated errors. The documented rollback is "point the route back to the source." It works, and 40 minutes of target writes vanish from the tenant's view. Why smart teams miss it: reversibility was assessed at design time as a routing property, not as a data property. Without reverse replication or a replayable change log, rollback after reopening writes is a data-loss decision that should be made explicitly by a named owner.
Pattern 5: The hot tenant that never catches up
The tenants selected for moving are exactly the ones with high write rates. In an illustrative case, a tenant produces 2,000 row changes per second at peak while the apply pipeline sustains 1,500. Lag grows by roughly 500 changes per second and the move never converges. The team keeps extending the window. Why smart teams miss it: capacity was planned from average tenants and from copy throughput, not from the target tenant's peak change rate versus apply rate.
| Failure | Systemic cause | Control that would have blocked it |
|---|---|---|
| Stale route writes | No data-plane enforcement; split ownership | Epoch gate on every write; post-flip source write alarm |
| Sidecar state left behind | Manifest from domain schema only | Cross-system inventory by tenant ID; content verification |
| Blind retry race | No durable operation identity or single-operator rule | Plan hash, atomic claim, conditional transitions, reconcile-first |
| Destructive rollback | Reversibility treated as routing only | Reverse replication healthy before reopening writes |
| Lag never converges | Average-based capacity planning | Measured apply rate above peak change rate before starting |
Trade-offs, Constraints, and Choosing an Approach by Persona
Key point: the fenced, replication-based design buys a short pause and a reversible cutover. You pay in engineering effort, per-write overhead and operational discipline.
Option comparison
The table below compares four options qualitatively. The ratings are our engineering judgment for typical conditions, not benchmark results; your data volume, write rate and tooling will shift them.
| Dimension | A. Maintenance window | B. Copy then flip | C. Dual write | D. Replication with fenced cutover (proposed design) |
|---|---|---|---|---|
| Cost to build | Low | Low | High: every write path changes | Medium to high: routing, gate, verification |
| Write pause | Long, scales with tenant size | Short but unsafe | Often none | Short and bounded by drain time and final lag |
| Risk of lost or split writes | Low if disciplined | High | Medium: partial failures diverge stores | Low when the gate is enforced |
| Rollback after new writes | Poor | None | Possible if the old store stays authoritative | Good with reverse replication |
| Scales to many moves | Poorly | Poorly: ad hoc scripts | Poorly: per-feature changes | Well: reusable state machine |
| Best fit | Small tenants with agreed downtime | Nothing consequential | Data-model migrations inside one store | Large or busy tenants, recurring rebalancing |
Constraints to state honestly
- The gate adds per-write cost. A lock or conditional check on every tenant write is cheap per call but not free, and it concentrates contention on a tenant-scoped row. Measure it with a realistic write mix.
- Replication tooling has limits. Logical replication and CDC have documented restrictions (sequences, schema changes during replication, certain data types, large objects depending on the database). Check the documentation for your exact engine and version.
- Schema changes during a move are a hazard. Freeze tenant-affecting schema changes while a move is active, or coordinate them, as described in our guide to expand and contract schema changes.
- Soak periods cost money. Keeping the source and reverse replication alive doubles storage and operational load for the soak duration. Shorten it only with evidence, not for budget reasons alone.
- Cell-based platforms change the unit. If your tenants live in cells, the move target is a whole cell with its own dependencies, and blast radius, quotas and routing differ. Our cell-based architecture playbook explains those boundaries.
Recommendation by persona
| Persona | Primary concern | Recommendation |
|---|---|---|
| Tech lead, early-stage platform with few large tenants | Shipping safely without a big platform build | Option A for small tenants; build the routing record and move record first, then add the gate before moving your first large tenant |
| Solution architect, growing multi-tenant platform | Repeatable rebalancing | Option D as the standard path; invest in the manifest, verification and reverse replication |
| DevOps or SRE lead | Operational safety and runbooks | Insist on UNKNOWN as a first-class state, a single-operator rule per tenant, and rehearsed rollback |
| CTO or engineering manager | Customer risk and cost | Fund the controls before the first high-value move; require named owners for privacy, data and rollback decisions |
Go/No-Go Controls, a Lower-Risk Rollout, and Tooling Context
Key point: use a checklist where every control is mandatory. A move with nine passing controls and one failing control is a no-go, and a high pass rate does not certify readiness.
Mandatory go/no-go controls (all required)
This is not a score. There is no total that means "ready." Each item is a gate, and each needs named evidence and an accountable owner. If any one fails, do not cut over.
| # | Control | Evidence |
|---|---|---|
| 1 | Plan hash recorded and immutable; single active move for the tenant | Move record; unique-index enforcement |
| 2 | Manifest covers every store that holds tenant state, each marked copied, re-pointed, rebuilt or accepted-ignored by a named owner | Signed manifest from a cross-system inventory by tenant ID |
| 3 | Privacy owner approved target location, transfer path and source erasure plan | Recorded approval; erasure task scheduled |
| 4 | Apply rate demonstrably exceeds the tenant's peak change rate | Measured rates from a rehearsal or production observation |
| 5 | Replication lag within the agreed bound and not growing | Lag trend over a stated observation window |
| 6 | Content verification passes, including idempotency records and outbox state | Verification report, not row counts alone |
| 7 | Epoch gate enforced on all write paths, including background workers | Test showing a stale-epoch write is rejected on every path |
| 8 | Reverse replication ready and tested for lag and health | Rehearsed rollback with target-originated writes |
| 9 | Target identifier generation safely past source values | Sequence or ID check recorded |
| 10 | Pause budget agreed with the customer-facing owner; fence-to-reopen time within it in rehearsal | Rehearsal timings measured with your own tooling |
| 11 | Reconcile-first handling implemented for every step with an external call; UNKNOWN visible in the runbook and dashboard | Fault-injection test with injected timeouts after commit |
| 12 | One named incident owner, with authority to decide rollback versus roll-forward | On-call roster for the move window |
A lower-risk rollout path
- Rehearse on synthetic or internal tenants. Include fault injection: kill the orchestrator mid-copy, time out the flip after commit, pause a worker past its lease, and serve a stale route.
- Move small, low-risk tenants first. Use them to calibrate pause time, lag behavior and verification runtime against your own measurements.
- Shadow-verify before trusting. Borrowing from the pattern Stripe describes, compare reads from old and new locations and alert on differences before serving from the new one.
- Move one tenant at a time, one operator at a time. Concurrency across tenants is fine once the controls are proven, but never two operations on the same tenant.
- Soak, then erase. Keep the source and reverse path through the agreed soak period, then run a verified erasure and record it.
Tooling context and what stays constant
Tooling in this area keeps improving. Database-native replication, managed migration services and workflow engines such as Vitess's VReplication make bulk copy, change streaming, lag checks and reverse replication far easier than they used to be. Treat vendor capability descriptions as vendor statements, and validate each one in your own environment, especially for tenant-level moves, since several tools are designed around tables, keyspaces or whole shards rather than a single tenant's rows across many stores. What does not change with tooling: exactly one writer per tenant at every instant, evidence before each irreversible step, conditional state changes, reconcile before retry, and a rollback path that survives new writes. Those are properties of your design, not of any product.
Planning your first large tenant move?
Routing, fencing, verification and rollback are easier to get right when reviewed before the first move, not after the first incident.
Talk with Developers.dev engineers about reviewing your migration design and building the tooling around it.
Contact UsIf you want a second pair of eyes on a platform design, our platform engineering services and cloud-native development teams work with architects on exactly this class of problem. Our article on per-tenant restore is a useful companion for the recovery side of the same boundary.
Conclusion: Five Actions Before You Move Your Next Tenant
A tenant move succeeds or fails on single-writer discipline, not on copy speed. If you take only a few steps from this article, take these:
- Inventory by tenant ID across every system. Build the manifest from what knows the tenant, not from the domain schema. Assign an owner to each store, including idempotency, outbox, jobs, object storage and secrets.
- Give every move a durable identity. Hash the approved plan, reject changed-plan reuse, allow only one active move per tenant, and advance state with conditional updates on the store that owns the record.
- Enforce the epoch at the data plane. Prove with a test that a stale-epoch write is rejected on every path, including background workers and long-lived connections.
- Reconcile before retrying anything ambiguous. Treat UNKNOWN as its own state, keep the tenant fenced, and resolve it from authoritative state.
- Make rollback a tested capability. Do not reopen writes on the target until reverse replication is healthy, and rehearse the rollback with target-originated writes.
This design is a proposal for you to adapt and validate. Test it against your own storage engines, measure it with your own tenants, and have counsel confirm any residency or privacy obligations that apply to your contracts.
About the Developers.dev engineering team
Developers.dev is an offshore software development and staff augmentation company founded in 2007, with 1000+ in-house IT professionals delivering cloud, DevOps, AI and platform engineering work for clients in the USA, EMEA and Australia. The company lists CMMI Level 5, ISO 27001 and SOC 2 among its accreditations; those describe company-level processes and do not certify any specific design in this article. This article was reviewed by the Developers.dev Expert Team.
Frequently Asked Questions
What is live tenant migration between shards?
It is the process of moving one tenant's data and associated state from one shard or cell to another while the application stays available. A safe version copies data, streams ongoing changes, briefly fences writes, verifies the target, flips an epoch-based route, and keeps a tested rollback path.
Why is a routing table update not enough to cut over a tenant?
Routers, connection pools and background workers can hold stale routes and keep writing to the old shard. You also need a data-plane check, such as a per-tenant gate that validates an epoch inside every write transaction, so the old location can reject writes it no longer owns.
How do I handle a timeout during the cutover flip?
Do not retry blindly. Perform a strong read of the authoritative routing record and compare the move ID, shard and epoch. If the flip applied, treat it as committed. If it clearly did not, re-issue the same conditional update. If you cannot tell, mark the move UNKNOWN, keep the tenant fenced and escalate.
- UNKNOWN means completion could not be confirmed.
- It is neither success nor verified failure.
Is it safe to roll back after the target has accepted writes?
Only if you have a mechanism that carries target-originated writes back to the source, such as reverse replication or a replayable change log, and you have tested it. Without that, pointing the route back discards the writes made since cutover, and that should be an explicit, owned decision.
What tenant state do teams most often forget to migrate?
Idempotency-key records, outbox and inbox rows, queued or scheduled jobs, object storage, search indexes, secrets and webhook configurations, and audit history. Build the manifest by searching every system for the tenant ID, not just the domain tables.
What happens to database sequences during a tenant move?
It depends on your database and replication method. PostgreSQL's documentation lists that sequence data is not replicated by logical replication, so you must advance target sequences past source values with headroom, or use tenant-safe generated identifiers. Check the documentation for your exact engine and version.
How long will the write pause be?
It depends on in-flight transaction drain time, final replication lag, verification time and the speed of your route and cache invalidation. Measure these in rehearsals with your own tooling and tenant profiles, then agree a pause budget with the customer-facing owner before the real move. Any numbers in this article are illustrative only.
Do moves across regions raise privacy concerns?
Yes, they can. A move changes where personal data is stored and creates a temporary second copy. Have a named privacy owner approve the target location and transfer path, plan verified erasure of the source, and keep identifiers such as tenant IDs out of telemetry where your policy requires. Legal obligations vary, so confirm them with qualified counsel.
Can I use Vitess MoveTables or a similar tool for tenant moves?
Vitess documents MoveTables as a workflow for moving tables between keyspaces, with lag checks and optional reverse replication, but it is designed around tables and keyspaces rather than a single tenant's rows across multiple stores. Evaluate whether your sharding model maps onto it, and validate behavior in your environment. Treat tool documentation as vendor statements, not guarantees for your design.
How do I decide whether a tenant is ready to be moved?
Use the mandatory go/no-go controls: every one must pass with evidence. Do not add them into a score. A single failed control, such as an apply rate lower than the tenant's peak change rate, is enough to postpone the move.
Moving a tenant should not feel like a coin toss.
If your platform has outgrown copy-and-flip, a short design review can surface missing fences, forgotten state and untested rollbacks before they reach a customer.
Work with Developers.dev engineers on tenant routing, migration tooling and safe cutover design for your multi-tenant platform.
Contact UsPlatform Engineering Services
This guide is designed for engineering leaders who want to plan a practical implementation. Use the related Developers.dev path to compare delivery options, implementation fit, risk, and practical next steps.
Reviewed by the Experts team
This guide is reviewed for clarity, technical and operational relevance, service alignment, and a useful next step. Verified by our SEO team for clear search presentation.
Reviewed by the Experts team. Verified by our SEO team. Validate legal, security, data, budget, and operational requirements with the relevant stakeholders before rollout.

