【问题标题】:MongoDB benchmarking insertsMongoDB 基准测试插入
【发布时间】:2015-01-12 13:25:38
【问题描述】:

我正在尝试使用 JS 工具对 MongoDB 进行基准测试。我正在尝试插入。给出的例子in mongo website

但是,我正在尝试插入操作,它工作得很好,但每秒发出错误的查询。

ops = [{op: "insert", ns: "benchmark.bench", safe: false, doc: {"a": 1}}]

以上工作正常。然后,我在 mongo shell 中运行了以下命令:

for ( x = 1; x<=128; x*=2){
    res = benchRun( { parallel : x ,
                      seconds : 5 ,
                      ops : ops
                    } )
    print( "threads: " + x + "\t queries/sec: " + res.query )
}

它给出了:

threads: 1   queries/sec: 0
threads: 2   queries/sec: 0
threads: 4   queries/sec: 0
threads: 8   queries/sec: 0
threads: 16  queries/sec: 0
threads: 32  queries/sec: 1.4
threads: 64  queries/sec: 0
threads: 128     queries/sec: 0

我不明白为什么查询/秒为 0 并且没有插入单个文档。这是在测试插入的性能吗?

【问题讨论】:

  • 根本没有抛出任何错误或警告。
  • 看看dynamic values 示例中的插入。您没有正确的插入符号。另外,不要使用 benchrun 进行基准测试。
  • @wdberkeley:那么有什么更好的基准测试方法?
  • 对于通用基准测试,您可以使用 YCSB。如果您正在针对特定用例(例如提议的应用程序)进行基准测试,那么只有在旨在满足该用例的数据模型上实际尝试实际工作负载,这是无可替代的。其他基准可能与特定用例无关。

标签: mongodb performance performance-testing database-performance nosql


【解决方案1】:

回答是因为我刚刚遇到了类似的问题。

尝试用printjson(res) 替换您的打印语句。 你会看到 res 有以下字段:

{
    "note" : "values per second",
    "errCount" : NumberLong(0),
    "trapped" : "error: not implemented",
    "insertLatencyAverageMicros" : 8.173300153139357,
    "totalOps" : NumberLong(130600),
    "totalOps/s" : 25366.173139864142,
    "findOne" : 0,
    "insert" : 25366.173139864142,
    "delete" : 0,
    "update" : 0,
    "query" : 0,
    "command" : 0
}

如您所见,查询计数为 0,因此当您打印 res.query 时,它给出 0。要获得每秒插入操作的数量,您需要打印 res.insert。我相信res.query对应的是“查找”操作。

【讨论】:

    猜你喜欢
    • 2019-12-25
    • 2019-07-21
    • 2013-04-19
    • 2010-12-30
    • 1970-01-01
    • 2017-05-29
    • 2014-07-30
    • 1970-01-01
    相关资源
    最近更新 更多