How Database Sharding Works

How Database Sharding Works

How to split a database when one machine can't keep up anymore

What you'll learn

  • What shards and shard keys are
  • Range sharding vs hash sharding
  • Good keys, bad keys, and hot shards
  • What sharding costs, and what to try first

In this video, we'll look at what to do when your database grows to 5 terabytes and one machine can't keep up with the writes. We'll cover how sharding splits data across servers, what a shard key is, range sharding vs hash sharding, and how a bad shard key leads to a hot shard.

We'll also look at what sharding costs you: slow or impossible joins across shards, hard cross-shard transactions, and moving data when you add shards.

By the end, you'll understand how sharding works, its trade-offs, and why most teams try indexes, caching, read replicas, and bigger machines first.

More videos

32 short explainers so far, with more on the way

View all videos

Join the Community

roadmap.sh is among the top 10 most starred projects on GitHub and is visited by hundreds of thousands of developers every month.

Top 10 out of 28M!

371K

GitHub Stars

Star us on GitHub
Help us reach #1

+90kevery month

+3.2M

Registered Users

Register yourself
Commit to your growth

+2kevery month

52K

Discord Members

Join on Discord
Join the community

RoadmapsGuidesFAQsYouTube

roadmap.shby@nilbuild

Community created roadmaps, best practices, projects, articles, resources and journeys to help you choose your path and grow in your career.

© roadmap.sh·Terms·Privacy·

ThewNewStack

The top DevOps resource for Kubernetes, cloud-native computing, and large-scale development and deployment.