這個測試的目的是驗證當前經常使用數據庫鏈接池的性能。java
Connection conn = dataSource.getConnection(); PreparedStatement stmt = conn.preparedStatement("select 1"); ResultSet rs = stmt.executeQuery(); while (rs.next()) { } rs.close(); stmt.close(); conn.close();
test codehttps://github.com/alibaba/druid/blob/master/src/test/java/com/alibaba/druid/benckmark/pool/Case1.javalinux
test configgit
property | value |
initialSize | 10 |
minPoolSize | 10 |
maxPoolSize | 50 |
測試各類併發場景下執行申請1,000,000(一百萬)次總耗時的性能對比。github
這是一臺雙路至強CPU的工做站,比我以前在mac book pro上作的測試,更接近真實服務器的運行環境。sql
數據庫鏈接池 | 1 thread | 2 threads | 5 threads | 10 threads | 20 threads | 50 threads | 100 threads |
druid | 248 | 710 | 1,133 | 1,134 | 905 | 1,107 | 1,468 |
dbcp | 660 | 1,522 | 3,545 | 4,176 | 3,671 | 4,237 | 14,129 |
boneCP | 3,522 | 2,930 | 2,579 | 3,745 | 7,434 | 11,991 | 14,584 |
c3p0 | 4,275 | 9,509 | 3,371 | 10,439 | 13,472 | 19,848 | 36,153 |
proxool | 7,187 | 7,707 | 11,037 | 10,777 | 15,222(Error) | 18,100(Error) | 21,547(Error) |
tomcat-jdbc | 372 | 736 | 1,879 | 1,727 | 1,576 | 1,322 | 12,545 |
jboss-datasource | 1,326 | 1,184 | 2,928 | 3,765 | 3,099 | 3,278 | 10,812 |
數據庫鏈接池 | 1 thread | 2 threads | 5 threads | 10 threads | 20 threads | 50 threads | 100 threads |
druid | 309 | 605 | 1,028 | 947 | 962 | 897 | 1,238 |
dbcp | 924 | 1,461 | 4,062 | 4,030 | 4,908 | 5,505 | 14,517 |
boneCP | 3,047 | 2,055 | 2,549 | 3,821 | 6,367 | 12,865 | 18,832 |
c3p0 | 4,018 | 8,206 | 8,897 | 10,667 | 12,367 | 25,822 | 38,681 |
proxool | 6912 | 4,714 | 4,851 | 11,908 | 16,066(Error) | 19,568(Error) | 18,036(Error) |
tomcat-jdbc | 400 | 740 | 1,811 | 1,707 | 1,618 | 1,624 | 11,905 |
jboss-datasource | 1,369 | 1,105 | 4,002 | 3,089 | 3,483 | 3,665 | 11,782 |
轉自:https://github.com/alibaba/druid/wiki/linux-benchmark 數據庫