Presentation is loading. Please wait.

Presentation is loading. Please wait.

Druid数据库连接池的特点 稳定 高效率 可扩展 可监控 可动态配置 防SQL注入. 温绍锦(温高铁)

Similar presentations


Presentation on theme: "Druid数据库连接池的特点 稳定 高效率 可扩展 可监控 可动态配置 防SQL注入. 温绍锦(温高铁)"— Presentation transcript:

1 温绍锦(温高铁) http://weibo.com/wengaotie

2 Druid数据库连接池的特点 稳定 高效率 可扩展 可监控 可动态配置 防SQL注入

3 稳定 阿里巴巴大规模部署 我们大规模使用中,开源连接池只有两个是稳定的: 应用超过500个 部署实例超过3000 最大集群超过60台
Druid DataSource Jboss DataSource (历史原因还在使用)

4 稳定的特性-ExceptionSorter
当连接产生不可恢复的异常时,需要及时从连接池中清除,否则会产生大量错误。这个功能也称为ExceptionSorter,只有JBossDataSource和DruidDataSource实现了这个功能。

5 Oracle Fatal Excetion Error Code 28 Session has been killed 600
Internal oracle error 1012 Not logged on 1014 Oracle shutdown in progress 1033 Oracle initialization or shutdown in progress 1034 Oracle not available 1035 ORACLE only available to users with RESTRICTED SESSION privilege 1089 Immediate shutdown in progres – no operations are permitted 1090 Shutdown in progress – no operations are permitted 1092 ORACLE instance terminated. Disconnection forced 1094 ALTER DATABASE CLOSE in progress. Connections not permitted

6 MySql Fatal Exception Error Code 1040 ER_CON_COUNT_EEROR 1042
ER_BAD_HOST_ERRROR 1043 ER_HANDSHAKE_ERROR 1047 ER_UNKOWN_COM_ERROR 1081 ER_IPSOCK_ERROR 1029 ER_HOST_IS_BLOCKED 1030 ER_HOST_NOT_PRIVILEGED 1045 ER_ACCESS_DENIED_ERROR 1004 ER_CANT_CREATE_FILE 1005 ER_CANT_CREAT_TABLE 1015 ER_CANT_LOCK 1021 ER_DISK_FULL

7 高性能 Druid是目前性能最好的数据库连接池 1 线程 2 线程 5 线程 10 线程 20线程 50线程 Druid 1,102
1,509 1,889 1,904 2,007 1,977 Tomcat-jdbc 1,399 1,378 2,257 2,289 2,305 2,503 DBCP 3,144 3,834 6,276 6,408 6,563 6,783 BoneCP 4,327 3,598 3,800 5,242 9,402 19,066 Jboss-Datasource 4,912 3,049 6,868 6,512 40,146 43,748 C3P0 18,570 19,467 15,270 19,294 28,195 66,677 Proxool 16,221 14,455 24,688 38,905 48,087 (Error) 58,238 详细测试信息: Druid是目前性能最好的数据库连接池

8

9 SQL Parser Parser基本概念 词法分析 Token 语法分析 抽象语法树 表达式 语句

10 手写Parser的性能 Cobar的SQL Parser,从Antlr生成的parser修改为Druid Parser之后,大约提升6倍的性能。 Druid Parser最近再次大幅度提升性能(50%) SQL Parser的关键在于词法 词法分析要支持预测

11 监控

12 Spring关联监控

13 Web关联监控

14 查看SQL执行明细 配置filters=log4j
:10:17,966 [DEBUG] Connection:132 - {conn-10001} connected :10:17,970 [DEBUG] Connection:132 - {conn-10001} commited :10:17,970 [DEBUG] Connection:132 - {conn 10001} rollback :10:17,983 [DEBUG] Statement:137 - {conn-10001, stmt-20000} created :10:17,986 [DEBUG] Statement:137 - {conn-10001, stmt-20000} executed millis. SELECT 1 :10:17,986 [DEBUG] Statement:137 - {conn-10001, stmt-20000} batch executed millis. SELECT 1 :10:18,205 [DEBUG] Statement:137 - {conn-10001, stmt-20000, rs-50000} query executed millis. SELECT 1 :10:18,205 [DEBUG] ResultSet:142 - {conn-10001, stmt-20000, rs-50000} open :10:18,206 [DEBUG] ResultSet:142 - {conn-10001, stmt-20000, rs-50000} Header: [null] :10:18,206 [DEBUG] Statement:137 - {conn-10001, stmt-20000} update executed. effort millis. SELECT 1 :10:18,223 [DEBUG] Statement:137 - {conn-10001, pstmt-20001} created. SELECT 1 :10:18,260 [DEBUG] Statement:137 - {conn-10001, pstmt-20001} Parameters : [null, null, null, null, 1, null, null, 1.0, 1, 1, null, null, null, null, 1, , null, null, null, null] :10:18,260 [DEBUG] Statement:137 - {conn-10001, pstmt-20001} Types : [ARRAY, OTHER, DECIMAL, OTHER, BLOB, TINYINT, OTHER, OTHER, CLOB, DATE, FLOAT, INTEGER, BIGINT, OTHER, NCLOB, NVARCHAR, VARCHAR, OTHER, REF, ROWID, SMALLINT, SQLXML, VARCHAR, TIME, TIMESTAMP, OTHER, OTHER] :10:18,260 [DEBUG] Statement:137 - {conn-10001, pstmt-20001} executed millis. SELECT 1 :10:18,260 [DEBUG] Statement:137 - {conn-10001, pstmt-20001} batch executed millis. SELECT 1 :10:18,262 [DEBUG] Statement:137 - {conn-10001, pstmt-20001} Types : [ARRAY, OTHER, DECIMAL, OTHER, BLOB, TINYINT, OTHER, OTHER, CLOB, DATE, FLOAT, INTEGER, BIGINT, OTHER, NCLOB, NVARCHAR, VARCHAR, OTHER, REF, ROWID, SMALLINT, SQLXML, VARCHAR, TIME, TIMESTAMP, OTHER, OTHER] :10:18,262 [DEBUG] Statement:137 - {conn-10001, pstmt-20001, rs-50001} query executed millis. SELECT 1 :10:18,262 [DEBUG] ResultSet:142 - {conn-10001, pstmt-20001, rs-50001} open :10:18,263 [DEBUG] ResultSet:142 - {conn-10001, pstmt-20001, rs-50001} Header: [null] :10:18,263 [DEBUG] Statement:137 - {conn-10001, pstmt-20001} Parameters : [null, null, null, null, 1, null, null, 1.0, 1, 1, null, null, null, null, 1, , null, null, null, null] :10:18,263 [DEBUG] Statement:137 - {conn-10001, pstmt-20001} Types : [ARRAY, OTHER, DECIMAL, OTHER, BLOB, TINYINT, OTHER, OTHER, CLOB, DATE, FLOAT, INTEGER, BIGINT, OTHER, NCLOB, NVARCHAR, VARCHAR, OTHER, REF, ROWID, SMALLINT, SQLXML, VARCHAR, TIME, TIMESTAMP, OTHER, OTHER] :10:18,263 [DEBUG] Statement:137 - {conn-10001, pstmt-20001} update executed. effort millis. SELECT 1 :10:18,274 [DEBUG] Statement:137 - {conn-10001, cstmt-20002} created. SELECT 1 :10:18,274 [DEBUG] Statement:137 - {conn-10001, stmt-20000, rs-50002} query executed millis. SELECT 1 :10:18,274 [DEBUG] ResultSet:142 - {conn-10001, stmt-20000, rs-50002} open :10:18,274 [DEBUG] ResultSet:142 - {conn-10001, stmt-20000, rs-50002} Header: [null] :10:18,275 [DEBUG] ResultSet:142 - {conn-10001, stmt-20000, rs-50002} Result: [1]

15 防御SQL注入 配置filters=“wall” 智能拦截永真条件 智能拦截系统函数调用 智能拦截系统表访问

16 集中配置、动态配置 filters=“config” 支持数据库密码加密 支持从本地或者http远程读取配置文件


Download ppt "Druid数据库连接池的特点 稳定 高效率 可扩展 可监控 可动态配置 防SQL注入. 温绍锦(温高铁)"

Similar presentations


Ads by Google