---
title: "Migrating Etsy’s database sharding to Vitess"
description: "Etsy moved shard routing for its ~1,000-table, ~1,000-shard, 425 TB MySQL cluster (1.7M requests/sec) from an ORM that looked up random shard mappings in a single index database to Vitess vindexes, without moving any data."
url: "https://swe.quest/articles/migrating-etsy-s-database-sharding-to-vitess-c6bef1d09f2cd679"
canonical: "https://www.etsy.com/codeascraft/migrating-etsyas-database-sharding-to-vitess"
source: "Etsy Code as Craft"
published: "2026-03-19"
difficulty: "medium"
kind: "Case study"
reading_minutes: 9
tags: ["mysql","distributed-databases","refactoring","sqlite","deployment"]
---

# Migrating Etsy’s database sharding to Vitess

A post on [Etsy Code as Craft](https://swe.quest/sources/etsy.md), published 2026-03-19, 9 min read, Case study. Original: [https://www.etsy.com/codeascraft/migrating-etsyas-database-sharding-to-vitess](https://www.etsy.com/codeascraft/migrating-etsyas-database-sharding-to-vitess)

## Summary

Etsy moved shard routing for its ~1,000-table, ~1,000-shard, 425 TB MySQL cluster (1.7M requests/sec) from an ORM that looked up random shard mappings in a single index database to Vitess vindexes, without moving any data. The ORM's shard assignment was switched to match Vitess's hash vindex, and legacy mappings were frozen into a read-only SQLite file copied onto each Vitess server. A custom hybrid vindex picks SQLite lookup or hash based on an id threshold. Tables were ramped incrementally through the experimentation framework with instant rollback, though 27 transaction-coupled models carrying a third of traffic had to move together to preserve per-connection atomicity. The five-year effort removed a single point of failure, cut re-sharding from months to days, and enabled opt-in scatter queries; one query dropped from ~2 s to ~20 ms, and bulk primary-key lookups needed far fewer queries.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [MySQL](https://swe.quest/tags/mysql.md) (Data & databases)
- [Distributed databases](https://swe.quest/tags/distributed-databases.md) (Data & databases)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)
- [SQLite](https://swe.quest/tags/sqlite.md) (Data & databases)
- [Deployment](https://swe.quest/tags/deployment.md) (Reliability & operations)

## Prerequisites

- MySQL sharding ([easy posts on MySQL](https://swe.quest/tags/mysql.md?difficulty=easy))
- ORMs
- database transactions ([easy posts on Databases](https://swe.quest/tags/databases.md?difficulty=easy))

## Keywords

Vitess, vindexes, MySQL, SQLite, Etsy ORM

## Related posts

- [Horizontally scaling the Rails backend of Shop app with Vitess](https://swe.quest/articles/horizontally-scaling-the-rails-backend-of-shop-app-with-vitess-03c7b2da20f98ec3.md): Shopify Engineering · 2024-01-17 · Medium · 27 min read · MySQL, Distributed databases, Ruby, Scaling, Schema migrations
  Shop app outgrew a single MySQL database despite federating tables across databases, so the team moved its Rails backend to Vitess, sharding user-owned tables by user\_id into a "users" keyspace and keeping the rest in an unsharded "global" keyspace.
- [Partitioning GitHub’s relational databases to handle scale](https://swe.quest/articles/partitioning-github-s-relational-databases-to-handle-scale-7b5ea75acfc088c0.md): GitHub Engineering · 2021-09-27 · Medium · 9 min read · MySQL, Distributed databases, Scaling, Schema migrations, Ruby
  GitHub split its monolithic \`mysql1\` MySQL cluster by first virtually partitioning tables into schema domains (declared in YAML) and enforcing boundaries with query and transaction linters, then physically moving domains to new clusters via Vitess vertical sharding or a custom ProxySQL/GTID-based write-cutover script.
- [Shard Balancing: Moving Shops Confidently with Zero-Downtime at Terabyte-scale](https://swe.quest/articles/shard-balancing-moving-shops-confidently-with-zero-downtime-at-terabyte-scale-76a6177fa357eea4.md): Shopify Engineering · 2021-09-24 · Medium · 13 min read · MySQL, Distributed databases, Schema migrations, Scaling
  Shopify rebalances its MySQL shards by moving individual shops between pods online, with downtime confined to a brief cutover.
- [Handling hot shards](https://swe.quest/articles/handling-hot-shards-713450434ac73606.md): PlanetScale · 2026-09-28 · Medium · 7 min read · Distributed databases, PostgreSQL, Scaling, Multi-tenancy
  When a shard key like tenant\_id stops matching reality because a few whale tenants dominate load or cross-tenant queries appear, Neki (PlanetScale's sharded Postgres from the Vitess maintainers) offers three escalating fixes: vertically scale the hot shard with its own configuration profile, isolate the whale by narrowing hashed key ranges in the declarative data topology, or reshard specific tables by a better key.
- [How Figma’s databases team lived to tell the scale](https://swe.quest/articles/how-figma-s-databases-team-lived-to-tell-the-scale-5117114294b188fe.md): Figma · 2024-03-14 · Medium · 19 min read · PostgreSQL, Distributed databases, Scaling, Query engines
  Figma horizontally sharded its RDS Postgres stack after vertical partitioning ran out of room.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
