[GODRIVER-1883] [question] Unexpected connection numbers when initializing the client Created: 11/Feb/21  Updated: 27/Oct/23  Resolved: 16/Feb/21

Status: Closed
Project: Go Driver
Component/s: Connections
Affects Version/s: 1.4.6
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: 策 高 Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

WSL Kwernel: 4.19.128-microsoft-standard
CPU: AMD Ryzen 7 3800XT 8-Core Processor


Issue Links:
Related
related to GODRIVER-1884 Document expected connection counts f... Backlog

 Description   

When initializing the client with default configs, there is more than 1 connection (sometimes 2, sometimes 3) to the specific server.

When I set the MaxPoolSize to 2 and MinPoolSize to 2, I got 4 connections which are also unexpected.

I am wondering if it is a bug or feature in the driver?



 Comments   
Comment by 策 高 [ 14/Feb/21 ]

Thanks for your reply!

Find the corresponding logic at go.mongodb.org/mongo-driver/x/mongo/driver/topology/server.go.
Connect()
 
 

 

Comment by Kevin Albertson [ 11/Feb/21 ]

Hi gaocegege@gmail.com, thank you for the report!

That sounds like expected behavior. A fixed number of connections are created per server for monitoring. This is in addition to the connections created for application use (which is dictated by MinPoolSize and MaxPoolSize).

For Go driver 1.4.0+ there are a fixed 2 monitoring connections per server.
For Go driver < 1.4.0 there is a fixed 1 monitoring connection per server.

When initializing the client with default configs, there is more than 1 connection (sometimes 2, sometimes 3) to the specific server.

If no MaxPoolSize was specified, the default MaxPoolSize is 100. And application connections are created as needed. The higher rate of concurrent operations, the more application connections will be created, capping at MaxPoolSize.

When I set the MaxPoolSize to 2 and MinPoolSize to 2, I got 4 connections which are also unexpected.

If you are connecting to one server, since there are two monitoring connections, that is expected.

Sincerely,
Kevin

Generated at Thu Feb 08 08:37:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.