# Sharding — MongoDB

Source: https://www.geekswithgeeks.com/en/mongodb/mongo-sharding

> Horizontally partition data across multiple servers.

## Splitting data by shard key

**Sharding** distributes a collection's documents across multiple servers (shards) based on a chosen **shard key**, instead of one server holding it all.

## When you need it

Reach for sharding when data size or write/read throughput outgrows what a single replica set can handle.

**Quiz:** What problem does sharding primarily solve?

- [ ] Automatic failover when the primary goes down
- [x] Scaling storage and throughput beyond a single server
- [ ] Validating document structure

*Answer:* Scaling storage and throughput beyond a single server. Sharding horizontally scales out data and load; failover is handled by replica sets instead.
