0
0
HLDsystem_design~20 mins

Database sharding strategies in HLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Database Sharding Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Horizontal vs Vertical Sharding

Which statement correctly describes the difference between horizontal and vertical sharding?

AHorizontal sharding splits data by columns across multiple databases; vertical sharding splits data by rows across databases.
BHorizontal sharding splits data by rows across multiple databases; vertical sharding splits data by columns or tables across databases.
CHorizontal sharding duplicates the entire database across servers; vertical sharding partitions data by user location.
DHorizontal sharding stores data in a single large database; vertical sharding stores data in multiple identical copies.
Attempts:
2 left
💡 Hint

Think about whether data is divided by rows or columns.

Architecture
intermediate
2:00remaining
Choosing a Sharding Key for User Data

You are designing a sharded database for a social media app. Which sharding key would best distribute user data evenly across shards?

AUser's unique user ID (numeric or UUID)
BUser's geographic location (country or city)
CUser's last login timestamp
DUser's account creation date
Attempts:
2 left
💡 Hint

Consider which key is unique and evenly distributed.

scaling
advanced
2:30remaining
Handling Hotspots in Sharded Databases

Your sharded database has a hotspot where one shard receives most of the traffic due to popular users. Which approach best mitigates this issue?

AIncrease the hardware resources only on the hotspot shard without changing sharding strategy.
BUse vertical sharding to split user data by columns instead of rows.
CMove all popular users to a single dedicated shard to isolate traffic.
DRe-shard the database using a hash of user ID to distribute load evenly.
Attempts:
2 left
💡 Hint

Think about redistributing data to balance load.

tradeoff
advanced
2:30remaining
Tradeoffs Between Range-Based and Hash-Based Sharding

Which statement best describes a key tradeoff between range-based and hash-based sharding?

ARange-based sharding allows efficient range queries but risks uneven data distribution; hash-based sharding distributes data evenly but makes range queries inefficient.
BRange-based sharding evenly distributes data but requires complex hashing; hash-based sharding is simple but causes hotspots.
CRange-based sharding is only used for vertical sharding; hash-based sharding is only used for horizontal sharding.
DRange-based sharding duplicates data across shards; hash-based sharding stores data in a single shard only.
Attempts:
2 left
💡 Hint

Consider query efficiency versus data balance.

estimation
expert
3:00remaining
Estimating Number of Shards for Growing User Base

Your application currently has 10 million users stored in 5 shards. Each shard can handle up to 3 million users efficiently. You expect user growth to 50 million in 2 years. How many shards should you plan for to maintain performance?

AAt least 10 shards
BAt least 20 shards
CAt least 17 shards
DAt least 15 shards
Attempts:
2 left
💡 Hint

Divide expected users by max users per shard and round up.