Connection pool monitoring

The FlexyPool library adds metrics and flexible strategies to a given Connection Pool, allowing it to resize on demand. This is very handy since most connection pools offer a limited set of dynamic configuration strategies.



  1. The anatomy of Connection Pooling
  2. FlexyPool, reactive connection pooling
  3. Professional connection pool sizing
  4. The simple scalability equation
  5. How to monitor a Java EE DataSource
  6. How does FlexyPool support the Dropwizard Metrics package renaming
  7. How does FlexyPool support both Connection proxies and decorators

7 thoughts on “FlexyPool

  1. Hi vladmihalcea,

    We uses the below connection pools in our application via spring configuration

    1) DB2DataSource
    2) OracleDataSource

    Can we implement flexypool metrics and failover strategies to the above connection pools?
    If so could you please let me know how can I do that?
    I didn’t find any specific doc or example code related to it under flexyool github tutorial or repository?

    does flexy-pool support only below connection pools ?

    ◦Apache DBCP
    ◦Apache DBCP2
    ◦Tomcat CP
    ◦Vibur DBCP

    It’s Me

    My Account

    1. You can always use the generic DataSource connection pool that was designed for Java EE. It should work with any DataSource implementation and it will collect all metrics for you. You won;t be able to adjust the pool size using overflow buffer, that being the only limitation.

      If you want to develop a new adaptor, it’s fairly simple. You just have to add a new Maven module, set the Maven dependency and then provide the Adaptor implementation which can set the max pool size and translate the connection acquisition request timeout exception. You can take any other adaptor module as an example, it’s really straight forward.

  2. Greetings vladmihalcia,

    You have a nice tool. I’m trying to use Flexypool to find methods/transactions that hold onto connections too long. Do you have advice about correlating connections that exceed connectionLeaseTimeThresholdMillis with the things they were doing while on-loan?

    I tried implementing a ConnectionLeaseTimeThresholdExceededEventListener and printing a stack trace, but it’s useless because there’s a fair amount of Spring/Hibernate/JPA/AOP magic at work, and all the stack traces are the same. 😦

    It would be excellent to be able to write the SQL executed to the log for any connection that exceeds connectionLeaseTimeThresholdMillis.

    1. But, the connection acquisition is not correlated to the SQL query that comes afterwards. These are two separate mechanisms. You could print the query execution time with datasource-proxy or p6spy, and aggregate all data using ElasticSearch and view it in Kibana. You might want to print the threadId, to make sure that all logs get correlated by thread and time.

  3. I’m thinking that correlating by thread is perhaps the only reasonable way to make this connection.

    I can get query times, and (using your tool) I can see when a connection is out of the pool longer than I wish it was. The thing I’m specifically trying to find in my application is circumstances where a code component leases a connection, executes some SQL, but also does some computationally expensive stuff (not additional SQL) while it’s holding on to the connection.

    My first choice would be to have all this info in one log entry, and only for connections that exceed connectionLeaseTimeThresholdMillis.

    1. Makes sense. Logging all query executions can let you know how much time is spent by executing statements. But you should also take into consideration the fetching phase as well. You could add a timer in your data access logic to measure the duration of the whole data execution.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s