lgcpeter 2008-06-30 12:12
浏览 379
已采纳

关于hibernate3推荐链接池C3p0的问题

听取了大家的建议,于前天(2008-06-28)替换掉了以前tomcat自带的DBCP连接池,改为了C3P0,配置如

下:
[code]
10<!--连接池的最小连接数-->
50<!--最大连接数-->
100<!--连接超时时间-->
<!--每隔100秒检测连接是否可正常使用 -->
100
<!--当池中的连接耗尽的时候,一次性增加的连接数量,默认为3-->
3
<!--statemnets缓存大小-->
150
[/code]
原来的DBCP配置
[code]
maxActive="200"
maxIdle="60"
maxWait="-1"
/>
[/code]
今天(2008-06-30)访问量达到了200,并且某一瞬间并发查询达到了150左右。出现了用DBCP时未出现过的

问题:瞬间打开页面很慢,并有部分用户超时掉线,我估计是我C3P0设置的问题。请大家

给予回答!

[b]问题补充:[/b]
[quote]
是不是最大连接数50太少了,你说一瞬间打到了150并发
[/quote]
我的理解是:c3p0.max_size达到最大后会自动新建线程,对吗?

  • 写回答

3条回答 默认 最新

  • hjgundam 2008-06-30 17:47
    关注

    看下这个官方文档里面写的

    Basic Pool Configuration

    c3p0 Connection pools are very easy to configure via the following basic parameters:

    acquireIncrement
    initialPoolSize
    maxPoolSize
    maxIdleTime
    minPoolSize
    initialPoolSize, minPoolSize, maxPoolSize define the number of Connections that will be pooled. Please ensure that minPoolSize <= maxPoolSize. Unreasonable values of initialPoolSize will be ignored, and minPoolSize will be used instead.

    Within the range between minPoolSize and maxPoolSize, the number of Connections in a pool varies according to usage patterns. The number of Connections increases whenever a Connection is requested by a user, no Connections are available, and the pool has not yet reached maxPoolSize in the number of Connections managed. Since Connection acquisition is very slow, it is almost always useful to increase the number of Connections eagerly, in batches, rather than forcing each client to wait for a new Connection to provoke a single acquisition when the load is increasing. acquireIncrement determines how many Connections a c3p0 pool will attempt to acquire when the pool has run out of Connections. ([color=red]Regardless of acquireIncrement, the pool will never allow maxPoolSize to be exceeded.[/color])

    The number of Connections in a pool decreases whenever a pool tests a Connection and finds it to be broken (see Configuring Connection Testing below), or when a Connection is expired by the pool after sitting idle for a period of time, or for being too old (See Managing Pool Size and Connection Age.)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合