Sunday, 29 July 2018

What is the optimal pool size for a Mongoose connection to MongoDB Atlas?

My Express REST API is using Mongoose with MongoDB Atlas. Atlas is running an M10s (EC2 T2 smalls) and my REST API is on an EC2 M5 Large. I'm currently using the mongoose connection option "poolSize" as the default of 5 (so I think 15 total open connections to the replica set).

I want my application to be able to handle 1000 requests/second to the Atlas DB.

The DB is just a basic collection of 50K users with a couple data points on each as well as a 10kb profile image. 500 of the requests will be for the profile image and the other half for things like username and password auth.

My MongoDB Atlas replica set says it has a max of 350 connections. If I am only utilizing 15 of those am I unintentionally creating a bottleneck here? Will those 15 connections (5/node) be able to handle 1000 requests per second? Should I increase my "poolSize" in Mongoose to 100 (300 total connections to replica set) in order to allow more requests per second? I realize the easy answer is to say go test it out, but first I wanted to hear roughly what I should do in this situation and know if my current setup of a "poolSize" of 5 will probably be fine for 1000 requests/s?



from What is the optimal pool size for a Mongoose connection to MongoDB Atlas?

No comments:

Post a Comment