Skip to main content
So, which one should you use?
  • If you already run MySQL, adopt Vitess for sharding and topology management.
  • If you already run Postgres, adopt Citus to distribute Postgres across nodes.
  • If you’re starting fresh on AWS and your access pattern is mostly single-key lookups, consider DynamoDB.
  • For extremely heavy, distributed write workloads, evaluate Cassandra.
  • For document-oriented collections that naturally migrate between shards, use MongoDB.
A dark infographic titled "Which one?" showing five cards that pair use-cases with database choices: MySQL→Vitess, Postgres→Citus, Single-key lookups→DynamoDB, Heavy writes→Cassandra, and Documents→MongoDB. Each card includes icons/logos and a short label.
Chirp stores relational tables (rows and columns), so the least disruptive path is to keep a relational database and introduce a sharding layer: Vitess for MySQL or Citus for Postgres. Both solutions handle routing, resharding, and co-locating related records — responsibilities we previously implemented in application logic. That means our existing user ID key and most table schemas can remain largely unchanged during the migration.
Sharding-aware databases automate routing and data movement, but some responsibilities still fall to your application.
Four responsibilities remain with your application:
  1. You must choose the shard key (for example, user_id) — the database won’t pick it for you.
  2. You must keep queries targeted. Queries that include the shard key (e.g., “get Chris’s profile by user ID”) go to a single shard; queries that omit it (e.g., “everyone who joined between two dates”) become scatter-gathers and contact many shards.
  3. You must mitigate leader hotspots. Hot shards still require application techniques like salting keys, request routing, or caching to avoid single-node bottlenecks.
  4. You must handle denormalization and updates. If Leo changes his name, your application must find and update every denormalized copy.
In short: sharding-aware databases take care of routing and data movement; choosing the shard key and adapting your application remains your job. When should you shard at all? Short answer: later than you think. Sharding is an invasive, long-lived change. Why sharding is painful:
  • It changes the shape of every query and many tables permanently.
  • The shard key is especially hard to change later — changing it typically requires moving nearly every row to different shards.
  • Migration and application changes are complex and error-prone if not planned and automated carefully.
Before sharding, try cheaper, lower-risk fixes first:
  • Move to a larger instance size.
  • Add read replicas to scale reads.
  • Introduce a cache (e.g., Redis, CDN) for hot access patterns like popular posts.
If those don’t resolve the problem, three signals typically indicate it’s time to shard:
A stylized diagram titled "When should you shard at all?" showing an app, a cache, a large primary database cylinder with two replica cylinders, and memory bars. The right side lists three reasons to shard — "writes hit the ceiling", "too big to back up", and a highlighted "won't fit in memory."
If the problem is only slow reads, prefer caches and replicas — they reduce read pressure on the primary without splitting tables. In this lesson, we consider sharding primarily when writes have hit the ceiling; that is the most defensible reason to shard.
Sharding permanently changes your system’s architecture. Delay it as long as possible. When you do shard, spend most of your effort choosing the correct shard key and planning/automating data migration and the required application changes.

Watch Video