Resharding Strategies: Stop-the-World vs Online
You'll learn: The two main approaches to resharding data—one that pauses operations briefly, and one that keeps your database running continuously.
When you need to reshard (redistribute data across new shards), you face a critical choice: should you pause everything briefly, or keep the system running while migrating data?
Stop-the-World Resharding
In stop-the-world resharding, you:
- Put the database into maintenance mode (block all writes, potentially reads)
- Migrate data to the new shard layout
- Update routing tables
- Resume operations
Analogy: Like closing a store temporarily to reorganize the shelves—simple, but customers can't shop during the remodel.
Pros: Simpler to implement, no data inconsistency risks, guaranteed success Cons: Downtime—unacceptable for 24/7 services
Online (Zero-Downtime) Resharding
Online resharding migrates data while the system continues serving traffic:
- Set up new shards alongside old ones
- Start copying data incrementally
- Dual-write to both old and new locations during transition
- Switch reads to new shards once caught up
- Retire old shards
Analogy: Like reorganizing a store while it's open—customers keep shopping, but you're carefully moving inventory section by section.
Pros: No downtime, users never affected Cons: Complex implementation, requires coordination between old/new shards, risk of bugs during dual-write phase
Choosing Your Approach
Stop-the-world works for small databases or when you have maintenance windows. Online migration is necessary for large-scale, always-on systems where even minutes of downtime costs millions.
Key Takeaway: Stop-the-world resharding is simple but requires downtime; online resharding keeps your system running but demands careful coordination and dual-write logic during the migration.