-
Type: Investigation
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: 1.3.1
-
Component/s: Performance
-
None
Problem Statement/Rationale
The performance of mongosh compared to mongo is very bad (more than 40 times slower) when using --eval to query the DB.
We first noticed this while upgrading to the popular last mongodb bitnami helm chart (bitnami/mongodb 12.0.0). The chart uses:
mongosh --eval 'db.adminCommand({ping: 1})'
as liveness probe which seems logical and works.
The problem comes due to the fact that these health checks are executed every 10 seconds and since the performance of mongosh has dropped so notably compared to mongo this causes a very high CPU usage of the nodes in our kubernetes cluster even if no user is working with the DBs.
Steps to Reproduce
Just execute mongosh with the --eval parameter and measure the execution time as I will show in the expected & actual results sections.
Expected Results
Please pay attention to the usage of mongo and the time measurements at the end of the code section.
I have no name!@mongodb-0:/$ time mongo --eval 'db.adminCommand({ping: 1})' MongoDB shell version v5.0.8 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("6547acbe-c08e-4f8b-b5fd-5cce1fca49ce") } MongoDB server version: 5.0.8 { "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1653047238, 1), "signature" : { "hash" : BinData(0,"IGJeXc/FIgBuEbWUo3NQ9vFtX9Y="), "keyId" : NumberLong("7099725676390907909") } }, "operationTime" : Timestamp(1653047238, 1) } real 0m0.095s user 0m0.071s sys 0m0.006s
Actual Results
Please pay attention to the usage of mongosh and the time measurements at the end of the code section.
I have no name!@mongodb-0:/$ time mongosh --eval 'db.adminCommand({ping: 1})' Current Mongosh Log ID: 62877fbe652999b416806eda Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.3.1 Using MongoDB: 5.0.8 Using Mongosh: 1.3.1For mongosh info see: https://docs.mongodb.com/mongodb-shell/ To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy). You can opt-out by running the disableTelemetry() command.{ ok: 1, '$clusterTime': { clusterTime: Timestamp({ t: 1653047228, i: 1 }), signature: { hash: Binary(Buffer.from("95f58f4aad1623763ee2775410bda9b4ee65ae55", "hex"), 0), keyId: Long("7099725676390907909") } }, operationTime: Timestamp({ t: 1653047228, i: 1 }) } real 0m2.945s user 0m3.211s sys 0m0.128s
Additional Notes
An issue was also opened in the bitnami helm chart project which contains this an other relevant information: https://github.com/bitnami/charts/issues/10316
To overcome this problem we are still using the mongo command even if it is deprecated.
- is related to
-
MONGOSH-1642 mongosh 2.0.2 starts up significantly slower than 1.9.0
- Closed