I have configured in my .NET Core 3.1 application the MongoDb waitQueueMultiple & maxPoolSize in the Mongo connection string.
I would like to set these parameters in the MongoClientSettings
instead of in the connection string, but I read that from 2.12.3 version of MongoDb waitQueueSize will be deprecated and I don't understand what the alternative will be.
Do you have any suggestions?
This is how I configured now my code:
var url = new MongoUrl(_mongoDbConfiguration.ConnectionString);
var settings = MongoClientSettings.FromUrl(url);
settings.MaxConnectionPoolSize = _mongoDbConfiguration.MaxPoolSize;
settings.WaitQueueSize = _mongoDbConfiguration.WaitQueueMultiple;
var client = new MongoClient(settings);
var database = client.GetDatabase(url.DatabaseName);
return database;
Thanks, Dave.
I found that documentation digging around.
This docs come from PyMongo but I think could be useful also for .NET one:
waitQueueMultiple
has been deprecated without replacement. This option was a poor solution for putting an upper bound on queuing since it didn't affect queuing in other parts of the driver.
Once the pool reaches its maximum size, additional threads have to wait for sockets to become available. PyMongo does not limit the number of threads that can wait for sockets to become available and it is the application's responsibility to limit the size of its thread pool to bound queuing during a load spike. Threads are allowed to wait for any length of time unless waitQueueTimeoutMS
is defined.
The default value for waitQueueTimeout is 2 minutes as per csharp driver docs.
So in my application I give the possibility to set MaxConnectionPoolSize
and WaitQueueTimeout
.
If not configured the application will be taken the default values.