[总结]数据库连接池设置不当导致大量的本地连接出现time_wait状态。

来源:互联网 发布:常用的udp端口号 编辑:程序博客网 时间:2024/06/05 01:02
最近在做性能测试时,在使用netstat命令查看本地网络连接状态时发现有大量的连接处于time_wait状态。于是认为是我们的dbcp的配置文件写的有问题,开始查应如何配置dbcp。但是改了几个参数后,发现还是出现大量的time_wait。于是又开始查看官方的配置说明,还是我们老大认真犀利,发现了这段:If maxIdle is set too low on heavily loaded systems it is possible you will see connections being closed and almost immediately new connections being opened. This is a result of the active threads momentarily closing connections faster than they are opening them, causing the number of idle connections to rise above maxIdle. The best value for maxIdle for heavily loaded system will vary but the default is a good starting point.这段之前我也发现了,可是却因为没仔细阅读想当然的认为了是另一个问题的说明。主要意思就是在负载压力较大的系统中maxIdle的值不能太低,否则就会在短时间内出现关闭连接的速度大于打开连接的速度的现象,就会出现大量空闲连接。所以,当出现的空闲连接数大于maxIdle时,连接池就会将多出的连接关闭,系统中也就会有大量的连接处于time_wait状态了。根据此说明,我们将maxIdle的数量修改为和maxTotal的值相同,再做性能压力测试,系统中不再出现大量的time_wait连接了。
0 0
原创粉丝点击