简体   繁体   English

MongoDB 基准测试插入

[英]MongoDB benchmarking inserts

I am trying to benchmark MongoDB with the JS harness.我正在尝试使用 JS 工具对 MongoDB 进行基准测试。 I am trying to do inserts.我正在尝试插入。 The example given in mongo website . mongo 网站中给出的示例。

However, I am trying an insert operation, which works totally fine, but gives out wrong queries/sec.但是,我正在尝试插入操作,该操作完全正常,但会发出错误的查询/秒。

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

The above works fine.以上工作正常。 Then, I have run the following in mongo shell:然后,我在 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 )
}

It gives out:它给出:

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

I dont understand why the queries/sec is 0 and not a single doc has been inserted.我不明白为什么查询/秒为 0 并且没有插入单个文档。 Is this right was testing performance for inserts?测试插入物的性能是否正确?

Answering because I just encountered a similar problem.回答是因为我刚刚遇到了类似的问题。

Try replacing your print statement with printjson(res) .尝试用printjson(res)替换您的打印语句。 You will see that res has the following fields:您将看到 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
}

As you can see, the query count is 0, hence when you print res.query it gives 0. To get the number of insert operations per second you would want to print res.insert .如您所见,查询计数为 0,因此当您打印res.query它会给出 0。要获得每秒插入操作的数量,您需要打印res.insert I believe res.query corresponds to the "find" operation.我相信res.query对应于“查找”操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM