The purpose of this test is to verify the performance of the current common database connection pool.
TestCase
Connection conn = dataSource.getConnection(); PreparedStatement stmt = conn.preparedStatement("select 1"); ResultSet rs = stmt.executeQuery(); while (rs.next()) { } rs.close(); stmt.close(); conn.close();
Test the performance comparison of 1,000,000 (1 million) times of the total time spent executing requests in various concurrent scenarios.
Environment
- OS Linux 3.5.0-19-generic x86_64
- CPU XEON e5-2450 Dual Total 16 core 32 physical thread
- Memory 48G
This is a two-way Xeon CPU workstation, which is closer to the real server environment than the one I tested on Mac book Pro.
JDK 1.6.0_38
Database Connection Pool |
1 thread |
2 Threads |
5 Threads |
Ten Threads |
Threads |
Threads |
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 |
JDK 1.7.0_10
Database Connection Pool |
1 thread |
2 Threads |
5 Threads |
Ten Threads |
Threads |
Threads |
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 |
Results analysis
- Druid is the best-performing database connection pool, with TOMCAT-JDBC and Druid performance approaching.
- Proxool in the intense concurrency will throw abnormal, completely not reliable. In the case of concurrency 10, 11 or 12 physical connections are used.
- C3P0 and Proxool are fairly slow and slow to the point where SQL execution is inefficient.
- BONECP performance is not superior, the use of linkedtransferqueue has not been able to achieve performance gains.
- Jboss-datasource stable, but poor performance
- BONECP and c3p0 completely do not follow the minpoolsize configuration, as long as there is an activity request, it will use the maxpoolsize.
- BONECP and C3P0 have large concurrent use of more than maxpoolsize number of physical connections, reaching maxpoolsize+1
Transferred from: Https://github.com/alibaba/druid/wiki/linux-benchmark