MongoDB Sharding and Horizontal Scaling Flashcards
6 cards from real MongoDB practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 6 MongoDB Sharding and Horizontal Scaling flashcards as text
What are the three main components of a MongoDB sharded cluster?
Answer: Mongos, config servers, and shards
A MongoDB sharded cluster consists of: (1) mongos — the query router that clients connect to; (2) config servers — store cluster metadata and chunk distribution; and (3) shards — each shard is a replica set holding a subset of the sharded data.
What is a shard key in MongoDB sharding?
Answer: A field or combination of fields that determines how documents are distributed across shards
The shard key is a field (or compound fields) whose values determine which shard stores each document. MongoDB divides the shard key value range into chunks and distributes these chunks across shards. Choosing the right shard key is critical for balanced distribution and query efficiency.
What is a monotonically increasing shard key and why is it problematic?
Answer: A shard key like a timestamp or auto-increment ID where all new inserts go to the same 'max' chunk, creating a hot spot
A monotonically increasing shard key (e.g., ObjectId, timestamp) causes all new inserts to go to the shard holding the upper-bound chunk, creating a write hot spot. This shard receives all write traffic while others sit idle. Hashed shard keys or compound keys solve this problem.
What is the role of the balancer in a MongoDB sharded cluster?
Answer: Automatically moving chunks between shards to maintain even data distribution
The MongoDB balancer is a background process that monitors chunk counts per shard. When imbalances exceed a threshold, it migrates chunks from overloaded shards to underloaded ones. Migrations occur automatically and transparently to the application.
What is a targeted (routed) query vs a scatter-gather query in a sharded cluster?
Answer: A targeted query includes the shard key and goes to one shard; a scatter-gather query broadcasts to all shards
A targeted query includes the shard key in the filter, allowing mongos to route it to exactly one (or a few) shard(s). A scatter-gather query lacks the shard key and must be broadcast to all shards, with results merged at mongos — much more expensive at scale.
What is a hashed shard key in MongoDB and when should you use it?
Answer: A shard key where MongoDB hashes the field values to distribute documents evenly, ideal for monotonically increasing fields
A hashed shard key applies a hash function to the shard key values before distributing documents. This ensures even distribution even for monotonically increasing fields (like ObjectId or timestamps), preventing hot spots. The trade-off is that range queries are inefficient.
How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. Exam facts are checked against the official sources listed below. Not reviewed by a subject-matter expert. Editorial policy
Sources & references
Exam facts on this page (fees, format, dates, passing scores) are checked against these official sources; the date is our last check. Editorial policy
- 10geneducation.zendesk.com — Test dates, score release, passing score, test delivery, retake policy · verified Oct 2026
- learn.mongodb.com — Eligibility, fees, exam format, time limit · verified Oct 2026