How to troubleshoot mongo sharded environment like query slow

how to troubleshoot mongo sharded environment like query slow

Hi @giribabu_venugopal and welcome to the MongoDB community!!

Could you help with some details on the issues you are observing:

  1. The error message observed if any while executing the query.
  2. The output for .explain() for which slow query has been observed.
  3. Sharded cluster deployment specifications (like no of shard servers, number of mongos etc)
  4. MongoDB version you are using
  5. Hardware specifications for the sharded cluster. (eg. disc space, RAM etc).
  6. Is the deployment On-Prem or an Atlas deployment.

Also, for troubleshooting slow queries in sharded cluster the following documentation can be of help.

  1. Troubleshoot Sharded Clusters
  2. Indexes for slow query improvements.

Let us know if you have any further queries.

Best Regards
Aasawari

1 Like

i have two shards SH1 and SH2, most of my queries (inserts and update) queries going to SH2.
Balancer is running.

may i know what is reason ?

rs2:PRIMARY> db.serverStatus().globalLock
{
        "totalTime" : NumberLong("2535707000"),
        "currentQueue" : {
                "total" : 2430,
                "readers" : 0,
                "writers" : 2430
        },
        "activeClients" : {
                "total" : 167,
                "readers" : 30,
                "writers" : 137
        }
}
rs2:PRIMARY>
4:18
rs1:PRIMARY> db.serverStatus().globalLock
{
        "totalTime" : NumberLong("11815012000"),
        "currentQueue" : {
                "total" : 0,
                "readers" : 0,
                "writers" : 0
        },
        "activeClients" : {
                "total" : 10,
                "readers" : 5,
                "writers" : 5
        }
}
rs1:PRIMARY>

How is your shard key defined? If your key is built on a monotonically increasing value you would definitely have a situation like this.

What is the result of running sh.status()?

2 Likes

no error in sh.status

also shards are equally distributed

I wasn’t asking if there were errors while running sh.status() but was hoping to see the results of from the command. That would help us to see what might be going on. Without having any of the information we’ve asked for, helping will be near impossible.

2 Likes

i shard mongodb to 3 shards 3 replica and 3 config server 2 router server …
but insert query for a simple user collection is 30 case per 10 sec
before sharding i have very speed 1000 insert per sec
waht happen for performance how can achive high speed

what is your experience
this is not scaling it is like fu…ing scaling