簡體   English   中英

MongoDB 5.0.8 在 PSA(Primary-Secondary-Arbiter)設置中的寫入性能不佳

[英]Poor Write perfomance with MongoDB 5.0.8 in a PSA (Primary-Secondary-Arbiter) setup

當一個數據承載成員出現故障時,我在 PSA(Primary-Secondary-Arbiter)部署中與 MongoDB 5.0.8 存在一些寫入性能問題。

我知道“ 緩解 PSA 副本集的性能問題”頁面以及臨時解決此問題的過程。

但是,在我看來,這里描述的手動干預在操作過程中應該是不必要的。 那么我該怎么做才能確保即使節點發生故障,系統也能繼續高效運行呢? 換句話說,就像在 MongoDB 4.x 中使用“enableMajorityReadConcern=false”選項一樣。

據我了解,這個問題與 defaultRWConcern 有關。 在 MongoDB 中配置 PSA 副本集時,您必須設置 DefaultRWConcern。 否則調用 rs.addArb 時會出現以下消息:

MongoServerError: Reconfig 嘗試安裝會更改隱式默認寫入問題的配置。 使用 setDefaultRWConcern 命令設置集群范圍的寫入問題並再次嘗試重新配置。

所以我做了

db.adminCommand({
    "setDefaultRWConcern": 1,
    "defaultWriteConcern": {
        "w": 1
    },
    "defaultReadConcern": {
        "level": "local"
    }
})

我希望這種配置在讀取/寫入只有一個數據承載節點可用的 PSA 系統時不會出現延遲。

但我在 mongod 日志中觀察到“慢查詢”消息,如下所示:

{
    "t": {
        "$date": "2022-05-13T10:21:41.297+02:00"
    },
    "s": "I",
    "c": "COMMAND",
    "id": 51803,
    "ctx": "conn149",
    "msg": "Slow query",
    "attr": {
        "type": "command",
        "ns": "<db>.<col>",
        "command": {
            "insert": "<col>",
            "ordered": true,
            "txnNumber": 4889253,
            "$db": "<db>",
            "$clusterTime": {
                "clusterTime": {
                    "$timestamp": {
                        "t": 1652430100,
                        "i": 86
                    }
                },
                "signature": {
                    "hash": {
                        "$binary": {
                            "base64": "bEs41U6TJk/EDoSQwfzzerjx2E0=",
                            "subType": "0"
                        }
                    },
                    "keyId": 7096095617276968965
                }
            },
            "lsid": {
                "id": {
                    "$uuid": "25659dc5-a50a-4f9d-a197-73b3c9e6e556"
                }
            }
        },
        "ninserted": 1,
        "keysInserted": 3,
        "numYields": 0,
        "reslen": 230,
        "locks": {
            "ParallelBatchWriterMode": {
                "acquireCount": {
                    "r": 2
                }
            },
            "ReplicationStateTransition": {
                "acquireCount": {
                    "w": 3
                }
            },
            "Global": {
                "acquireCount": {
                    "w": 2
                }
            },
            "Database": {
                "acquireCount": {
                    "w": 2
                }
            },
            "Collection": {
                "acquireCount": {
                    "w": 2
                }
            },
            "Mutex": {
                "acquireCount": {
                    "r": 2
                }
            }
        },
        "flowControl": {
            "acquireCount": 1,
            "acquireWaitCount": 1,
            "timeAcquiringMicros": 982988
        },
        "readConcern": {
            "level": "local",
            "provenance": "implicitDefault"
        },
        "writeConcern": {
            "w": 1,
            "wtimeout": 0,
            "provenance": "customDefault"
        },
        "storage": {},
        "remote": "10.10.7.12:34258",
        "protocol": "op_msg",
        "durationMillis": 983
    }

這里涉及的集合處於適當的負載下,每秒來自不同(並發)客戶端的大約 1000 次讀取和 1000 次寫入。

MongoDB 4.x 與“enableMajorityReadConcern=false”在這里執行“正常”,我沒有注意到我的應用程序有任何性能損失。 MongoDB 5.x 無法做到這一點,並且在我的應用程序中,數據堆積如山,無法以高效的方式被寫入。

所以我的問題是,如果我能恢復 MongoDB 4.x 的行為。 在故障場景中可用的單個數據承載節點的寫保證對我來說是可以的。 但在發生故障的情況下,實際上應該避免手動重新配置故障節點。

感謝您的任何建議!

最后,我們將設置更改為 PSS 布局。 這也在MongoDB 社區論壇中被推薦。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM