本文介绍了在Mongo中,分片和复制有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

复制似乎比分片要简单得多,除非我错过了分片实际上试图实现的好处.它们都不都提供水平缩放吗?

Replication seems to be a lot simpler than sharding, unless I am missing the benefits of what sharding is actually trying to achieve. Don't they both provide horizontal scaling?

推荐答案

在扩展MongoDB的上下文中:

In the context of scaling MongoDB:

  • 复制 创建数据的其他副本并允许自动故障转移到另一个节点.如果您可以读取可能不是最新的数据,则复制可能有助于横向扩展读取.

  • replication creates additional copies of the data and allows for automatic failover to another node. Replication may help with horizontal scaling of reads if you are OK to read data that potentially isn't the latest.

分片 允许按水平缩放数据写入使用分片键在多个服务器上对数据进行分区. 选择一个好的分片键非常重要.例如,分片密钥选择不当可能导致仅将数据写入单个分片上的热点".

sharding allows for horizontal scaling of data writes by partitioning data across multiple servers using a shard key. It's important to choose a good shard key. For example, a poor choice of shard key could lead to "hot spots" of data only being written on a single shard.

分片环境确实增加了更多的复杂性,因为MongoDB现在必须管理分发数据以及分片之间的请求-添加了额外的配置和路由过程来管理这些方面.

A sharded environment does add more complexity because MongoDB now has to manage distributing data and requests between shards -- additional configuration and routing processes are added to manage those aspects.

复制和分片通常结合在一起以创建 分片群集 副本集支持的每个分片.

Replication and sharding are typically combined to created a sharded cluster where each shard is supported by a replica set.

从客户端应用程序的角度来看,您还具有一些与复制/分片交互有关的控制权,尤其是:

From a client application point of view you also have some control in relation to the replication/sharding interaction, in particular:

  • Read preferences
  • Write concerns

这篇关于在Mongo中,分片和复制有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 02:31