0

I've just set up a full NodeJS bot, using MongoDB. This Discord server has roughly 24k people spamming the bot left and right with commands, and there for I've used

(Info blurred out, due to having username, password, ips there)

"url": "mongodb://XXXX:[email protected]:25000/?authSource=admin?maxPoolSize=500&poolSize=300&autoReconnect=true",

This is my URI, and as you see I've allowed a farely large poolsize.

Normally my application (before i enabled pooling) would have hit 300-600 on average connections, due to having it have multiple instances of "MongoDB.Connect(uri) etc" around in the cose, as well as a massive amount of db.close() at the end of collections.

I've cleaned up the entire thing, and i only call 1 instance of MongoClient.Connect() & then refer this connection around once in the code (as a bypasser).

There after I've made sure to wipe everything that would close the db (db.close();)

I've started up, and everything still seems responsive - so theres no database/mongo errors.

However, looking through MongoDB Compass, my connection count is around 29 stable. Which is good obviously, but when i enabled 300 Pools, shouldn't this be higher?

MongoDB Compass

This is how my mongod.cfg looks like enter image description here

Is there something i have missed? or is it all behaving as it should?

2
  • While making it do some work (Changing 100s of files per milisecond out of 25.000 total), it still doesn't seem like the connection count really diverts much (we talk 37). Why doesn't it go up much more? to speed up the proccess - and after its done, the connection count keeps staying at 37 instead of going back down. Commented Mar 8, 2021 at 0:50
  • serviceExecutor: adaptive - in mongod.cfg could this be related? Commented Mar 8, 2021 at 0:57

1 Answer 1

1

Each client connects to each server once or twice for monitoring. If you create a client that performs a single operation, while that operation is running against a 4.4 replica set you have 7 open connections.

By reusing clients you can have a dramatic reduction in the number of total connections.

Additionally a further reduction is expected since each of your operations can complete faster (it doesn't have to wait for server discovery).

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah, i can see that its still laying stable around.. 30~ connections over 24 hours almost - before it would have been at a few hundred. Speed seems to be the same~ish as before, and stability seems to be good. So i would assume my "pooling" is going as expected? Even though theres a few hundred less cons

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.