Mitigate Performance Issues with PSA Replica Set使用PSA副本集缓解性能问题

On this page本页内容

Overview概述

In a three-member replica set with a primary-secondary-arbiter (PSA) architecture or a sharded cluster with three-member PSA shards, a data-bearing node that is down or lagged can lead to performance issues.在具有主辅仲裁器(PSA)体系结构的三成员副本集或具有三成员PSA分片的分片集群中,数据承载节点停机或滞后可能会导致性能问题。

If one data-bearing node goes down, the other node becomes the primary. 如果一个数据承载节点发生故障,另一个节点将成为主节点。Writes with w:1 continue to succeed in this state but writes with write concern "majority" cannot succeed and the commit point starts to lag. w:1的写入在此状态下继续成功,但写入关注点为"majority"的写入无法成功,提交点开始延迟。If your PSA replica set contains a lagged secondary and your replica set requires two nodes to majority commit a change, your commit point also lags.如果PSA副本集包含滞后的次要副本集,并且副本集需要两个节点来多数提交更改,则提交点也会滞后。

With a lagged commit point, two things can affect your cluster performance:对于延迟的提交点,有两件事会影响集群性能:

  • The storage engine keeps all changes that happen after the commit point on disk to retain a durable history. 存储引擎将在提交点之后发生的所有更改保存在磁盘上,以保留持久的历史记录。The extra I/O from these writes tends to increase over time. 这些写入的额外I/O往往会随着时间的推移而增加。This can greatly impact write performance and increase cache pressure.这会极大地影响写入性能并增加缓存压力。
  • MongoDB allows the oplog to grow past its configured size limit to avoid deleting the majority commit point.MongoDB允许oplog增长超过其配置的大小限制,以避免删除多数提交点

To reduce the cache pressure and increased write traffic, set votes: 0 and priority: 0 for the node that is unavailable or lagging. 要降低缓存压力并增加写入流量,请为不可用或滞后的节点设置votes: 0priority: 0For write operations issued with "majority", only voting members are considered to determine the number of nodes needed to perform a majority commit. 对于以“多数”发出的写操作,只考虑投票成员来确定执行多数提交所需的节点数。Setting the configuration of the node to votes: 0 reduces the number of nodes required to commit a write with write concern "majority" from two to one and allows these writes to succeed.将节点配置设置为votes: 0将提交具有写入关注点"majority"的写入所需的节点数量从两个减少到一个,并允许这些写入成功。

Once the secondary is caught up, you can use the rs.reconfigForPSASet() method to set votes back to 1.一旦第二个被捕获,您可以使用rs.reconfigForPSASet()方法将votes设置回1

Note注意

In earlier versions of MongoDB, enableMajorityReadConcern and --enableMajorityReadConcern were configurable allowing you to disable the default read concern "majority" which had a similar effect.在早期版本的MongoDB中,enableMajorityReadConcern--enableMajorityReadConcern是可配置的,允许您禁用具有类似效果的默认读取关注点"majority"

Procedure过程

To reduce the cache pressure and increased write traffic for a deployment with a three-member primary-secondary-arbiter (PSA) architecture, set { votes: 0, priority: 0 } for the secondary that is unavailable or lagging:要减少使用三成员主辅助仲裁器(PSA)架构的部署的缓存压力和增加的写入流量,请为不可用或滞后的辅助仲裁器设置{ votes: 0, priority: 0 }

cfg = rs.conf();
cfg["members"][<array_index>]["votes"] = 0;
cfg["members"][<array_index>]["priority"] = 0;
rs.reconfig(cfg);

If you want to change the configuration of the secondary later, use the rs.reconfigForPSASet() method.如果您想稍后更改辅助服务器的配置,请使用rs.reconfigForPSASet()方法。

←  Modify PSA Replica Set SafelyReplication Reference →