I am helping to support a Node.js application which uses MongoDB on an EC2 instance as the back end. The database is about 14 GB and the largest table has a little over 15 million documents.
To test, I have set up MongoDB on an m5.large instance (2 vcpu, 8 gb ram) and DocumentDB on an db.r5.large instance (2 vcpu, 16 gb ram).
When performing operations such as aggregate queries on the largest table, the CPU usage on DocDB is abnormally high and never drops back down. I have seen it get stuck at 99% CPU usage for days with seemingly nothing happening other than a couple aggregate queries which are each taking 10 seconds to complete.
The same test on the MongoDB instance leads to peak CPU usage of 10% and the aggregate queries complete in less than 1 second.
What could possibly lead to such a disparity in performance between AWS DocumentDB and MongoDB? I thought DocDB would be a simple lift and shift type of service but it is proving to be a giant pain....