Database Manual / Sharding / Administration / Scaling Strategies

Start with Sharded Clusters从分片集群开始

We recommend starting with a single sharded cluster when you are building a new application regardless of your immediate need for multiple shards.我们建议您在构建新应用程序时从单个分片集群开始,而不管您是否需要多个分片。

The following scenarios benefit from sharded cluster architecture:以下场景受益于分片集群架构:

Use Case用例Description描述
Cost Optimization成本优化Vertical scaling becomes increasingly expensive and less effective as hardware requirements grow. Horizontal scaling offers more predictable and cost-effective scaling as resource demands increase.随着硬件需求的增长,垂直扩展变得越来越昂贵,效率也越来越低。随着资源需求的增加,水平扩展提供了更可预测和更具成本效益的扩展。
High Concurrent Collection Access高并发集合访问Applications with multiple active collections where resource contention results in performance bottlenecks. Sharding distributes collections across dedicated hardware, preventing resource contention.具有多个活动集合的应用程序,其中资源争用会导致性能瓶颈。分片将集合分布在专用硬件上,防止资源争用。
High-Throughput Workloads高吞吐量工作负载Applications with high read/write volumes benefit from distributing traffic across multiple machines, improving performance and reducing bottlenecks.具有高读/写量的应用程序受益于在多台机器上分配流量,提高性能并减少瓶颈。
Large Data Sets大数据集If your data volumes grow rapidly or working sets exceed single-server memory capacity, horizontal scaling ensures sustainable performance by distributing data across multiple nodes.如果数据量快速增长或工作集超过单服务器内存容量,水平扩展可以通过在多个节点上分布数据来确保可持续的性能。
Multi-Tenant Environments多租户环境Applications serving multiple customers benefit from having dedicated shards per tenant, providing performance isolation and customized resource allocation. MongoDB's sharding features enable efficient multi-tenant architectures.服务于多个客户的应用程序受益于每个租户都有专用的分片,提供性能隔离和定制的资源分配。MongoDB的分片功能实现了高效的多租户架构。
Global Deployments全球部署When your users are spread across different regions, distributing data across geographically positioned shards reduces latency and enhances the user experience.当用户分布在不同的地区时,将数据分布在地理位置的分片上可以减少延迟并增强用户体验。

Details详情

Starting with a sharded cluster is a proactive approach that offers:从分片集群开始是一种主动的方法,它提供了:

  • Effortless Horizontal Scaling – You can easily add shards as your application grows, without the complexity of migrating from a replica set.轻松的水平扩展-随着应用程序的增长,您可以轻松添加分片,而无需从副本集迁移的复杂性。
  • Cost-Effective Infrastructure – MongoDB 8.0 introduces config shards, allowing you to set up a sharded cluster on a single replica set infrastructure without dedicated config servers. 经济高效的基础设施-MongoDB 8.0引入了配置分片,允许您在单个副本集基础设施上设置分片集群,而无需专用的配置服务器。In MongoDB Atlas, sharded clusters with up to 3 shards in version 8.0 use config shards by default.在MongoDB Atlas中,8.0版本中最多有3个分片的分片集群默认使用配置分片。

Consider adding shards when your database reaches 60-70% of resource utilization (RAM, vCPUs, or storage) of a sizable machine. For example, in Atlas, consistent 60-70% resource utilization of an M60 machine with a 4 TB disk indicates an additional shard should be added.当数据库达到大型计算机资源利用率(RAM、vCPU或存储)的60-70%时,考虑添加分片。例如,在Atlas中,具有4 TB磁盘的M60机器的资源利用率始终为60-70%,这表明应该添加额外的分片。

Learn More了解更多