1

[BoneCP Version : 0.8.0.RELEASE]
[Guava Version : 11.0.2]

我使用guice-mybatiswithbonecp作为数据源提供者。getConnection()为了在 mysql master 和 slave 之间旋转,我已经用 over-ridden 包装了 MySQL 驱动程序。我看到 boneCP 创建的连接数量超过了应用程序所需的数量。考虑到 QPS,我们有 10 个活动连接应该足够了,但它创建了超过 30 个。此外,bonecp 统计数据给出了负数:

[Format]
Cluster = pool.getTotalCreatedConnections()|pool.getTotalFree()|pool.getTotalLeased() 

[ Data ]
cluster[1]=10|44|-34,
cluster[2]=10|50|-40,
cluster[3]=-28|0|-28,
cluster[4]=10|45|-35,
cluster[5]=10|49|-39,
cluster[6]=10|50|-40,
cluster[7]=10|46|-36,
cluster[8]=10|34|-24,


Following are my bonecp configurations :
        bonecp.connectionTestStatement = "SELECT now()"
        bonecp.partitionCount = 1
        bonecp.maxConnectionsPerPartition = 50
        bonecp.minConnectionsPerPartition = 10
        bonecp.acquireIncrement = 1
        bonecp.idleConnectionTestPeriod = 60
        bonecp.timeUnit = SECONDS
        bonecp.idleMaxAge = 10
        bonecp.poolAvailabilityThreshold = 1
        bonecp.maxConnectionAgeInSeconds = 10
        bonecp.acquireRetryDelayInMs = 500
        bonecp.acquireRetryAttempts = 10

从 netstat 我看到 ESTABLISHED 连接的总数等于pool.getTotalFree()所有集群的总和。

注意:我有另一个 db [oracle],我使用 bonecp 没有遇到这个问题。唯一的区别是我们没有包装驱动程序,并且不需要在不同的主机之间轮换getConnection()请求。

在迁移到 BoneCP 之前,我使用的是 C3P0,在那里我们遇到了性能问题,但统计数据很好。我正在阅读源代码以确定根本原因。

4

0 回答 0