简体   繁体   English

MongoDB 随着时间的推移降低写入性能

[英]MongoDB degrading write performance over time

I am importing a lot of data (18GB, 3 million documents) over time, almost all the data are indexed, so there are lots of indexing going on.随着时间的推移,我正在导入大量数据(18GB,300 万个文档),几乎所有数据都已编入索引,因此正在进行大量索引。 The system consist of a single client (single process on a separate machine) establishing a single connection (using pymongo) and doing insertMany in batch of 1000 docs.该系统由单个客户端(单独机器上的单个进程)组成,建立单个连接(使用 pymongo)并批量执行 1000 个文档的insertMany

MongoDB setup: MongoDB 设置:

  • single instance,单例,
  • journaling enabled,启用日记功能,
  • WiredTiger with default cache,带有默认缓存的 WiredTiger,
  • RHEL 7, RHEL 7,
  • version 4.2.1版本 4.2.1
  • 192GB RAM, 16 CPUs 192GB 内存,16 个 CPU
  • 1.5 TB SSD, 1.5 TB 固态硬盘,
  • cloud machine.云机。

When I start the server (after full reboot) and insert the collection, it takes 1.5 hours.当我启动服务器(完全重新启动后)并插入集合时,需要 1.5 小时。 If the server run for a while inserting some other data (from a single client), it finishes to insert the data, I delete the collection and run the same data to insert - it takes 6 hours to insert it (there is still sufficient disk more than 60%, nothing else making connections to the db).如果服务器运行一段时间插入一些其他数据(来自单个客户端),它会完成插入数据,我删除集合并运行相同的数据插入 - 插入需要 6 个小时(仍然有足够的磁盘超过 60%,没有其他东西可以连接到数据库)。 It feels like the server performance degrades over time, may be OS specific.感觉服务器性能会随着时间的推移而下降,可能是特定于操作系统的。 Any similar experience, ideas?有没有类似的经历、想法?

I had faced similar issue, the problem was RAM.我遇到过类似的问题,问题是RAM。 After full restart the server had all RAM free, but after insertions the RAM was full.完全重新启动后,服务器的所有 RAM 均可用,但插入后 RAM 已满。 Deletion of collection and insertion same data again might take time as some RAM was still utilised and less was free for mongo.删除收集和再次插入相同的数据可能需要一些时间,因为一些 RAM 仍在使用中,而 mongo 的可用内存更少。 Try freeing up RAM and cache after you drop the collection, and check if same behaviour persists.删除集合后尝试释放 RAM 和缓存,并检查相同的行为是否仍然存在。

As you haven't provided any specific details, I would recommend you enable profiling;由于您没有提供任何具体细节,我建议您启用分析; this will allow you to examine performance bottlenecks.这将允许您检查性能瓶颈。 At the mongo shell run:在 mongo shell 运行:

db.setProfilingLevel(2)

Then run:然后运行:

db.system.profile.find( { "millis": { "$gt": 10 } }, { "millis": 1, "command": 1 }) // find operations over 10 milliseconds

Once done set reset the profiling mode:一旦完成设置重置分析模式:

db.setProfilingLevel(0) 

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

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