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条)

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?