java driver: how to know the usage of connection pool

331 views
Skip to first unread message

Andy Fan

unread,
Jun 14, 2017, 11:05:59 PM6/14/17
to mongodb-user
One MongoClient instance represents N connection pools,  N is the number of MongoDB nodes except the hidden & arbiter nodes. 
When a request needs a connection,  suppose all the connection are in use,  it will wait for N time unit before raise exception  (suppose the wait queue size is not too long).  

=== The above is my current understanding,  please correct me if I'm anything wrong =====

Suppose we set the N to 400ms,   and a request itself need 5ms database server response time + 15ms network transfer time.    so the request may take 400 + 5 + 15 = 420 ms response time at most. 

but in fact,  all the 3 number are unknown.   So if a customer says why I get 400+ms  response time to DBA, DBA is hard to decide which part is wrong.  DBA can only know the request is quicker than {slowms} since it is not recorded in mongo server slow query log.  it is unknown that if the issue was caused by "network transfer time" or "connection wait time".   This will make the troubleshooting hard. 

so my question is,  could we get the connection pool usage metrics in the driver?   I think any one of the blow should be very useful. 

1.  How many connections is in use currently for every connection pool? 
2.  What many connections is got since the java process start and how about the average time? 

but looks none of them are exposed now.   do you have any suggestion for this?

Thanks

Jeff Yemin

unread,
Jun 27, 2017, 9:21:56 PM6/27/17
to mongodb-user
Connection pool metrics are already exposed via JMX.  See http://mongodb.github.io/mongo-java-driver/3.4/driver/reference/monitoring/ for details.

In an upcoming release we will expose the ability to register a connection pool listener.  Please follow https://jira.mongodb.org/browse/JAVA-805 for details.


Regards,
Jeff
Reply all
Reply to author
Forward
0 new messages