Skip to main content

How does MongoDB ensure consistency in a sharded cluster?

Senior MongoDB
Quick Answer In a sharded cluster, consistency per shard is handled by each shard's replica set. Cross-shard consistency: single-document operations on one shard are always atomic. Multi-document cross-shard transactions use a two-phase commit protocol via the transaction coordinator. For non-transactional operations across shards, you get per-shard consistency but no global atomicity.

Answer

Config servers maintain chunk metadata; mongos routes queries based on metadata, and majority write concern ensures cluster-wide consistent writes.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice