EtsyElla Yarmo-GrayProblem & solution
Migrating Etsy’s database sharding to Vitess
Summary
Etsy migrated its long-running MySQL shard management to Vitess vindexes after an architecture spanning about 1,000 tables and shards, 425 TB of data, and roughly 1.7 million requests per second. The legacy ORM used a single index database to map records to shards, creating a scaling bottleneck and single point of failure. To avoid moving existing data, engineers built custom SQLite lookup and hybrid vindexes, changed new shard assignments to match Vitess’s hash algorithm, and introduced routing incrementally table by table with traffic ramps, rollback, and query compatibility testing. After five years, about 2,500 pull requests, and 6,000 queries, the migration removed the index database dependency, made scaling operations take days rather than months, simplified developer access, and kept database performance largely unchanged without a mass data migration.
Context
Etsy’s sharded MySQL architecture had grown to about 1,000 tables and shards, 425 TB of data, and roughly 1.7 million requests per second. Horizontal scaling was manual and took months, the unsharded index database was a single point of failure, and developers had to manage shard details when accessing data.
Approach / What changed
Etsy introduced Vitess as an abstraction layer, then created custom vindexes to preserve existing shard mappings without moving data. A SQLite lookup vindex handled legacy mappings, a hash vindex handled newly assigned IDs, and a hybrid vindex selected between them using a threshold. Vindexes were enabled incrementally by table, with traffic ramping, compatibility testing, monitoring, and rollback.
Takeaways
Custom SQLite and hybrid vindexes preserved Etsy’s random legacy shard mappings while allowing new IDs to use the Vitess hash algorithm.
Etsy disabled scatter queries by default because an unintentionally broad query could be sent to all 1,000 shards; approved scatter queries nevertheless reduced one model’s query time from about 2 seconds to 20 milliseconds.
The completed migration removed the index database as a single point of failure, reduced scaling operations from months to days, and avoided a massive data migration while keeping performance largely unchanged.
Source and freshness
- Source
- etsy.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.