分片 是 MongoDB 的 水平扩展 方法——将数据分布在多个服务器(分片)上,使数据库能够处理超出单个服务器容量的数据集和吞吐量。它按 分片键 对数据进行分区,MongoDB 将查询路由到正确的分片。
分片的理由:超越单个服务器的扩展
text
A single server has limits (storage, RAM, write throughput). When data/load exceeds
what one server (even a powerful one) can handle, SHARDING distributes it:
→ data is split across multiple SHARDS (each a replica set)
→ each shard holds a SUBSET of the data → combined capacity scales horizontally
→ handles huge datasets and high write throughput
