Data

System Design: Database Sharding

Learn database sharding concepts through hands-on labs! Explore shard keys, hotspots, resharding, and consistent hashing through real-world scenarios.
Aditya Chauhan
Aditya Chauhan
Technical PM and Learning Designer
Kripa Sarvaiya
Kripa Sarvaiya
DevOps Engineer | Cloud Native Enthusiast
System Design: Database Sharding
Play Button
Fill this form to get a notification when course is released.
book
6
Lessons
book
Challenges
Article icon
20
Topics

What you’ll learn

Our students work at..

Description

This beginner-friendly course on database sharding focuses on understanding why sharding is needed, how it works, and when not to shard at all, rather than memorizing terms.

The whole course follows Chirp, a small social app where people post short messages, follow each other, and like posts. Chirp starts on a single database with a few hundred users and grows to 40 million users and 8 TB of data. Every lesson starts with something breaking: a profile that used to open in 30 milliseconds now takes 3 seconds, writes pile up during a big event, a pop star with 40 million followers overloads one machine, or adding a single machine forces 80% of the data to move. Then you fix it and look at the new problem the fix creates.

Across seven lessons, you learn about reads and writes, replicas, and why adding replicas can’t raise the write limit. You also learn what a shard is, how to choose a shard key, scatter-gather and co-location, hashing, and the four ways to split data. After that, you explore the routing layer, hotspots and the celebrity problem, resharding, consistent hashing and virtual nodes, fixed buckets, and joins across shards. Then you see how real databases such as Vitess, Citus, Cassandra, DynamoDB, and MongoDB handle sharding for you. The course ends with the three signals that tell you it's actually time to shard. Everything is explained in plain language, with a hand-drawn diagram for every step.

This course also includes four hands-on labs on a real Citus cluster. In them, you split a users table across machines; test different shard keys to see which ones spread the data evenly; overload one shard with a pop star's traffic and fix it; and finally, add a new machine, move data onto it, and join tables that live on different shards. Every lab comes with hints and full solutions.

If you know what a database table is and can use a terminal, you're ready to start.

Read More

What our students say

Aditya Chauhan

About the instructor

Aditya is a Technical PM and Learning Designer at KodeKloud, he has led more than 50+ courses. With a background in computer science and a lifelong love for teaching, he has always found something deeply rewarding in sharing what he knows with others. Whatever the topic, he loves finding a way to break it down into simple concepts, so learning feels less like a struggle and more like a series of small, satisfying moments.

‍

Kripa Sarvaiya

About the instructor

Kripa specializes in building and maintaining reliable and efficient labs for course releases. She also manages Kubernetes version upgrades and ensures ongoing maintenance of courses post-release. Skilled in cloud platforms, scripting, and system monitoring, Kripa collaborates closely with development and operations teams to optimize performance and deliver high-quality lab environments.

No items found.

Why One Database Isn't Enough

lock
3
Topics
Lesson Content

Module Content

Course Introduction00:29
When One Database Starts to Break06:36
How to Reach Out to KodeKloud and Engage with the Community

Sharding Fundamentals

lock
3
Topics
Lesson Content

Module Content

What Sharding Actually Is03:11
Split the Users Table00:27
Lab: What Sharding Actually Is, Distribute Chirp Across a Citus Cluster

Shard Keys and Partitioning

lock
4
Topics
Lesson Content

Module Content

Choosing the Shard Key09:09
Hashing, and the Four Ways to Split09:17
Pick a Shard Key00:18
Lab: Choosing the Shard Key, and the Four Ways to Split

Routing and Hot Shards

lock
3
Topics
Lesson Content

Module Content

Routing, and the Celebrity Problem12:19
Fix a Hot Shard00:16
Lab: Routing, and the Celebrity Problem

Resharding and Cross-Shard Queries

lock
5
Topics
Lesson Content

Module Content

Resharding, and Consistent Hashing06:58
Resharding With Fixed Buckets06:15
Sharding Challenges, Joins Across Shards03:58
Grow the Cluster00:18
Lab: Resharding Without Downtime, and Joins Across Shards

Resharding and Cross-Shard Queries

lock
2
Topics
Lesson Content

Module Content

How Real Databases Shard for You07:24
Which One, and When to Shard at All03:27

Frequently Asked Questions

Who are KodeKloud courses for?

KodeKloud courses are designed for learners at different skill levels, from beginners to experienced IT professionals looking to develop or strengthen their technical skills.

Do KodeKloud courses include hands-on practice?

Yes. Many KodeKloud courses include hands-on labs and practical exercises that let you apply what you learn in real-world environments.

Do I need any prior experience to take a KodeKloud course?

Prerequisites vary by course. Each course page provides information about the recommended knowledge or experience you may need before starting.

Can I learn at my own pace?

Yes. KodeKloud courses are designed for self paced learning, so you can learn according to your schedule and revisit lessons and practice activities as needed.

Can I access KodeKloud courses on mobile devices?

Yes. KodeKloud can be accessed through supported web browsers and mobile devices, allowing you to learn from different devices.

Do KodeKloud courses provide certificates?

Certificate availability depends on the course and your KodeKloud plan. Check the individual course page or your account for the applicable certificate details.

How long does it take to complete a KodeKloud course?

Course completion time varies depending on the course length, your prior experience, and how much time you spend on hands-on practice.

Can I practice while taking the course?

Yes. Courses that include hands-on labs allow you to practice concepts as you progress through the lessons.

 How do I start learning a KodeKloud course?

Choose a course that matches your learning goals, review its requirements and curriculum, and select the available subscription option to start learning.

System Design: Database Sharding
Play Button
System Design: Database Sharding
Fill this form to get a notification when course is released.
This course comes with hands-on cloud labs
6
Modules
Lessons
20
Lessons
Course Certificate
01.17
Hours of Video
Hours of Labs
Story Format
Videos
Case Studies
Demo
Labs
Cloud Labs
Mock exams
Quizzes
Discord Community Support
Community support
English
Closed Captions

Expand Your Skills in Other Domains

Top-rated KodeKloud courses across popular technology tracks
No items found.
Data
close