Real-World Case Studies: Database Partitioning and Sharding

โœ… Source-checked. Each deep dive names its source, and we kept only what that source says. Found an error, or something the source doesn't support? Report it on the tracking issue.

Three ways to split data: Bigtable splits sorted key ranges automatically, Uber's Schemaless hashes rows into a fixed set of shards, and Discord picks a composite partition key that bounds partition size.


๐Ÿข Deep Dive 1: Google Bigtable, Range Partitioning with Automatic Splits

Source: Bigtable: A Distributed Storage System for Structured Data (Chang et al., OSDI 2006). Everything in this section comes from the paper.


๐Ÿš™ Deep Dive 2: Uber Schemaless, Hashing into a Fixed Set of Shards

Sources: Jakob Holdgaard Thomsen, "Designing Schemaless, Uber Engineering's Scalable Datastore Using MySQL" and "The Architecture of Schemaless" (January 2016). Everything in this section comes from those posts.


๐Ÿ’ฌ Deep Dive 3: Discord, a Partition Key that Bounds Partition Size

Sources: How Discord Stores Billions of Messages (Stanislav Vishnevskiy, January 2017); How Discord Stores Trillions of Messages (Bo Ingram, March 2023). Everything in this section comes from those posts.

โ„น๏ธ An earlier version of this page said Schemaless picks shards with MurmurHash3 and builds indexes from MySQL binlogs via Kafka, said Bigtable holds "exabytes", and said reversed URLs prevent hotspots. The sources don't support any of that, so we removed it.


๐ŸŽฏ System Design Interview Takeaways

  1. Range vs. hash partitioning. Range partitioning (Bigtable) keeps neighbouring keys together for scans. Hashing into shards (Schemaless) spreads load evenly but makes range scans hit many shards.
  2. Fix the shard count, move the shards. Schemaless maps rows to a fixed number of shards and remaps shards to machines as it grows, so a row's shard never changes.
  3. Design the partition key around partition size. Discord added a time bucket to its key so no partition grows without bound.
  4. Plan for hot keys. Even a good key can't stop many readers hitting one partition. Coalescing duplicate requests, as Discord does, is one answer.