MongoDB MCQs – Sharding

11.) What is the purpose of the balancer in MongoDB sharding?

A) To encrypt data
B) To distribute chunks evenly across shards
C) To route queries to shards
D) To back up data

Answer: Option B

Explanation: The balancer ensures that chunks are distributed evenly across shards.

12.) Which of the following is true about hashed sharding?

A) It uses a range-based shard key
B) It is slower than range-based sharding
C) It uses a hash function to distribute data
D) It is not supported in MongoDB

Answer: Option C

Explanation: Hashed sharding uses a hash function to distribute data evenly across shards.

13.) What is the primary disadvantage of range-based sharding?

A) It is slower than hashed sharding
B) It can lead to uneven data distribution
C) It requires more config servers
D) It is not supported in MongoDB

Answer: Option B

Explanation: Range-based sharding can lead to uneven data distribution if the shard key values are not evenly distributed.

14.) Which command is used to add a shard to a sharded cluster?

A) sh.addShard()
B) sh.createShard()
C) sh.enableShard()
D) sh.startShard()

Answer: Option A

Explanation: The sh.addShard() command is used to add a shard to a sharded cluster.

15.) What is the role of the mongos process in MongoDB sharding?

A) To store metadata
B) To store actual data
C) To route queries to the correct shard
D) To act as a config server

Answer: Option C

Explanation: The mongos process routes queries to the correct shard based on the shard key.

16.) What happens if a shard goes down in a sharded cluster?

A) The entire cluster becomes unavailable
B) Only the data on the failed shard is unavailable
C) The balancer redistributes the data
D) The config server takes over

Answer: Option B

Explanation: If a shard goes down, only the data on that shard becomes unavailable.

17.) Which of the following is true about tag-aware sharding?

A) It uses tags to back up data
B) It uses tags to encrypt data
C) It uses tags to compress data
D) It uses tags to group shards

Answer: Option D

Explanation: Tag-aware sharding uses tags to group shards and control data distribution.

18.) What is the purpose of the sh.splitAt() command?

A) To enable sharding
B) To merge two chunks
C) To add a new shard
D) To split a chunk at a specific shard key value

Answer: Option D

Explanation: The sh.splitAt() command splits a chunk at a specific shard key value.

19.) Which of the following is true about zone sharding?

A) It allows data to be distributed based on geographic zones
B) It is slower than hashed sharding
C) It requires more config servers
D) It is not supported in MongoDB

Answer: Option A

Explanation: Zone sharding allows data to be distributed based on geographic or logical zones.

20.) Which of the following is true about the sh.enableBalancing() command?

A) It stops the balancer
B) It enables the balancer to redistribute chunks
C) It adds a new shard
D) It removes a shard

Answer: Option B

Explanation: The sh.enableBalancing() command enables the balancer to redistribute chunks.

Leave a Reply

Your email address will not be published. Required fields are marked *