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"?
-
How did you time that, from the web server? Then it would include the time taken to pass and process the data to the web service as well as any network latency depending where they are in relation to each other.nanobar– nanobar2019-03-25 10:26:18 +00:00Commented Mar 25, 2019 at 10:26
3 Answers
"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
Comments
your assumption is incorrect, cuz u are ignoring the fact that mongodb supports concurrency