Hot Shard in MongoDB: Diagnose and Fix
Fast recall
Quick revision
Core answer
_id, low-cardinality fields like status, or one dominant tenant). Diagnose with sh.status(), getShardDistribution(), db.currentOp(), and the profiler. Short-term mitigation: vertical scale the hot shard, split jumbo chunks, throttle problem producers, pin whales to their own zone. Long-term fix: run reshardCollection (5.0+) with a hashed or compound key so writes spread evenly. The lasting lesson is that shard-key choice is the single most important design decision in MongoDB sharding — it defines your scaling ceiling.Production NoSQL troubleshooting, shard-key diagnosis, and understanding of MongoDB cluster operations under load
Blaming hardware, ignoring shard-key choice, or adding shards without redistributing hot chunks
Discuss hashed vs ranged shard keys, compound keys, `reshardCollection`, jumbo chunks, zones, and write sharding as a stopgap
Interview-ready guide
Interview answer
Name the pattern fast
- Hot shard = one shard owns the hottest chunks; almost always a bad shard key
- Monotonic keys, low-cardinality keys, or whale values are the classic causes
Walk through diagnosis
- Per-shard metrics,
sh.status(),getShardDistribution() - Profiler and
currentOp()for hot ops - Check jumbo chunks and the actual shard key
Offer immediate mitigation
- Vertical scale the hot shard, manual splits, throttle producers, zones for whales, Kafka buffer
Propose the long-term fix
reshardCollection(5.0+) with hashed or compound key- Before 5.0: dual-write migration
- Good keys: high cardinality, low frequency, non-monotonic, query-aligned
Close with prevention
- Shard-key review in design docs
- Load test with representative data
- Alert on chunk distribution imbalance and jumbo chunks
Hot Shard in MongoDB: Diagnose and Fix
Direct Answer
A hot shard means one shard gets disproportionate writes while others sit idle — root cause is almost always a bad shard key (monotonically increasing _id, low-cardinality fields like status, or one dominant tenant). Diagnose with sh.status(), getShardDistribution(), db.currentOp(), and the profiler. Short-term mitigation: vertical scale the hot shard, split jumbo chunks, throttle problem producers, pin whales to their own zone. Long-term fix: run reshardCollection (5.0+) with a hashed or compound key so writes spread evenly. The lasting lesson is that shard-key choice is the single most important design decision in MongoDB sharding — it defines your scaling ceiling.
Common Mistakes & Pitfalls
Blaming hardware, ignoring shard-key choice, or adding shards without redistributing hot chunks
Check your understanding
Answer these without looking back at the article.
- What's the difference between hashed and ranged shard keys and when do you pick each?
- How does `reshardCollection` work under the hood in MongoDB 5.0+?
- What is a jumbo chunk and how do you recover from them?
- When is zone sharding the right answer vs a compound shard key?
Related interview prep categories
1Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.