I have M80 atlas cluster(128GB RAM and 32vCPUs) with 3 replicasets.

most of the time my system use around 10% of RAM and 10% of CPU, during high load CPU spikes more than 100% leading to autoscaling of cluster evthough i have all the required indexes(I added them based on atlas performance advisor).

I’m trying to cut the cost, i noticed only primary's CPU is shooting up, so if i start reading from secondaries, can I reduce the CPU usage or 32 vCPUs are actually shared across 3 replicas and I wont see much diffrence?

as per my understandin it would not make a different if writes are causing CPU spikes, but i see a correlation between CPU usage and read operations.

  • You have a replica set with 3 nodes, or 3 replicasets (a sharded cluster?)
    – yossale
    Nov 6, 2023 at 13:16
  • its a standard atlas 3 node replicaset
    – mahendra
    Nov 6, 2023 at 16:22

2 Answers 2


Read queries in MongoDB can consume a lot of CPU - for example, if you're using the aggregation framework heavily.

So unless you have a very specific read-after-write needs, you can use readPreference of secondaryPreferred or secondary to direct your reads to your secondaries, and let your primary manage only the writes.

Another option might be to check that you don't have too many indexes - each index basically means that for each write you also write to each index - which might create unnecessary load on your cpu.

As a side note, if you have an M80 that is usually running at 10% CPU and 10% RAM, I suggest you discuss this with the support of MongoDB Atlas, because it sounds like you're over-provisioned.

  • thanks for your answer, the index suggestion makes sense, but isnt CPU shared across the nodes? when I do db.hostInfo on my primary it shows full ram and cpu of M80 plan, and I use M80 because of these spikes i see CPU is utilised more than 100% sometimes.
    – mahendra
    Nov 7, 2023 at 22:10
  • 2
    MongoDB compute & storage are in the same place. So when you have an M80 you basically have 3 different nodes, where each one has 128GB of RAM and 32 vCPU. If you get 100% cpu usages, it means you're utilizing all 32 vCPUs at 100%, which sounds a bit extreme. In this case I would definitely suggest using you read replicas.
    – yossale
    Nov 9, 2023 at 9:46

It can be very useful for you to make your readings from secondary nodes (if it is also suitable for your application).

If you have queries that force the m80 cluster, focusing a little more on the application side may provide clearer benefits for you.

For example, if you use skip-limit for pagination in a query with a lot of data, you need to optimise your queries rather than indexing or doing reads in secondary.

  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Jan 11 at 2:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.