A chunk is a contiguous range of shard key values that MongoDB uses to split data into manageable pieces for distribution across shards.
Click to reveal answer
beginner
What role does the balancer play in MongoDB?
The balancer moves chunks between shards to evenly distribute data and workload, ensuring no single shard is overloaded.
Click to reveal answer
intermediate
How does MongoDB decide when to split a chunk?
MongoDB splits a chunk when it grows beyond a configured size limit to keep data balanced and queries efficient.
Click to reveal answer
intermediate
Why is balancing important in a sharded MongoDB cluster?
Balancing prevents hotspots by distributing data evenly, which improves performance and resource use across all shards.
Click to reveal answer
advanced
What happens if the balancer is turned off in MongoDB?
Without the balancer, chunks won't move between shards, which can cause uneven data distribution and slow queries on overloaded shards.
Click to reveal answer
What is a chunk in MongoDB sharding?
AA piece of data representing a range of shard key values
BA single document in a collection
CA backup copy of data
DA user session in the database
✗ Incorrect
Chunks are ranges of shard key values used to split data for distribution.
What does the balancer do in a MongoDB cluster?
AMoves chunks between shards to balance data
BDeletes old data automatically
CCreates backups of the database
DMonitors user activity
✗ Incorrect
The balancer moves chunks to keep data evenly spread across shards.
When does MongoDB split a chunk?
AWhen the database restarts
BWhen a user requests it
CWhen the chunk size exceeds a set limit
DWhen a shard is removed
✗ Incorrect
Chunks split automatically when they grow too large.
Why is balancing data important in sharding?
ATo increase the size of chunks
BTo speed up backups
CTo reduce the number of shards
DTo prevent any shard from becoming overloaded
✗ Incorrect
Balancing keeps workload even and improves performance.
What can happen if the balancer is disabled?
AData will be deleted from shards
BData may become unevenly distributed causing slow queries
CNew shards will be added automatically
DChunks will automatically merge
✗ Incorrect
Without balancing, some shards can get overloaded, slowing down queries.
Explain what chunks are and how they help in MongoDB sharding.
Think about how data is split to spread across servers.
You got /4 concepts.
Describe the purpose of the balancer in a MongoDB sharded cluster.
Consider what keeps the data spread out evenly.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of chunks in MongoDB sharding?
easy
A. To backup data automatically
B. To create indexes on collections
C. To encrypt data for security
D. To split data into smaller parts for easier management
Solution
Step 1: Understand the role of chunks in sharding
Chunks divide large data sets into smaller pieces to distribute across servers.
Step 2: Identify the purpose of chunking
This splitting helps manage and query data efficiently in a distributed system.
Final Answer:
To split data into smaller parts for easier management -> Option D
Quick Check:
Chunks split data = To split data into smaller parts for easier management [OK]
Hint: Chunks break data into parts for easier handling [OK]
Common Mistakes:
Confusing chunks with backups
Thinking chunks encrypt data
Assuming chunks create indexes
2. Which of the following is the correct command to check the balancer status in MongoDB?
easy
A. sh.status()
B. db.balancerStatus()
C. sh.isBalancerRunning()
D. sh.getBalancerState()
Solution
Step 1: Recall MongoDB shell commands for sharding
The sh.status() command shows the sharding status including balancer info.
Step 2: Verify other options
Other commands are not valid MongoDB shell commands for balancer status.
Final Answer:
sh.status() -> Option A
Quick Check:
Balancer status command = sh.status() [OK]
Hint: Use sh.status() to see balancer info quickly [OK]
Common Mistakes:
Using non-existent commands like db.balancerStatus()
Confusing balancer commands with other shell commands
Assuming sh.getBalancerState() exists
3. Consider a sharded collection with chunks distributed unevenly. What will the balancer do when it runs?
medium
A. Move chunks from overloaded shards to underloaded shards
B. Delete chunks from overloaded shards
C. Merge all chunks into one big chunk
D. Create new chunks on the busiest shard
Solution
Step 1: Understand balancer's role in chunk distribution
The balancer moves chunks to spread data evenly across shards.
Step 2: Identify the correct action for uneven chunk distribution
It migrates chunks from overloaded shards to those with less data to balance load.
Final Answer:
Move chunks from overloaded shards to underloaded shards -> Option A
Quick Check:
Balancer moves chunks to balance load = Move chunks from overloaded shards to underloaded shards [OK]
Hint: Balancer moves chunks to balance shard load [OK]
Common Mistakes:
Thinking balancer deletes chunks
Assuming balancer merges chunks
Believing balancer creates chunks on busy shards
4. You run sh.startBalancer() but the balancer does not start. What is a likely cause?
medium
A. Chunks are too small to move
B. Balancer is disabled in the config server
C. Balancer is already running
D. No shards exist in the cluster
Solution
Step 1: Check balancer configuration
If balancer is disabled in the config server, it won't start even if commanded.
Step 2: Evaluate other options
Balancer already running would not prevent start command; chunk size doesn't block start; shards must exist for sharding.
Final Answer:
Balancer is disabled in the config server -> Option B
Quick Check:
Balancer disabled in config = won't start [OK]
Hint: Check config server if balancer won't start [OK]
Common Mistakes:
Assuming balancer can't start if already running
Thinking chunk size blocks balancer start
Ignoring config server settings
5. A MongoDB cluster has uneven chunk distribution causing slow queries on one shard. You want to manually trigger chunk migration to balance load. Which command should you use?
hard
A. sh.shardCollection('db.collection', { shardKey: 1 })
B. sh.splitChunk('db.collection', { shardKey: value })
C. sh.moveChunk('db.collection', { shardKey: value }, 'toShard')
D. sh.enableBalancer()
Solution
Step 1: Identify command to move chunks manually
sh.moveChunk() moves a specific chunk to a target shard manually.
Step 2: Differentiate from other commands
sh.splitChunk() splits chunks, sh.enableBalancer() enables automatic balancing, and sh.shardCollection() enables sharding on a collection.
Final Answer:
sh.moveChunk('db.collection', { shardKey: value }, 'toShard') -> Option C
Quick Check:
Manual chunk move = sh.moveChunk() [OK]
Hint: Use sh.moveChunk() to manually move chunks [OK]
Common Mistakes:
Using splitChunk to move chunks
Confusing enabling balancer with moving chunks
Trying to shard collection again instead of moving chunks
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.