gpt4 book ai didi

python - MongoDB - serverStatus 非常慢

转载 作者:行者123 更新时间:2023-12-03 12:44:16 25 4
gpt4 key购买 nike

当我运行一个运行大约50个线程的多线程程序,并且在每个线程中都有数据库操作时,mongodb运行速度太慢,然后服务将被停止。在 Mongodb 日志中,我看到此消息:

2017-12-13T09:24:50.226+0330 I COMMAND  [ftdc] serverStatus was very slow: { after basic: 71, after asserts: 307, after backgroundFlushing: 358, after connections: 622, after dur: 653, after extra_info: 915, after globalLock: 977, after locks: 998, after network: 1008, after opLatencies: 1008, after opcounters: 1008, after opcountersRepl: 1008, after repl: 1030, after security: 1030, after storageEngine: 1061, after tcmalloc: 1293, after wiredTiger: 1627, at end: 2498 }

这是我的线程代码:
def processor(*data):
for item in data[0]:
try:
col_articles_data.update({'_id': item['id']}, {'$set': {'processed': True}})
except:
Debug.PrintException()

我该怎么办?

最佳答案

这表明您的 mongodb 需要的 RAM 比您预配的要多。我可以想到两种解决问题的方法:

  • 增加内存
  • 增加 Docker 的 RAM 资源,以防它运行 docker 容器 ( https://docs.docker.com/config/containers/resource_constraints/ )
  • 关闭其他消耗 RAM 的应用程序,例如 Web 浏览器或邮件客户端
  • 优化您的查询 适合您的资源:https://docs.mongodb.com/manual/core/query-optimization/

  • 更多信息请阅读: https://groups.google.com/g/mongodb-user/c/Y-B_XShEquE

    关于python - MongoDB - serverStatus 非常慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47786567/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com