Challenge - 5 Problems
Range Sharding Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Find the shard key range for a given document
Given a MongoDB sharded collection with a range-based shard key on the field
- Shard1: age < 20
- Shard2: 20 ≤ age < 40
- Shard3: age ≥ 40
Choose the correct shard that will contain Alice's document.
age, which shard will store the document { "name": "Alice", "age": 25 } if the shard ranges are:- Shard1: age < 20
- Shard2: 20 ≤ age < 40
- Shard3: age ≥ 40
Choose the correct shard that will contain Alice's document.
Attempts:
2 left
💡 Hint
Check which range the age 25 falls into.
✗ Incorrect
Since Alice's age is 25, it falls within the range 20 ≤ age < 40, which belongs to Shard2.
🧠 Conceptual
intermediate2:00remaining
Understanding range-based shard key distribution
Why is range-based sharding potentially problematic if the incoming data is mostly increasing in the shard key value?
Choose the best explanation.
Choose the best explanation.
Attempts:
2 left
💡 Hint
Think about what happens if new data always has a higher shard key value.
✗ Incorrect
If data mostly increases in shard key value, all new writes go to the shard holding the highest range, causing that shard to be overloaded.
📝 Syntax
advanced2:00remaining
Identify the correct MongoDB command to enable range-based sharding
Which of the following MongoDB shell commands correctly enables sharding on the
users collection using age as the shard key with range-based sharding?Attempts:
2 left
💡 Hint
The command to shard a collection requires the namespace and shard key as an object.
✗ Incorrect
The correct syntax is sh.shardCollection("database.collection", { shardKey: 1 }) to enable range-based sharding on the shard key.
❓ optimization
advanced2:00remaining
Optimizing range-based shard key selection
You have a collection where most queries filter by
region and timestamp. Which shard key choice will best optimize query performance and data distribution using range-based sharding?Attempts:
2 left
💡 Hint
Consider which fields are used in queries and how combining them affects shard distribution.
✗ Incorrect
Using a compound shard key on region and timestamp allows queries filtering on both fields to target specific shards and balances data by region and time.
🔧 Debug
expert2:00remaining
Diagnose the cause of unbalanced shards in range-based sharding
A MongoDB cluster uses range-based sharding on the
orderDate field. Over time, one shard stores 90% of the data, causing performance issues. What is the most likely cause?Attempts:
2 left
💡 Hint
Think about how range-based sharding handles sequential values.
✗ Incorrect
A monotonically increasing shard key causes all new data to be routed to the last shard range, leading to unbalanced data and load.