Why does MongoDB scale horizontally?
Because MongoDB was designed from the start so that data could be split into pieces and stored across several servers, instead of just one. It uses replication and sharding mechanisms to distribute and store data across a cluster.
The key reasons
- Data can be split into shards
A collection is split by its
shard key, and each piece goes to its own server. That means load doesn't concentrate in one place. - There's no tie to a single machine Unlike many SQL systems, MongoDB can behave as a single database even when the data physically lives on dozens of nodes.
- Requests are routed through mongos The client doesn't have to think about "where the data lives", the router itself sends the request to the right shard.
What this gives you
- the database isn't limited by a single server's power
- new machines can be added as load grows
- reads and writes get spread across nodes
Summary
MongoDB scales horizontally because it can distribute data and load across many servers, while still looking like a single logical database.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.