【问题标题】:Skewed Read Load on Mongo Replica SetMongo 副本集上的倾斜读取负载
【发布时间】:2020-12-27 05:39:20
【问题描述】:

我已经建立了一个 mongo 副本集,其中包含一个主副本和两个辅助副本。我面临的问题是,来自与副本集连接 URL 连接的应用程序服务器的读取总是只转到一个辅助服务器,从而导致两个辅助服务器之间的读取负载出现巨大偏差。

由于这种偏差,我在一台服务器上的资源受到限制,而另一台服务器上的资源却被浪费了。

rs.status()

    {
    "set" : "rs0",
    "date" : ISODate("2020-09-08T19:39:20.394Z"),
    "myState" : 1,
    "term" : NumberLong(16),
    "syncingTo" : "",
    "syncSourceHost" : "",
    "syncSourceId" : -1,
    "heartbeatIntervalMillis" : NumberLong(2000),
    "majorityVoteCount" : 2,
    "writeMajorityCount" : 2,
    "optimes" : {
        "lastCommittedOpTime" : {
            "ts" : Timestamp(1599593958, 2042),
            "t" : NumberLong(16)
        },
        "lastCommittedWallTime" : ISODate("2020-09-08T19:39:18.908Z"),
        "readConcernMajorityOpTime" : {
            "ts" : Timestamp(1599593958, 2042),
            "t" : NumberLong(16)
        },
        "readConcernMajorityWallTime" : ISODate("2020-09-08T19:39:18.908Z"),
        "appliedOpTime" : {
            "ts" : Timestamp(1599593959, 1176),
            "t" : NumberLong(16)
        },
        "durableOpTime" : {
            "ts" : Timestamp(1599593958, 2042),
            "t" : NumberLong(16)
        },
        "lastAppliedWallTime" : ISODate("2020-09-08T19:39:19.138Z"),
        "lastDurableWallTime" : ISODate("2020-09-08T19:39:18.908Z")
    },
    "lastStableRecoveryTimestamp" : Timestamp(1599593936, 300),
    "lastStableCheckpointTimestamp" : Timestamp(1599593936, 300),
    "electionCandidateMetrics" : {
        "lastElectionReason" : "priorityTakeover",
        "lastElectionDate" : ISODate("2020-08-11T17:18:08.040Z"),
        "electionTerm" : NumberLong(16),
        "lastCommittedOpTimeAtElection" : {
            "ts" : Timestamp(1597166288, 246),
            "t" : NumberLong(15)
        },
        "lastSeenOpTimeAtElection" : {
            "ts" : Timestamp(1597166288, 246),
            "t" : NumberLong(15)
        },
        "numVotesNeeded" : 2,
        "priorityAtElection" : 2,
        "electionTimeoutMillis" : NumberLong(10000),
        "priorPrimaryMemberId" : 5,
        "targetCatchupOpTime" : {
            "ts" : Timestamp(1597166288, 394),
            "t" : NumberLong(15)
        },
        "numCatchUpOps" : NumberLong(148),
        "newTermStartDate" : ISODate("2020-08-11T17:18:08.074Z"),
        "wMajorityWriteAvailabilityDate" : ISODate("2020-08-11T17:18:10.782Z")
    },
    "members" : [
        {
            "_id" : 3,
            "name" : "1.1.1.1:27017",
            "health" : 1,
            "state" : 1,
            "stateStr" : "PRIMARY",
            "uptime" : 2427845,
            "optime" : {
                "ts" : Timestamp(1599593959, 1176),
                "t" : NumberLong(16)
            },
            "optimeDate" : ISODate("2020-09-08T19:39:19Z"),
            "syncingTo" : "",
            "syncSourceHost" : "",
            "syncSourceId" : -1,
            "infoMessage" : "",
            "electionTime" : Timestamp(1597166288, 383),
            "electionDate" : ISODate("2020-08-11T17:18:08Z"),
            "configVersion" : 32,
            "self" : true,
            "lastHeartbeatMessage" : ""
        },
        {
            "_id" : 5,
            "name" : "3.3.3.3:27017",
            "health" : 1,
            "state" : 2,
            "stateStr" : "SECONDARY",
            "uptime" : 3672,
            "optime" : {
                "ts" : Timestamp(1599593954, 3378),
                "t" : NumberLong(16)
            },
            "optimeDurable" : {
                "ts" : Timestamp(1599593954, 3378),
                "t" : NumberLong(16)
            },
            "optimeDate" : ISODate("2020-09-08T19:39:14Z"),
            "optimeDurableDate" : ISODate("2020-09-08T19:39:14Z"),
            "lastHeartbeat" : ISODate("2020-09-08T19:39:19.238Z"),
            "lastHeartbeatRecv" : ISODate("2020-09-08T19:39:20.261Z"),
            "pingMs" : NumberLong(0),
            "lastHeartbeatMessage" : "",
            "syncingTo" : "1.1.1.1:27017",
            "syncSourceHost" : "1.1.1.1:27017",
            "syncSourceId" : 3,
            "infoMessage" : "",
            "configVersion" : 32
        },
        {
            "_id" : 6,
            "name" : "2.2.2.2:27017",
            "health" : 1,
            "state" : 2,
            "stateStr" : "SECONDARY",
            "uptime" : 3341,
            "optime" : {
                "ts" : Timestamp(1599593957, 2190),
                "t" : NumberLong(16)
            },
            "optimeDurable" : {
                "ts" : Timestamp(1599593957, 2190),
                "t" : NumberLong(16)
            },
            "optimeDate" : ISODate("2020-09-08T19:39:17Z"),
            "optimeDurableDate" : ISODate("2020-09-08T19:39:17Z"),
            "lastHeartbeat" : ISODate("2020-09-08T19:39:18.751Z"),
            "lastHeartbeatRecv" : ISODate("2020-09-08T19:39:20.078Z"),
            "pingMs" : NumberLong(0),
            "lastHeartbeatMessage" : "",
            "syncingTo" : "1.1.1.1:27017",
            "syncSourceHost" : "1.1.1.1:27017",
            "syncSourceId" : 3,
            "infoMessage" : "",
            "configVersion" : 32
        }
    ],
    "ok" : 1,
    "$clusterTime" : {
        "clusterTime" : Timestamp(1599593959, 1329),
        "signature" : {
            "hash" : BinData(0,"dfdfdggjhkljoj+mvY8="),
            "keyId" : NumberLong("897987897897987")
        }
    },
    "operationTime" : Timestamp(1599593959, 1176)
}

请帮帮我。这是 mongo 副本集集群通常所期望的吗?

提前非常感谢:)

【问题讨论】:

    标签: mongodb mongodb-query replicaset


    【解决方案1】:

    副本集中辅助节点的服务器选择算法是described here。

    您可以使用本地阈值和最大过时参数,例如如果您充分增加两者,假设驱动程序兼容,您应该会看到辅助节点之间的负载分布大致均匀。

    【讨论】:

      猜你喜欢
      • 2016-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-05
      • 1970-01-01
      • 2017-02-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多