MongoDB使用更好的配置机器

时间:2016-09-22 09:29:16

标签: mongodb performance

我们有两个用于测试的mongo服务器和一个用于生产的服务器,每个服务器都有一个名为images的集合,其中有大约700万个文档。

{
    _id
    MovieId
    ...
}

我们的索引位于_idMovieId

我们正在运行以下格式的查询

db.images.find({MovieId:1234})

质量保证配置:

256GB of RAM with RAID disk

Prod Config:

700GB of RAM with SSD mirror

mongod配置(/etc/mongod.conf)

QA:

storage:
   dbPath: "/data/mongodb_data"
   journal:
     enabled: false
   engine: wiredTiger
   wiredTiger:
     engineConfig:
        cacheSizeGB: 256
setParameter:
   wiredTigerConcurrentReadTransactions: 256

PROD:

storage:
   dbPath: "/data/mongodb_data"
   directoryPerDB: true
   journal:
     enabled: false
   engine: wiredTiger
   wiredTiger:
     engineConfig:
        cacheSizeGB: 600
setParameter:
   wiredTigerConcurrentReadTransactions: 256

使用更好的prod服务器配置,它应该比QA服务器更好。令人惊讶的是,与QA Server相比,它的运行速度非常慢。

我检查了同一负载下两台服务器上的当前操作(使用db.currentOp()),prod服务器上的大量查询需要10-20秒,但在QA服务器上查询时间不超过1秒。 / p>

查询是从Mapreduce作业启动的。

我需要帮助来确定问题。

[编辑]:Mongo 3.0.11版

2 个答案:

答案 0 :(得分:0)

您可以通过多种方式调试mongo查询。

使用以下命令开始索引使用:
db.images.aggregate([{$ indexStats:{}}])

如果这不能为您提供任何有用的信息,请使用以下方法检查慢查询的执行计划: db.setProfilingLevel(2)
db.system.profile.find()。漂亮()

db.system.profile将为您提供完整的查询配置文件。

答案 1 :(得分:0)

我们的临时服务器和生产服务器之间的打开文件最大用户进程的数量存在差异。我使用命令ulimit -a

检查了它

<强>分段:

 open files                      (-n) 32768
 pipe size            (512 bytes, -p) 8
 POSIX message queues     (bytes, -q) 819200
 real-time priority              (-r) 0
 stack size              (kbytes, -s) 10240
 cpu time               (seconds, -t) unlimited
 max user processes              (-u) 32768

<强> PROD:

 open files                      (-n) 16384
 pipe size            (512 bytes, -p) 8
 POSIX message queues     (bytes, -q) 819200
 real-time priority              (-r) 0
 stack size              (kbytes, -s) 10240
 cpu time               (seconds, -t) unlimited
 max user processes              (-u) *16384*

在我更改了prod上的两个设置后,它开始提供更好的性能。感谢@Gaurav就此向我提出建议。

相关问题