惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 子福当自强

vue element plus el-dropdown实现command传递多个参数最简单方式 centos 8 安装 nodejs npm centos 8 安装 minio centos 8 安装 ngingx 1.20 centos 8 安装 mysql 8 centos 8 安装 redis 6 centos 8 rpm安装oracle jdk 11 CentOS 8.2远程连接vncserver升级后1.10.1无法启动解决记录 Eclipse:Cannot complete the install because of a conflicting dependency.问题解决 Android SDK更新以及ADT更新出现问题的解决办法 - 子福当自强 Visual Studio 2013开启JavaScript的智能提示功能 linux中mysql密码找回的两种方式 Oracle 物化视图 说明 linux下mysql字符集编码问题的修改 mysql 启动错误-server PID file could not be found - 子福当自强 在linux安装mysql,并设置远程访问 mysql安装过程中出现错误ERROR 1820 (HY000): You must SET PASSWORD before executing this statement解决 - 子福当自强 linux 下面 jdk1.7 rpm 包的安装 网页导航栏设计模式
java数据库连接池性能对比
子福当自强 · 2014-08-05 · via 博客园 - 子福当自强

这个测试的目的是验证当前常用数据库连接池的性能。

testcase

  Connection conn = dataSource.getConnection();
  PreparedStatement stmt = conn.preparedStatement("select 1");
  ResultSet rs = stmt.executeQuery();
  while (rs.next()) {
  }
  rs.close();
  stmt.close();
  conn.close();

测试各种并发场景下执行申请1,000,000(一百万)次总耗时的性能对比。

环境

  • OS linux 3.5.0-19-generic X86_64
  • CPU XEON E5-2450 双路共16核32物理线程
  • Memory 48G

这是一台双路至强CPU的工作站,比我之前在mac book pro上做的测试,更接近真实服务器的运行环境。

JDK 1.6.0_38

数据库连接池 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

JDK 1.7.0_10

数据库连接池 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

结果分析

  1. Druid是性能最好的数据库连接池,tomcat-jdbc和druid性能接近。
  2. proxool在激烈并发时会抛异常,完全不靠谱。在并发10的情况下,会使用11或者12个物理连接。
  3. c3p0和proxool都相当慢,慢到影响sql执行效率的地步。
  4. bonecp性能并不优越,采用LinkedTransferQueue并没有能够获得性能提升。
  5. jboss-datasource虽然稳定,但是性能很糟糕
  6. boneCP和c3p0完全不遵循minPoolSize的配置,只要有活动请求,就会用到maxPoolSize。
  7. bonecp和c3p0存在较大并发时使用的物理连接超过maxPoolSize数量,达到maxPoolSize+1

转自:https://github.com/alibaba/druid/wiki/linux-benchmark