Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB - serverStatus was very slow

When I run a multi-thread program which runs about 50 threads, and in each thread there are database operations, mongodb runs too slow and then service will be stopped. in Mongodb log I see this message:

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 }

This is my thread code:

def processor(*data):
    for item in data[0]:
        try:
            col_articles_data.update({'_id': item['id']}, {'$set': {'processed': True}})
        except:
            Debug.PrintException()

What should I do?

like image 342
ehsan shirzadi Avatar asked Nov 07 '22 13:11

ehsan shirzadi


1 Answers

This indicates that your mongodb needs more RAM than you provisioned it. I can think of two ways of fixing the problem:

  1. Increase the RAM
  • increase Docker´s RAM Resources, in case it runs a docker container (https://docs.docker.com/config/containers/resource_constraints/)
  • closing other RAM-draining applications such as web browsers or mail clients
  1. Optimizes your queries to fit yours resources: https://docs.mongodb.com/manual/core/query-optimization/

For more info read: https://groups.google.com/g/mongodb-user/c/Y-B_XShEquE

like image 97
tschomacker Avatar answered Nov 15 '22 06:11

tschomacker