Mongodb performance when I try to read data every few seconds

I have large number of notifications logs on mogodb. What i am doing i am trying to check status of logs every few seconds. So after sometime it is slowing the performance of mogodb, alot of read requests are joining to mongodb. I have almost 500,000 logs in my table. And 2 Cpu’s for mongodb server.

Hello @Hassan_Asif ,

Could you please share below details for me to understand you use case better?

  • Some sample documents
  • Query you are using
  • The number of clients executing this query at once

Based on your description of the issue, it may be that your server is overwhelmed with the workload, could you also share below details regarding your server?

  • What are the hardware specifications?
  • Is your mongod server sharing resources with other processes such as other applications running on same server, other server processes or even other mongod processes?

Regards,
Tarun

Hello @Tarun_Gaur thank you for your response. So we have email logs we are storing in mongodb, so we are reading and writing data in large amount. So atleast we have 20 jobs interacting with mongodb at same time.

Is your application still experiencing slowness? Number of open connections performing operations does not affect the database’s performance given if the hardware is able to support that load. To understand what could be the cause of this slowness, please share below details:

  • Output of mongostat
  • What are the hardware specifications?
  • Is your mongod server sharing resources with other processes such as other applications running on same server, other server processes or even other mongod processes?

You can also go through below links to check for additional metrics.

When we use filter, sort skip and limit. When we pass 50000 to skip then query is every slow.
when we use filter without sort query is fast.

  • Please run your query with explain in executionStats mode (e.g. `db.collection.explain(‘executionStats’).aggregate(…)) and check the output.

  • Make sure you are using index efficiently to support sort, for details please check use Indexes to Sort Query Results.

  • In case the indexes are working as expected then another area to look into are resources, make sure your server is not having resource crunch, you can also take a look at the output of mongostat.