【发布时间】:2014-03-23 23:26:00
【问题描述】:
我最近将我的 Spring RESTful API 数据源从 DriverManagerDataSource 切换到 HikariCp,但是我的数据库连接从 20 个连接变成了 600 个连接。会发生这种情况吗?
我的设置如下:
<bean id="jdbcDataSource"
class="com.zaxxer.hikari.HikariDataSource" destroy-method="shutdown">
<constructor-arg>
<bean class="com.zaxxer.hikari.HikariConfig">
<constructor-arg>
<props>
<prop key="dataSource.url">url</prop>
<prop key="dataSource.user">user</prop>
<prop key="dataSource.password">password</prop>
<prop key="dataSource.cachePrepStmts">true</prop>
<prop key="dataSource.prepStmtCacheSize">250</prop>
<prop key="dataSource.prepStmtCacheSqlLimit">2048</prop>
<prop key="dataSource.useServerPrepStmts">true</prop>
</props>
</constructor-arg>
<property name="dataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" />
</bean>
</constructor-arg>
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="jdbcDataSource" />
</bean>
【问题讨论】:
-
这不应该发生。您使用的是什么版本的 HikariCP?
-
1.3.3 的更改日志显示“修复了在大量突发连接请求期间可能超出最大配置连接的问题。”
-
我使用的是 1.3.3 版
-
你正在运行一些东西来产生负载吗?日志中有异常吗?
-
我有很多脚本访问我的 API,它们发送大量 INSERT 请求。并且日志中没有异常