Hi, I am trying to move my infrastructure from different cloud provider and got stuck on MongoDB performance in Digital Ocean. All my queries take two times more execution time than it should be compare to previous provider and even localhost. I tested it on the same data, no indexes.
I used .explain("executionStats") command to get execution times. The results:
Digital Ocean:
"executionStats": {
"executionSuccess": true,
"nReturned": 12,
"executionTimeMillis": 609,
"totalKeysExamined": 0,
"totalDocsExamined": 333969,
Previous provider:
"executionStats": {
"executionSuccess": true,
"nReturned": 12,
"executionTimeMillis": 256,
"totalKeysExamined": 0,
"totalDocsExamined": 333969,
Localhost:
`"executionStats": {
"executionSuccess": true,
"nReturned": 12,
"executionTimeMillis": 221,
"totalKeysExamined": 0,
"totalDocsExamined": 333969`,
I run these tests multiple times, tried different queries, but DO is always significantly slower. I tried to scale up DO more, but it didn’t help. I use managed MongoDB 4 GB RAM / 2vCPU / 56 GB Disk in Frankfurt. I had similar setup with previous provider.
Any help appreciate it, thank you.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Update: I tried to test self hosted Mongo on basic Droplet and execution time is solid. Looks like the issue is in managed MongoDB.
Hey!
It sounds like that this could be just network latency, if you were running the statements from the server itself it would explain why you are seeing the same behavior on your localhost and on the Droplet that you’ve just created.
However, if you are running the statements from your local computer to the remote managed database, it would explain the few hundred milliseconds difference.
Basically, the physical distance between your MongoDB server in DigitalOcean’s data center and your current location might be contributing to increased response times. You could try to spin up a Droplet where you would be running your application on, and measure the execution time when running the statements from the Droplet to the Managed Database that are in the same region.
Let me know how it goes!
- Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.