I have set min_pool_size to 100 in mongoid.yml but in mongo when running db.serverStatus().connections i only get 30. Is there a way to check how many connections I have in pool?
Ruby on Rails, Can I get the current count of connections in Mongoid pool?
1.2k Views Asked by user793789 At
2
Setting min_pool_size in Ruby driver (and consequently Mongoid) does not mean that many network connections are actually created. Setting min_pool_size creates that many driver connection objects, but they are connected to the cluster on demand. This behavior has been fixed in version 2.11.0 of the driver - see https://jira.mongodb.org/browse/RUBY-1605.
To find out how many sockets are actually opened to a given server, first obtain its connection pool:
Then look at the sockets in the connections:
Each server has one additional connection/socket opened to it for monitoring purposes which is not application-accessible.
Note that all of the code posted above (
next_primary
, poking into connection sockets, etc.) is not part of the driver public API and may change at any time.