DATABASE
    advanced

    Database Sharding

    Software Engineer path · lesson 57 of 99
    Shard 0
    0
    Shard 1
    0
    Shard 2
    0
    Shard 3
    0
    Hash-based: hash(key) % 4 — even distribution, no range queries0 records

    Hash or range sharding?

    Sort

    Sort each trait into the sharding strategy it describes.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    Hash-based

    Drop items here

    Range-based

    Drop items here
    6 pieces left to place

    Test your knowledge

    20 questions
    Question 1 of 20
    Score: 0

    What is the main advantage of consistent hashing over simple modular hashing when adding a new shard?

    The short version

    Sharding is like splitting a phone book into multiple volumes (A-F, G-M, N-S, T-Z). Each volume is a shard that can be stored and searched independently.

    In more depth

    Database Sharding

    Hash-Based Sharding

    Apply hash function to shard key
    Even distribution of data
    Difficult to do range queries

    Range-Based Sharding

    Split data by key ranges
    Easy range queries
    Risk of uneven distribution (hotspots)

    Consistent Hashing

    Minimizes data movement when adding/removing shards
    Uses virtual nodes for better distribution

    Interview Questions

    Meta
    Twitter
    Pinterest
    Google
    Amazon
    Microsoft

    Love this visualization?

    Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.

    100% free • No credit card required