Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monitoring Bone cp Connection pool

We are trying to move to bonecp connection pool from c3p0. we use hibernate as the ORM tool.

Now, is there any way to monitor the connections in boncecp like getting to know the maximum available and busy connection in the pool at a particular point of time and whether there are any unreturned connections to the pool etc?

Thanks for the help

like image 736
Npa Avatar asked Aug 06 '12 17:08

Npa


People also ask

How do I monitor my database connection pool?

Using VisualVM to Monitor Database Performance. VisualVM provides information about database transactions and connection pooling. To see connection pooling information, you should install the Java M-Beans plugin for your version of VisualVM. See the VisualVM documentation for more information on M-Beans plugin.

What are some of the main issues with using connection pools?

One of the most common issues undermining connection pool benefits is the fact that pooled connections can end up being stale. This most often happens due to inactive connections being timed out by network devices between the JVM and the database. As a result, there will be stale connections in the pool.

What is a good connection pool size?

For optimal performance, use a pool with eight to 16 connections per node. For example, if you have four nodes configured, then the steady-pool size must be set to 32 and the maximum pool size must be 64.


1 Answers

A lot of monitoring information is accessible via the BoneCP connection pool class (BoneCP). This is registered as a managed bean, so if you use jconsole or some other monitoring tool you should get a detailed view to this information, e.g.:

BoneCP MBean Screenshot

If needed you can get the BoneCP instance from a BoneCPDataSource using BoneCPDataSource#getPool():

/**
 * Get a status information of the JDBC connections.
 * 
 * @return The status information of the JDBC connections.
 */
public String getConnectionStatus() {
    String status = "unknown";
    if (dataSource instanceof BoneCPDataSource) {

        BoneCPDataSource bcpDataSource = (BoneCPDataSource) dataSource;
        BoneCP bcp = bcpDataSource.getPool();
        status = "JDBC connections: " + bcp.getTotalLeased()
            + " in use / " + bcp.getTotalFree()
            + " in pool / total created "
            + bcp.getTotalCreatedConnections();

    }
    return status;
}
like image 94
FrVaBe Avatar answered Oct 16 '22 20:10

FrVaBe