测试版本
引用
bonecp-0.7.1-rc2.jar
bonecp-provider-0.7.1-rc2.jar
guava-r08.jar
guava-r08-gwt.jar
mysql-connector-java-3.0.17-ga-bin.jar
未使用bonecp的AB测试效果
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url"
value="jdbc:mysql://localhost/s?useUnicode=true&characterEncoding=utf-8"
/> <property name="username"> <value>root</value> </property>
<property name="password"> <value></value> </property>
</bean>
引用
C:\Documents and Settings\Administrator>ab -n 1000 -c 10 http://www.abc.com/?refresh=true
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.abc.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: Apache-Coyote/1.1
Server Hostname: www.abc.com
Server Port: 80
Document Path: /?refresh=true
Document Length: 20385 bytes
Concurrency Level: 10
Time taken for tests: 193.406 seconds
Complete requests: 1000
Failed requests: 503
(Connect: 0, Receive: 0, Length: 503, Exceptions: 0) 请求失败。
Write errors: 0
Non-2xx responses: 503
Total transferred: 10479297 bytes
HTML transferred: 10131345 bytes
Requests per second: 5.17 [#/sec] (mean)
Time per request: 1934.063 [ms] (mean)
Time per request: 193.406 [ms] (mean, across all concurrent requests)
Transfer rate: 52.91 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 4.3 0 31
Processing: 94 1906 1426.7 2000 8234
Waiting: 94 1893 1428.6 1984 8234
Total: 94 1907 1426.2 2000 8234
Percentage of the requests served within a certain time (ms)
50% 2000
66% 2031
75% 3000
80% 3016
90% 4016
95% 5016
98% 6031
99% 6063
100% 8234 (longest request)
使用bonecp后的AB测试效果
<bean id="dataSource"
class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
<property name="targetDataSource">
<ref local="mainDataSource" />
</property>
</bean>
<bean id="mainDataSource" class="com.jolbox.bonecp.BoneCPDataSource"
destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl"
value="jdbc:mysql://localhost/ssss?useUnicode=true&characterEncoding=utf-8" />
<property name="username" value="root" />
<property name="password" value="" />
<property name="idleConnectionTestPeriod" value="60" />
<property name="idleMaxAge" value="240" />
<property name="maxConnectionsPerPartition" value="60" />
<property name="minConnectionsPerPartition" value="20" />
<property name="partitionCount" value="3" />
<property name="acquireIncrement" value="10" />
<property name="statementsCacheSize" value="50" />
<property name="releaseHelperThreads" value="3" />
</bean>
引用
C:\Documents and Settings\Administrator>ab -n 1000 -c 10 http://www.abc.com/?refresh=true
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.abc.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: Apache-Coyote/1.1
Server Hostname: www.abc.com
Server Port: 80
Document Path: /?refresh=true
Document Length: 20385 bytes
Concurrency Level: 10
Time taken for tests: 12.313 seconds
Complete requests: 1000
Failed requests: 0 未失败。其实是存在失败的。
Write errors: 0
Total transferred: 20741000 bytes
HTML transferred: 20385000 bytes
Requests per second: 81.22 [#/sec] (mean)
Time per request: 123.125 [ms] (mean)
Time per request: 12.313 [ms] (mean, across all concurrent requests)
Transfer rate: 1645.07 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 4.9 0 31
Processing: 16 121 55.6 109 453
Waiting: 16 90 59.3 78 406
Total: 16 122 55.7 125 453
Percentage of the requests served within a certain time (ms)
50% 125
66% 125
75% 141
80% 141
90% 172
95% 234
98% 313
99% 344
100% 453 (longest request)
后端报错。mysql为默认设置
引用
2011-3-30 0:26:12 com.jolbox.bonecp.PoolWatchThread fillConnections
严重: Error in trying to obtain a connection. Retrying in 7000ms
java.sql.SQLException: Data source rejected establishment of connection message from server: "Too many connections"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2001)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1907)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:2524)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:818)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1808)
at com.mysql.jdbc.Connection.<init>(Connection.java:452)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:411)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:242)
at com.jolbox.bonecp.ConnectionHandle.obtainInternalConnection(ConnectionHandle.java:204)
at com.jolbox.bonecp.ConnectionHandle.<init>(ConnectionHandle.java:161)
at com.jolbox.bonecp.PoolWatchThread.fillConnections(PoolWatchThread.java:101)
at com.jolbox.bonecp.PoolWatchThread.run(PoolWatchThread.java:82)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
容量提升 81.22/5.17=15.7 倍。