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 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料