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. This can greatly impact write performance and increase cache pressure.这些写入的额外I/O往往会随着时间的推移而增加。这会极大地影响写入性能并增加缓存压力。MongoDB allows the oplog to grow past its configured size limit to avoid deleting theMongoDB允许oplog超过其配置的大小限制,以避免删除大多数提交点。majority commit point
.
To reduce the cache pressure and increased write traffic, set 要降低缓存压力并增加写入流量,请为不可用或滞后的节点设置votes: 0
and priority: 0
for the node that is unavailable or lagging. votes: 0
和priority: 0
。For 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"
的写操作所需的节点数量从2个减少到1个,并允许这些写操作成功。
Once the secondary is caught up, you can use the 一旦二次投票被赶上,您可以使用rs.reconfigForPSASet()
method to set votes
back to 1
.rs.reconfigForPSASet()
方法将votes
设置回1
。
In earlier versions of MongoDB, 在MongoDB的早期版本中,enableMajorityReadConcern
and --enableMajorityReadConcern
were configurable allowing you to disable the default read concern "majority"
which had a similar effect.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 要为具有三成员主-辅助仲裁器(PSA)体系结构的部署降低缓存压力并增加写入流量,请为不可用或滞后的辅助仲裁器设置{ votes: 0, priority: 0 }
for the secondary that is unavailable or lagging:{ 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()
方法。