王如锵
王如锵

Reputation: 991

Is mongodb handle query one by one?

Assume I have a mongodb instance on a remote server (1 core cpu and 8G memory). When I send a simple query db.table.find({_id:ObjectId('xxx')}).limit(1).explain()to the instance, I got the result show that query cost 10ms. So can I come to a conclusion that "my mongodb server can only handle 100 simple query per second"?

Upvotes: 1

Views: 495

Answers (3)

Amir
Amir

Reputation: 341

your assumption is incorrect, cuz u are ignoring the fact that mongodb supports concurrency

Source

Upvotes: -1

XESLOOHC GOD
XESLOOHC GOD

Reputation: 56

"So can I come to a conclusion that "my mongodb server can only handle 100 simple query per second""

Its not tht like that 1 query takes 10ms then 100 query will take 1sec db.table.find({_id:ObjectId('xxx')}).limit(1) will not lock your table So if your 100 client request this with 100 connections all will return in 10ms Concurrency Depends upon locks and connection limits

If a query locking collection for read and write for 10 sec then all query after that will wait for lock to cleared

MongoDb Can Handle multiple Request

db.runCommand( { serverStatus: 1 } ) will return current status of mongo there is object in

"connections" : {
    "current" : <num>,
    "available" : <num>,
    "totalCreated" : <num>,
    "active" : <num>
}

https://docs.mongodb.com/manual/reference/command/serverStatus/#connections

https://docs.mongodb.com/manual/reference/configuration-options/#net.maxIncomingConnections

https://docs.mongodb.com/manual/faq/concurrency/

These will give more clarity around connections and its limits

Upvotes: 2

shan
shan

Reputation: 152

You should know, your mongodb server can handle many parallel queries.

Upvotes: 1

Related Questions