Calculating connection count and DB server type

How can I calculate the optimal total connection count from my service to the my mongo DB endpoint? Is there a basic formula based on expected number of queries per second and CPU and IO taken by each query?

Similarly, is there a formula to calculate the optimal database instance type/size to use based on traffic patterns and query characteristics (CPU, IO consumed or latency of query)?

Note: By instance type I mean similar to EC2 instance type which provides info on vCPU and memory (RAM)

I will be using this to create the connection pool in my service. I’m assuming that if my service has N hosts then per host the connection pool size need to be the total optimal connection count divided by N.

Hi,

MongoDB Drivers already manage connection pools so I don’t think it’s a good idea to add another home made connection pool on top of it.

For the sizing, there are no magic formulas. It can be completely different from one use case to another. It depends on your read/write ratio, your hardware, perf requirements, etc.

You can have a look to the pricing and cluster tier MongoDB Atlas provides to get an idea of what MongoDB generally recommends for the ratio storage - RAM - CPU.

Cheers,
Maxime.