SlideShare ist ein Scribd-Unternehmen logo
1 von 92
Downloaden Sie, um offline zu lesen
Java MySQL Connector &
Connection Pool
Features & Optimization
Kenny Gryp
<kenny.gryp@percona.com>
April 14, 2015
@gryp
DISCLAIMER
Please excuse me for
not being a Java
developer
2
What I Don’t Like
• Brussels Sprouts
• Taxes
• Calories
• Java(’s chattiness)
3
MYSQL CONNECTORS
CONNECTION POOLS
4
MYSQL CONNECTORS
CONNECTION POOLS
Connectors
Configuring Connector
Creating A Database
Connection
Prepared Statements
Example Transaction
5
MySQL Connector/J & MariaDB Java
Client
• MySQL Connector/J
– Oracle
– 5.1.35 Latest
– Compatible with
• MySQL
• Percona Server
• MariaDB
6
MySQL Connector/J & MariaDB Java
Client
• MariaDB Java Client
• MariaDB
• Fork from Drizzle Connector
• Latest 1.1.8
• Compatible with
– MySQL
– Percona Server
– MariaDB
7
MySQL Connector/J Features
• Enterprise Plugin: Query Analyzer
• MySQL Fabric Integration
• Load Balancing
• Failover
• Replication
8
MYSQL CONNECTORS
CONNECTION POOLS
Connectors
Configuring
Connector
Creating A Database
Connection
Prepared Statements Example Transaction
9
Creating Connection
Connection con =
DriverManager.getConnection
(“jdbc:mysql://node2/employees?
user=connj&password=test");
Statement stmt = con.createStatement();
String query =
"select * from employees
where emp_no = 20000;";
ResultSet rs = stmt.executeQuery(query);
...
MariaDB:
jdbc:mariadb://node2/employees
?user=connj&password=test"
10
Creating Connection - Tomcat w. JDBC-
Pool
context.xml (local):
<Resource name="jdbc/test"
auth="Container"
type="javax.sql.DataSource"
username=“jdbc-pool" password="test"
driverClassName="com.mysql.jdbc.Driver"
url=“jdbc:mysql://node2:3306/employees”
/>
MariaDB:
driverClassName="org.mariadb.jdbc.Driver"
11
Creating Connection - JDBC URL
jdbc:mysql://node2:3306/employees?
useServerPrepStmts=true&...
12
MYSQL CONNECTORS
CONNECTION POOLS
Connectors
Configuring Connector
Creating A Database
Connection
Prepared Statements
Example Transaction
13
Connector/J - Creating Connection
SHOW VARIABLES WHERE
Variable_name ='language' OR…
SELECT
@@session.auto_increment_increment;
SET NAMES latin1;
SET character_set_results = NULL;
SET autocommit=1;
SET sql_mode=
'NO_ENGINE_SUBSTITUTION,STRICT_TRAN
S_TABLES';
14
MariaDB - Creating Connection
set autocommit=1;
USE employees;
show variables like 'sql_mode';
15
Creating Connection - Defaults
• Connector/J:
• MariaDB Java

Client:
16
Connector/J & MariaDB Java Client -
Verbosity
• Connector/J is more verbose when starting a
connection
• Usually not a problem:
– connection pools are commonly used

(more coming soon…)
– connections are reused
– Actually I like but not too much.
17
Optimization
• MariaDB Java Client vs MySQL Connector/J
• Prepared Statements
18
Connector Performance - SELECT 1
localhost, single threaded 19
QPS
0
4000
8000
12000
16000
localhost
ConnectorJ MariaDB
15.213
13.477
Connector Performance - MariaDB %faster
20
Faster%
5%
10%
15%
20%
MariaDB Connector +Speed% ConnectorJ
SELECT1 LO
13%
Connector Performance - MariaDB %faster
21
Faster%
5%
10%
15%
20%
MariaDB Connector +Speed% ConnectorJ
SELECT1 LO SELECT1 net pk range
0%
4%4%
13%
Benefit is relative!
MYSQL CONNECTORS
CONNECTION POOLS
Connectors
Configuring Connector
Creating A Database
Connection
Prepared Statements
Example Transaction
22
Client or Server Side Prepared Statements
• Server side Prepared statements:
– reduce network traffic
– query is already optimized on server.
• Support:
– MariaDB Java client only supports client
side
– Connector/J default in client side
23
Server Side Prepared Statements
PREPARE stmt1 FROM
select * from employees
where emp_no = ?;
EXECUTE # API CALL
select * from employees
where emp_no = 20000;
DEALLOCATE PREPARE stmt1;
24
Connector/J: Server Side Prepared
Statements
• useServerPrepStmts = false
– disabled by default
• Mind looking at:
– cachePrepStmts = false
• do PREPARE, EXECUTE, DEALLOCATE
every time…, 3 round trips?
– prepStmtCacheSize = 25
– prepStmtCacheSqlLimit = 256
• low defaults
25
https://bugs.mysql.com/bug.php?id=74932
Benchmark: Prepared Statements
26
QPS
900
1800
2700
3600
MariaDB CONN/J CONN/J SRVCONN/J SRV+Cache
3.506QPS
2.047QPS
3.342QPS3.400QPS
select * from employees_alotofindexes
where first_name='moss' and birth_date > "1954-06-14"
and gender="M" and hire_date > "1998-01-01"G
Cracked!!
27
MYSQL CONNECTORS
CONNECTION POOLS
Connectors
Configuring Connector
Creating A Database
Connection
Prepared Statements
Example Transaction
28
Connector/J Optimization + Default JDBC-
Pool
Connection con = ds.getConnection();
con.setTransactionIsolation
(Connection.TRANSACTION_READ_COMMITTED);
con.setAutoCommit(false);
PreparedStatement stmt =
con.prepareStatement("select * from
employees where emp_no = ?");
stmt.setInt(1, 20000);
ResultSet rs = stmt.executeQuery();
stmt.close();
rs.close();
con.commit();
con.close();
29
Connector/J Optimization + Default JDBC-
Pool
SET SESSION TRANSACTION
ISOLATION LEVEL READ COMMITTED;
SET autocommit=0;
# administrator command: Prepare;
select * from employees
where emp_no = 20000;
# administrator command: Close stmt;
commit;
30
Taxes
Connector/J Optimization
• useConfigs=maxPerformance
– cachePrepStmts=true
– cacheCallableStmts=true
– cacheServerConfiguration=true
– useLocalSessionState=true
– elideSetAutoCommits=true
– alwaysSendSetIsolation=false
– enableQueryTimeouts=false
31
Connector/J Optimization
• useLocalTransactionState=true

commit() / rollback()
32
Connector/J Optimization - Tuned
JDBC URL: useConfigs=maxPerformance&
useServerPrepStmts=true:
select * from employees
where emp_no = 20000;
commit;
33
MariaDB Java Client Optimization
SET SESSION TRANSACTION
ISOLATION LEVEL READ COMMITTED;
select * from employees
where emp_no = 20000;
COMMIT;
34
MariaDB Java Client Optimization - Code
if
(
con.getTransactionIsolation() !=
Connection.TRANSACTION_READ_COMMITTED
)
{
con.setTransactionIsolation
(Connection.TRANSACTION_READ_COMMITTED);
}
35
MariaDB Java Client Optimization -
Interceptors
SELECT @@tx_isolation;
select * from employees
where emp_no = 20000;
COMMIT;
Still @@tx_isolation. Now add JDBC Interceptor:
<Resource name="jdbc/test"
auth="Container"
factory=
"org.apache.tomcat.jdbc.pool.DataSourceFactory"
jdbcInterceptors="ConnectionState"
driverClassName="org.mariadb.jdbc.Driver"
url="jdbc:mysql://node2:3306/employees"/>
36
MariaDB Java Client Optimization -
Optimized!
select * from employees
where emp_no = 20000;
COMMIT;
37
Benchmark - Connector Concurrency -
SELECT 1 38
HikariCP-bench with JDBC Pool, 4 Threads, SELECT 1 (4,8,16,32
Pool Size)
QPS
17.500
35.000
52.500
70.000
MariaDB CONN/J
Benchmark - Connector Concurrency -
TRX 39
HikariCP-bench with JDBC Pool, 4 Threads, TRX (4,8,16,32 Pool
Size)
QPS
4.750
9.500
14.250
19.000
Conn/J MariaDB Conn/J Optim MariaDB Optim
MYSQL CONNECTORS
CONNECTION POOLS
40
MYSQL CONNECTORS
CONNECTION POOLS
Connection Pools
Issues
Resetting Environment
Testing Connectivity
Pool Sizing
Lingering Transactions
Analysis
Examples
Graceful Failover
Conn/J Extra Features
41
Java Connection Pools
– The Usual:
– C3P0
– Commons-DBCP (v1&v2)
– JDBC Pool (fork commons-DBCP)
– Out In The Wild:
– Vibur-DBCP
– HikariCP
– BoneCP
42
Java Connection Pools
– The Usual:
– C3P0
– Commons-DBCP (v1&v2)
– JDBC Pool (fork commons-DBCP)
– Out In The Wild:
– Vibur-DBCP
– HikariCP
– BoneCP
43
Connection Pool Key Points
• Connection Management
• Pool Sizing
• Connection Testing
• Avoid Lingering Transactions
44
MYSQL CONNECTORS
CONNECTION POOLS
Connection Pools
Issues
Resetting Environment
Testing Connectivity
Pool Sizing
Lingering Transactions
Analysis
Examples
Graceful Failover
Conn/J Extra Features
45
Connection Pool Issues
• Coming from DBA side, I do not like
‘chattiness’
46
Connection Pool Issues
47
Connection Pool Issues
48
Connection Pool Issues
49
Connection Pool Issues
50
WHY DOES IT HAVE TO DO
THAT?
Because of
‘application bugs’
51
Connection Pools - Why Chattiness
Examples
• *maybe* forgot to COMMIT / ROLLBACK
• wanting AUTOCOMMIT=1

but a previous TRX set it to 0
• Changing TRX Isolation Level
• Is connection still working?
52
MYSQL CONNECTORS
CONNECTION POOLS
Connection Pools
Issues
Resetting
Environment
Testing Connectivity
Pool Sizing
Lingering Transactions
Analysis
Examples
Graceful Failover
Conn/J Extra Features
53
Connection Pool - Resetting Status
54
JDBC-Pool C3P0 DBCP2 HikariCP
Rollback rollbackOnReturn=false autoCommitOnClose=false rollbackOnReturn

=true
Commit commitOnReturn=false autoCommitOnClose=false n/a n/a
Avoid see above forceIgnoreUnresolvedTransa
ctions=false
see above
Auto
Commit
Driver Driver enableAutoCommit

OnReturn=true
Driver
MYSQL CONNECTORS
CONNECTION POOLS
Connection Pools
Issues
Resetting Environment
Testing Connectivity
Pool Sizing
Lingering Transactions
Analysis
Examples
Graceful Failover
Conn/J Extra Features
55
Connection Pool - Testing
• Making sure the connection is still active
• If not, maybe reopen a connection
• Not recommended as DB
• However, applications:
• do not like errors
• do not retry gracefully
56
Connection Pool - Testing
• If connections REALLY need to be tested…
• do not specify test query like:
• SELECT 1
• SELECT * FROM DUAL
• Leave default, all of the connection pools
use:

JDBC4 isValid();
57
Connection Pool - Testing
58
JDBC-Pool C3P0 DBCP2 HikariCP
Test Before testOnBorrow=false testConnectionOnCheckOut

=false
testOnBorrow=false n/a
Test After testOnReturn=false testConnectionOnCheckIn

=false
testOnReturn=false n/a
Test While Idle testWhileIdle=false idleConnectionTestPeriod

=0
testWhileIdle=false n/a
JDBC4
isValid()
default default default jdbc4ConnectionTest

=true (default)
Query validationQuery

(isValid)
preferredTestQuery=null validationQuery

(isValid)
connectionTestQuery

=none
Interval? validationInterval=30000 n/a n/a n/a
Connection Pool - Testing
• JDBC: validationInterval=30s

WHY? It defeats the whole purpose!
59
MYSQL CONNECTORS
CONNECTION POOLS
Connection Pools
Issues
Resetting Environment
Testing Connectivity
Pool Sizing
Lingering Transactions
Analysis
Examples
Graceful Failover
Conn/J Extra Features
60
Connection Pool - Pool Sizing
• Funnelling on Application Level, is good
• Smaller Number is Better
• +- * CPU’s on DB
• maybe a bit more (waiting on IO…)
• all application servers combined
• Response Time vs Throughput
61
Connection Pool - Pool Sizing
62
JDBC-Pool C3P0 DBCP2 HikariCP
Amount of
Connections
maxActive=100 maxPoolSize=15 maxTotal=8 maximumPoolSize=10
Maximum Idle
Connections
maxIdle=100 maxIdleTime=0** maxIdle=8 n/a
Minimum Idle
Connections
minIdle=10 minPoolSize=3 minIdle=0 minimumIdle=max
Startup Size initialSize=10 initialPoolSize=3 initialSize=0 minimumIdle
MYSQL CONNECTORS
CONNECTION POOLS
Connection Pools
Issues
Resetting Environment
Testing Connectivity
Pool Sizing
Lingering
Transactions
Analysis
Examples
Graceful Failover
Conn/J Extra Features
63
Connection Pool - Avoid Lingering
Transactions
• Application forgets to return the connection
• Statements that take longer than …
• Avoid this!
• Fix Application
64
Connection Pool - Avoid Lingering
Transactions 65
KILL Warning
JDBC-Pool removeAbandoned=false

removeAbandonedTimeout=60

abandonWhenPercentageFull=0
suspectTimeout=0
C3P0 unreturnedConnectionTimeout=0 n/a
DBCP removeAbandoned=false

removeAbandonedTimeout=300

Only When: 

getNumIdle() < 2 and
getNumActive() > getMaxTotal() - 3)
n/a
HikariCP n/a leakDetectionThreshold=0
MYSQL CONNECTORS
CONNECTION POOLS
Connection Pools
Issues
Resetting Environment
Testing Connectivity
Pool Sizing
Lingering Transactions
Analysis
Examples
Graceful Failover
Conn/J Extra Features
66
Connection Pools - How To Look At
Workload?
• Slow Query Log
• tcpdump
• pt-query-digest
• Percona Cloud Tools
67
MYSQL CONNECTORS
CONNECTION POOLS
Connection Pools
Issues
Resetting Environment
Testing Connectivity
Pool Sizing
Lingering Transactions
Analysis
Examples
Graceful Failover
Conn/J Extra Features
68
Connection Pool - Example Transaction
Connection con = ds.getConnection();
con.setTransactionIsolation
(Connection.TRANSACTION_READ_COMMITTED);
con.setAutoCommit(false);
PreparedStatement stmt =
con.prepareStatement("select * from
employees where emp_no = ?");
stmt.setInt(1, 20000);
ResultSet rs = stmt.executeQuery();
stmt.close();
rs.close();
con.commit();
con.close();
69
For Connectors - RECAP
• MySQL Connector/J
• useConfigs=maxPerformance
• useServerPrepStmts=true
• MariaDB Java Client
• HikariCP: Built in
• JDBC-Pool:
jdbcInterceptors=“ConnectionState"
• Other Pools: UNKNOWN
70
Connection Pool - TRX JDBC
select * from employees
where emp_no = 20000;
commit;
71
200
Connection Pool - TRX C3P0
SET SESSION TRANSACTION
ISOLATION LEVEL READ COMMITTED;
SET autocommit=0;
select * from employees
where emp_no = 20000;
commit;
SET autocommit=1;
SET SESSION TRANSACTION
ISOLATION LEVEL REPEATABLE READ;
72
600
Connection Pool - TRX C3P0
mysql> set global
tx_isolation=“READ-COMMITTED”;
forceIgnoreUnresolvedTransactions=true
73
200
Connection Pool - TRX DBCP
SET autocommit=1;
# administrator command: Ping;
SET autocommit=0;
select * from employees
where emp_no = 20000;
commit;
rollback;
SET autocommit=1;
74
700
Connection Pool - TRX DBCP
testOnBorrow=false
rollbackOnReturn=false
enableAutoCommitOnReturn=false
jdbcUrl: useLocalTransactionState=true
75
200
Connection Pool - TRX HikariCP
SET SESSION TRANSACTION
ISOLATION LEVEL READ COMMITTED;
SET autocommit=0;
select * from employees
where emp_no = 20000;
commit;
SET autocommit=1;
SET SESSION TRANSACTION
ISOLATION LEVEL REPEATABLE READ;
76
600
Connection Pool - TRX HikariCP
mysql> set global
tx_isolation=“READ-COMMITTED”;
autoCommit=false
77
200
Connection Pools
78
MariaDB vs. Connector/J
79
MYSQL CONNECTORS
CONNECTION POOLS
Connection Pools
Issues
Resetting Environment
Testing Connectivity
Pool Sizing
Lingering Transactions
Analysis
Examples
Graceful Failover
Conn/J Extra Features
80
Connection Pools - Graceful Failover
81
Connection Pools - Graceful Failover
• HAProxy ‘stats socket’
/etc/haproxy/haproxy.cfg
global
. . .
stats socket /tmp/haproxy.sock level admin
• Disable Node
# echo "disable server database/node1" 

| socat stdio /tmp/haproxy.sock
82
Connection Pools - Graceful Failover
83
Connection Pools - Graceful Failover
• During ‘maintenance’, what do we do?
• KILL old connections?
• Wait until connections are closed? (Define
lifetimes?)
• Ignore it?
84
Connection Pools - Graceful Failover
• Some connection pools can close
connections gracefully, when idle.
• For ‘synchronous’ replication systems
• using JMX
• No Application Errors!
85
Method
JDBC-Pool purgeOnReturn()
C3P0 softResetAllUsers()
DBCP n/a
HikariCP softEvictConnections(),
suspendPool(), resumePool() <—- ASYNC
Connection Pools - Graceful Failover
86
Connection Pools - Graceful Failover
87
Connection Pools - Graceful Failover
88
Connection Pools - Graceful Failover
• 0 Application Errors
• Completely seamless
89
MYSQL CONNECTORS
CONNECTION POOLS
Connection Pools
Issues
Resetting Environment
Testing Connectivity
Pool Sizing
Lingering Transactions
Analysis
Examples
Graceful Failover
Conn/J Extra
Features
90
Connector/J - Extra Features
• Load Balancing
• jdbcUrl: ”jdbc:mysql:loadbalance://
node1,node2/db?
loadBalanceConnectionGroup=lb&

loadBalanceEnableJMX=true”
• loadBalanceStrategy 

(random/bestResponseTime)
• Failover
• ReplicationDriver (setReadOnly)
• Combining with Connection Pools is less useful
• Fabric
91
Java MySQL Connector & 

Connection Pool Optimization
• http://dev.mysql.com/doc/connector-j/en
• https://mariadb.com/kb/en/mariadb/client-libraries/mariadb-java-
client/
• http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html
• http://www.mchange.com/projects/c3p0
• http://commons.apache.org/proper/commons-dbcp/
• https://github.com/brettwooldridge/HikariCP
92
MYSQL CONNECTORS
CONNECTION POOLS
Kenny Gryp
<kenny.gryp@percona.com>
November 4, 2014
@gryp

Weitere ähnliche Inhalte

Was ist angesagt?

My sql failover test using orchestrator
My sql failover test  using orchestratorMy sql failover test  using orchestrator
My sql failover test using orchestratorYoungHeon (Roy) Kim
 
MySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & OperationsMySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & OperationsFrederic Descamps
 
Where狙いのキー、order by狙いのキー
Where狙いのキー、order by狙いのキーWhere狙いのキー、order by狙いのキー
Where狙いのキー、order by狙いのキーyoku0825
 
MySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group ReplicationMySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group ReplicationFrederic Descamps
 
The MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer TraceThe MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer Traceoysteing
 
ソーシャルゲーム案件におけるDB分割のPHP実装
ソーシャルゲーム案件におけるDB分割のPHP実装ソーシャルゲーム案件におけるDB分割のPHP実装
ソーシャルゲーム案件におけるDB分割のPHP実装infinite_loop
 
MySQL InnoDB Cluster and Group Replication in a Nutshell: hands-on tutorial
MySQL InnoDB Cluster and Group Replication in a Nutshell:  hands-on tutorialMySQL InnoDB Cluster and Group Replication in a Nutshell:  hands-on tutorial
MySQL InnoDB Cluster and Group Replication in a Nutshell: hands-on tutorialFrederic Descamps
 
MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바NeoClova
 
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query PerformanceUsing Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performanceoysteing
 
Time-Based Blind SQL Injection
Time-Based Blind SQL InjectionTime-Based Blind SQL Injection
Time-Based Blind SQL Injectionmatt_presson
 
雑なMySQLパフォーマンスチューニング
雑なMySQLパフォーマンスチューニング雑なMySQLパフォーマンスチューニング
雑なMySQLパフォーマンスチューニングyoku0825
 
MySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptxMySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptxNeoClova
 
Intro to MySQL Master Slave Replication
Intro to MySQL Master Slave ReplicationIntro to MySQL Master Slave Replication
Intro to MySQL Master Slave Replicationsatejsahu
 
MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용I Goo Lee
 
Zabbixのパフォーマンスチューニング & インストール時の注意点
Zabbixのパフォーマンスチューニング & インストール時の注意点Zabbixのパフォーマンスチューニング & インストール時の注意点
Zabbixのパフォーマンスチューニング & インストール時の注意点Kodai Terashima
 
MariaDB MaxScale monitor 매뉴얼
MariaDB MaxScale monitor 매뉴얼MariaDB MaxScale monitor 매뉴얼
MariaDB MaxScale monitor 매뉴얼NeoClova
 
Replication Troubleshooting in Classic VS GTID
Replication Troubleshooting in Classic VS GTIDReplication Troubleshooting in Classic VS GTID
Replication Troubleshooting in Classic VS GTIDMydbops
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesCarol McDonald
 
大規模・長期保守を見据えたエンタープライズ システム開発へのSpring Frameworkの適用
大規模・長期保守を見据えたエンタープライズシステム開発へのSpring Frameworkの適用大規模・長期保守を見据えたエンタープライズシステム開発へのSpring Frameworkの適用
大規模・長期保守を見据えたエンタープライズ システム開発へのSpring Frameworkの適用apkiban
 

Was ist angesagt? (20)

My sql failover test using orchestrator
My sql failover test  using orchestratorMy sql failover test  using orchestrator
My sql failover test using orchestrator
 
MySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & OperationsMySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & Operations
 
Where狙いのキー、order by狙いのキー
Where狙いのキー、order by狙いのキーWhere狙いのキー、order by狙いのキー
Where狙いのキー、order by狙いのキー
 
MySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group ReplicationMySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group Replication
 
The MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer TraceThe MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer Trace
 
ソーシャルゲーム案件におけるDB分割のPHP実装
ソーシャルゲーム案件におけるDB分割のPHP実装ソーシャルゲーム案件におけるDB分割のPHP実装
ソーシャルゲーム案件におけるDB分割のPHP実装
 
ヤフー社内でやってるMySQLチューニングセミナー大公開
ヤフー社内でやってるMySQLチューニングセミナー大公開ヤフー社内でやってるMySQLチューニングセミナー大公開
ヤフー社内でやってるMySQLチューニングセミナー大公開
 
MySQL InnoDB Cluster and Group Replication in a Nutshell: hands-on tutorial
MySQL InnoDB Cluster and Group Replication in a Nutshell:  hands-on tutorialMySQL InnoDB Cluster and Group Replication in a Nutshell:  hands-on tutorial
MySQL InnoDB Cluster and Group Replication in a Nutshell: hands-on tutorial
 
MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바
 
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query PerformanceUsing Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performance
 
Time-Based Blind SQL Injection
Time-Based Blind SQL InjectionTime-Based Blind SQL Injection
Time-Based Blind SQL Injection
 
雑なMySQLパフォーマンスチューニング
雑なMySQLパフォーマンスチューニング雑なMySQLパフォーマンスチューニング
雑なMySQLパフォーマンスチューニング
 
MySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptxMySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptx
 
Intro to MySQL Master Slave Replication
Intro to MySQL Master Slave ReplicationIntro to MySQL Master Slave Replication
Intro to MySQL Master Slave Replication
 
MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용
 
Zabbixのパフォーマンスチューニング & インストール時の注意点
Zabbixのパフォーマンスチューニング & インストール時の注意点Zabbixのパフォーマンスチューニング & インストール時の注意点
Zabbixのパフォーマンスチューニング & インストール時の注意点
 
MariaDB MaxScale monitor 매뉴얼
MariaDB MaxScale monitor 매뉴얼MariaDB MaxScale monitor 매뉴얼
MariaDB MaxScale monitor 매뉴얼
 
Replication Troubleshooting in Classic VS GTID
Replication Troubleshooting in Classic VS GTIDReplication Troubleshooting in Classic VS GTID
Replication Troubleshooting in Classic VS GTID
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security Vulnerabilities
 
大規模・長期保守を見据えたエンタープライズ システム開発へのSpring Frameworkの適用
大規模・長期保守を見据えたエンタープライズシステム開発へのSpring Frameworkの適用大規模・長期保守を見据えたエンタープライズシステム開発へのSpring Frameworkの適用
大規模・長期保守を見据えたエンタープライズ システム開発へのSpring Frameworkの適用
 

Andere mochten auch

Эффективная отладка репликации MySQL
Эффективная отладка репликации MySQLЭффективная отладка репликации MySQL
Эффективная отладка репликации MySQLSveta Smirnova
 
Mastering InnoDB Diagnostics
Mastering InnoDB DiagnosticsMastering InnoDB Diagnostics
Mastering InnoDB Diagnosticsguest8212a5
 
Reducing Risk When Upgrading MySQL
Reducing Risk When Upgrading MySQLReducing Risk When Upgrading MySQL
Reducing Risk When Upgrading MySQLKenny Gryp
 
Successful Scalability Principles - Part 1
Successful Scalability Principles - Part 1Successful Scalability Principles - Part 1
Successful Scalability Principles - Part 1Ronald Bradford
 
MySQL Server Defaults
MySQL Server DefaultsMySQL Server Defaults
MySQL Server DefaultsMorgan Tocker
 
MHA (MySQL High Availability): Getting started & moving past quirks
MHA (MySQL High Availability): Getting started & moving past quirksMHA (MySQL High Availability): Getting started & moving past quirks
MHA (MySQL High Availability): Getting started & moving past quirksColin Charles
 
10x Performance Improvements - A Case Study
10x Performance Improvements - A Case Study10x Performance Improvements - A Case Study
10x Performance Improvements - A Case StudyRonald Bradford
 
MySQL InnoDB Cluster and Group Replication - OSI 2017 Bangalore
MySQL InnoDB Cluster and Group Replication - OSI 2017 BangaloreMySQL InnoDB Cluster and Group Replication - OSI 2017 Bangalore
MySQL InnoDB Cluster and Group Replication - OSI 2017 BangaloreSujatha Sivakumar
 
Why MySQL Replication Fails, and How to Get it Back
Why MySQL Replication Fails, and How to Get it BackWhy MySQL Replication Fails, and How to Get it Back
Why MySQL Replication Fails, and How to Get it BackSveta Smirnova
 
Using Apache Spark and MySQL for Data Analysis
Using Apache Spark and MySQL for Data AnalysisUsing Apache Spark and MySQL for Data Analysis
Using Apache Spark and MySQL for Data AnalysisSveta Smirnova
 
The nightmare of locking, blocking and isolation levels!
The nightmare of locking, blocking and isolation levels!The nightmare of locking, blocking and isolation levels!
The nightmare of locking, blocking and isolation levels!Boris Hristov
 
A New Architecture for Group Replication in Data Grid
A New Architecture for Group Replication in Data GridA New Architecture for Group Replication in Data Grid
A New Architecture for Group Replication in Data GridEditor IJCATR
 
Advanced Percona XtraDB Cluster in a nutshell... la suite
Advanced Percona XtraDB Cluster in a nutshell... la suiteAdvanced Percona XtraDB Cluster in a nutshell... la suite
Advanced Percona XtraDB Cluster in a nutshell... la suiteKenny Gryp
 
MySQL Replication Performance Tuning for Fun and Profit!
MySQL Replication Performance Tuning for Fun and Profit!MySQL Replication Performance Tuning for Fun and Profit!
MySQL Replication Performance Tuning for Fun and Profit!Vitor Oliveira
 
MySQL High Availability Deep Dive
MySQL High Availability Deep DiveMySQL High Availability Deep Dive
MySQL High Availability Deep Divehastexo
 
Mysql展示功能与源码对应
Mysql展示功能与源码对应Mysql展示功能与源码对应
Mysql展示功能与源码对应zhaolinjnu
 
Advanced mysql replication techniques
Advanced mysql replication techniquesAdvanced mysql replication techniques
Advanced mysql replication techniquesGiuseppe Maxia
 
Lessons Learned: Troubleshooting Replication
Lessons Learned: Troubleshooting ReplicationLessons Learned: Troubleshooting Replication
Lessons Learned: Troubleshooting ReplicationSveta Smirnova
 
Galera cluster for high availability
Galera cluster for high availability Galera cluster for high availability
Galera cluster for high availability Mydbops
 
Mysql high availability and scalability
Mysql high availability and scalabilityMysql high availability and scalability
Mysql high availability and scalabilityyin gong
 

Andere mochten auch (20)

Эффективная отладка репликации MySQL
Эффективная отладка репликации MySQLЭффективная отладка репликации MySQL
Эффективная отладка репликации MySQL
 
Mastering InnoDB Diagnostics
Mastering InnoDB DiagnosticsMastering InnoDB Diagnostics
Mastering InnoDB Diagnostics
 
Reducing Risk When Upgrading MySQL
Reducing Risk When Upgrading MySQLReducing Risk When Upgrading MySQL
Reducing Risk When Upgrading MySQL
 
Successful Scalability Principles - Part 1
Successful Scalability Principles - Part 1Successful Scalability Principles - Part 1
Successful Scalability Principles - Part 1
 
MySQL Server Defaults
MySQL Server DefaultsMySQL Server Defaults
MySQL Server Defaults
 
MHA (MySQL High Availability): Getting started & moving past quirks
MHA (MySQL High Availability): Getting started & moving past quirksMHA (MySQL High Availability): Getting started & moving past quirks
MHA (MySQL High Availability): Getting started & moving past quirks
 
10x Performance Improvements - A Case Study
10x Performance Improvements - A Case Study10x Performance Improvements - A Case Study
10x Performance Improvements - A Case Study
 
MySQL InnoDB Cluster and Group Replication - OSI 2017 Bangalore
MySQL InnoDB Cluster and Group Replication - OSI 2017 BangaloreMySQL InnoDB Cluster and Group Replication - OSI 2017 Bangalore
MySQL InnoDB Cluster and Group Replication - OSI 2017 Bangalore
 
Why MySQL Replication Fails, and How to Get it Back
Why MySQL Replication Fails, and How to Get it BackWhy MySQL Replication Fails, and How to Get it Back
Why MySQL Replication Fails, and How to Get it Back
 
Using Apache Spark and MySQL for Data Analysis
Using Apache Spark and MySQL for Data AnalysisUsing Apache Spark and MySQL for Data Analysis
Using Apache Spark and MySQL for Data Analysis
 
The nightmare of locking, blocking and isolation levels!
The nightmare of locking, blocking and isolation levels!The nightmare of locking, blocking and isolation levels!
The nightmare of locking, blocking and isolation levels!
 
A New Architecture for Group Replication in Data Grid
A New Architecture for Group Replication in Data GridA New Architecture for Group Replication in Data Grid
A New Architecture for Group Replication in Data Grid
 
Advanced Percona XtraDB Cluster in a nutshell... la suite
Advanced Percona XtraDB Cluster in a nutshell... la suiteAdvanced Percona XtraDB Cluster in a nutshell... la suite
Advanced Percona XtraDB Cluster in a nutshell... la suite
 
MySQL Replication Performance Tuning for Fun and Profit!
MySQL Replication Performance Tuning for Fun and Profit!MySQL Replication Performance Tuning for Fun and Profit!
MySQL Replication Performance Tuning for Fun and Profit!
 
MySQL High Availability Deep Dive
MySQL High Availability Deep DiveMySQL High Availability Deep Dive
MySQL High Availability Deep Dive
 
Mysql展示功能与源码对应
Mysql展示功能与源码对应Mysql展示功能与源码对应
Mysql展示功能与源码对应
 
Advanced mysql replication techniques
Advanced mysql replication techniquesAdvanced mysql replication techniques
Advanced mysql replication techniques
 
Lessons Learned: Troubleshooting Replication
Lessons Learned: Troubleshooting ReplicationLessons Learned: Troubleshooting Replication
Lessons Learned: Troubleshooting Replication
 
Galera cluster for high availability
Galera cluster for high availability Galera cluster for high availability
Galera cluster for high availability
 
Mysql high availability and scalability
Mysql high availability and scalabilityMysql high availability and scalability
Mysql high availability and scalability
 

Ähnlich wie Java MySQL Connector & Connection Pool Features & Optimization

DPC2007 PHP And Oracle (Kuassi Mensah)
DPC2007 PHP And Oracle (Kuassi Mensah)DPC2007 PHP And Oracle (Kuassi Mensah)
DPC2007 PHP And Oracle (Kuassi Mensah)dpc
 
Diving into the Deep End - Kafka Connect
Diving into the Deep End - Kafka ConnectDiving into the Deep End - Kafka Connect
Diving into the Deep End - Kafka Connectconfluent
 
PROGRAMMING IN JAVA- unit 5-part II
PROGRAMMING IN JAVA- unit 5-part IIPROGRAMMING IN JAVA- unit 5-part II
PROGRAMMING IN JAVA- unit 5-part IISivaSankari36
 
Chap3 3 12
Chap3 3 12Chap3 3 12
Chap3 3 12Hemo Chella
 
High-Performance JDBC Voxxed Bucharest 2016
High-Performance JDBC Voxxed Bucharest 2016High-Performance JDBC Voxxed Bucharest 2016
High-Performance JDBC Voxxed Bucharest 2016Vlad Mihalcea
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)Aurimas Mikalauskas
 
java database connectivity for java programming
java database connectivity for java programmingjava database connectivity for java programming
java database connectivity for java programmingrinky1234
 
OOP Lecture 17-DB Connectivity-Part1.pptx
OOP Lecture 17-DB Connectivity-Part1.pptxOOP Lecture 17-DB Connectivity-Part1.pptx
OOP Lecture 17-DB Connectivity-Part1.pptxTanzila Kehkashan
 
20151010 my sq-landjavav2a
20151010 my sq-landjavav2a20151010 my sq-landjavav2a
20151010 my sq-landjavav2aIvan Ma
 
Load Balancing MySQL with HAProxy - Slides
Load Balancing MySQL with HAProxy - SlidesLoad Balancing MySQL with HAProxy - Slides
Load Balancing MySQL with HAProxy - SlidesSeveralnines
 
MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012Colin Charles
 
12 Factor Scala
12 Factor Scala12 Factor Scala
12 Factor ScalaJoe Kutner
 
Exploring mysql cluster 7.4
Exploring mysql cluster 7.4Exploring mysql cluster 7.4
Exploring mysql cluster 7.4Ivan Ma
 
JavaOne 2015: 12 Factor App
JavaOne 2015: 12 Factor AppJavaOne 2015: 12 Factor App
JavaOne 2015: 12 Factor AppJoe Kutner
 
NIC 2013 - Hyper-V Replica
NIC 2013 - Hyper-V ReplicaNIC 2013 - Hyper-V Replica
NIC 2013 - Hyper-V ReplicaKristian Nese
 
ProxySQL for MySQL
ProxySQL for MySQLProxySQL for MySQL
ProxySQL for MySQLMydbops
 
Linux Kernel vs DPDK: HTTP Performance Showdown
Linux Kernel vs DPDK: HTTP Performance ShowdownLinux Kernel vs DPDK: HTTP Performance Showdown
Linux Kernel vs DPDK: HTTP Performance ShowdownScyllaDB
 
Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004
Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004
Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004derek_clark_ashmore
 

Ähnlich wie Java MySQL Connector & Connection Pool Features & Optimization (20)

JDBC.ppt
JDBC.pptJDBC.ppt
JDBC.ppt
 
DPC2007 PHP And Oracle (Kuassi Mensah)
DPC2007 PHP And Oracle (Kuassi Mensah)DPC2007 PHP And Oracle (Kuassi Mensah)
DPC2007 PHP And Oracle (Kuassi Mensah)
 
Diving into the Deep End - Kafka Connect
Diving into the Deep End - Kafka ConnectDiving into the Deep End - Kafka Connect
Diving into the Deep End - Kafka Connect
 
Disaster Recovery Site Implementation with MySQL
Disaster Recovery Site Implementation with MySQLDisaster Recovery Site Implementation with MySQL
Disaster Recovery Site Implementation with MySQL
 
PROGRAMMING IN JAVA- unit 5-part II
PROGRAMMING IN JAVA- unit 5-part IIPROGRAMMING IN JAVA- unit 5-part II
PROGRAMMING IN JAVA- unit 5-part II
 
Chap3 3 12
Chap3 3 12Chap3 3 12
Chap3 3 12
 
High-Performance JDBC Voxxed Bucharest 2016
High-Performance JDBC Voxxed Bucharest 2016High-Performance JDBC Voxxed Bucharest 2016
High-Performance JDBC Voxxed Bucharest 2016
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
 
java database connectivity for java programming
java database connectivity for java programmingjava database connectivity for java programming
java database connectivity for java programming
 
OOP Lecture 17-DB Connectivity-Part1.pptx
OOP Lecture 17-DB Connectivity-Part1.pptxOOP Lecture 17-DB Connectivity-Part1.pptx
OOP Lecture 17-DB Connectivity-Part1.pptx
 
20151010 my sq-landjavav2a
20151010 my sq-landjavav2a20151010 my sq-landjavav2a
20151010 my sq-landjavav2a
 
Load Balancing MySQL with HAProxy - Slides
Load Balancing MySQL with HAProxy - SlidesLoad Balancing MySQL with HAProxy - Slides
Load Balancing MySQL with HAProxy - Slides
 
MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012
 
12 Factor Scala
12 Factor Scala12 Factor Scala
12 Factor Scala
 
Exploring mysql cluster 7.4
Exploring mysql cluster 7.4Exploring mysql cluster 7.4
Exploring mysql cluster 7.4
 
JavaOne 2015: 12 Factor App
JavaOne 2015: 12 Factor AppJavaOne 2015: 12 Factor App
JavaOne 2015: 12 Factor App
 
NIC 2013 - Hyper-V Replica
NIC 2013 - Hyper-V ReplicaNIC 2013 - Hyper-V Replica
NIC 2013 - Hyper-V Replica
 
ProxySQL for MySQL
ProxySQL for MySQLProxySQL for MySQL
ProxySQL for MySQL
 
Linux Kernel vs DPDK: HTTP Performance Showdown
Linux Kernel vs DPDK: HTTP Performance ShowdownLinux Kernel vs DPDK: HTTP Performance Showdown
Linux Kernel vs DPDK: HTTP Performance Showdown
 
Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004
Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004
Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004
 

Mehr von Kenny Gryp

MySQL Database Architectures - 2022-08
MySQL Database Architectures - 2022-08MySQL Database Architectures - 2022-08
MySQL Database Architectures - 2022-08Kenny Gryp
 
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11Kenny Gryp
 
MySQL Operator for Kubernetes
MySQL Operator for KubernetesMySQL Operator for Kubernetes
MySQL Operator for KubernetesKenny Gryp
 
MySQL Database Architectures - 2020-10
MySQL Database Architectures -  2020-10MySQL Database Architectures -  2020-10
MySQL Database Architectures - 2020-10Kenny Gryp
 
MySQL InnoDB Cluster / ReplicaSet - Tutorial
MySQL InnoDB Cluster / ReplicaSet - TutorialMySQL InnoDB Cluster / ReplicaSet - Tutorial
MySQL InnoDB Cluster / ReplicaSet - TutorialKenny Gryp
 
MySQL Connectors 8.0.19 & DNS SRV
MySQL Connectors 8.0.19 & DNS SRVMySQL Connectors 8.0.19 & DNS SRV
MySQL Connectors 8.0.19 & DNS SRVKenny Gryp
 
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterMySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterKenny Gryp
 
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best PracticesMySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best PracticesKenny Gryp
 
MySQL Group Replication - Ready For Production? (2018-04)
MySQL Group Replication - Ready For Production? (2018-04)MySQL Group Replication - Ready For Production? (2018-04)
MySQL Group Replication - Ready For Production? (2018-04)Kenny Gryp
 
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group ReplicationPercona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group ReplicationKenny Gryp
 
MySQL Group Replication
MySQL Group ReplicationMySQL Group Replication
MySQL Group ReplicationKenny Gryp
 
Multi Source Replication With MySQL 5.7 @ Verisure
Multi Source Replication With MySQL 5.7 @ VerisureMulti Source Replication With MySQL 5.7 @ Verisure
Multi Source Replication With MySQL 5.7 @ VerisureKenny Gryp
 
MySQL Group Replication - HandsOn Tutorial
MySQL Group Replication - HandsOn TutorialMySQL Group Replication - HandsOn Tutorial
MySQL Group Replication - HandsOn TutorialKenny Gryp
 
Online MySQL Backups with Percona XtraBackup
Online MySQL Backups with Percona XtraBackupOnline MySQL Backups with Percona XtraBackup
Online MySQL Backups with Percona XtraBackupKenny Gryp
 
Percona XtraDB Cluster
Percona XtraDB ClusterPercona XtraDB Cluster
Percona XtraDB ClusterKenny Gryp
 

Mehr von Kenny Gryp (15)

MySQL Database Architectures - 2022-08
MySQL Database Architectures - 2022-08MySQL Database Architectures - 2022-08
MySQL Database Architectures - 2022-08
 
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11
 
MySQL Operator for Kubernetes
MySQL Operator for KubernetesMySQL Operator for Kubernetes
MySQL Operator for Kubernetes
 
MySQL Database Architectures - 2020-10
MySQL Database Architectures -  2020-10MySQL Database Architectures -  2020-10
MySQL Database Architectures - 2020-10
 
MySQL InnoDB Cluster / ReplicaSet - Tutorial
MySQL InnoDB Cluster / ReplicaSet - TutorialMySQL InnoDB Cluster / ReplicaSet - Tutorial
MySQL InnoDB Cluster / ReplicaSet - Tutorial
 
MySQL Connectors 8.0.19 & DNS SRV
MySQL Connectors 8.0.19 & DNS SRVMySQL Connectors 8.0.19 & DNS SRV
MySQL Connectors 8.0.19 & DNS SRV
 
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterMySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
 
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best PracticesMySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
 
MySQL Group Replication - Ready For Production? (2018-04)
MySQL Group Replication - Ready For Production? (2018-04)MySQL Group Replication - Ready For Production? (2018-04)
MySQL Group Replication - Ready For Production? (2018-04)
 
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group ReplicationPercona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
 
MySQL Group Replication
MySQL Group ReplicationMySQL Group Replication
MySQL Group Replication
 
Multi Source Replication With MySQL 5.7 @ Verisure
Multi Source Replication With MySQL 5.7 @ VerisureMulti Source Replication With MySQL 5.7 @ Verisure
Multi Source Replication With MySQL 5.7 @ Verisure
 
MySQL Group Replication - HandsOn Tutorial
MySQL Group Replication - HandsOn TutorialMySQL Group Replication - HandsOn Tutorial
MySQL Group Replication - HandsOn Tutorial
 
Online MySQL Backups with Percona XtraBackup
Online MySQL Backups with Percona XtraBackupOnline MySQL Backups with Percona XtraBackup
Online MySQL Backups with Percona XtraBackup
 
Percona XtraDB Cluster
Percona XtraDB ClusterPercona XtraDB Cluster
Percona XtraDB Cluster
 

KĂźrzlich hochgeladen

Dubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls DubaiDubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls Dubaikojalkojal131
 
Top profile Call Girls In Rohtak [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Rohtak [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Rohtak [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Rohtak [ 7014168258 ] Call Me For Genuine Models We...nirzagarg
 
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...HyderabadDolls
 
Introduction to Statistics Presentation.pptx
Introduction to Statistics Presentation.pptxIntroduction to Statistics Presentation.pptx
Introduction to Statistics Presentation.pptxAniqa Zai
 
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...HyderabadDolls
 
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...kumargunjan9515
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabiaahmedjiabur940
 
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book nowVadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book nowgargpaaro
 
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.pptibrahimabdi22
 
Vastral Call Girls Book Now 7737669865 Top Class Escort Service Available
Vastral Call Girls Book Now 7737669865 Top Class Escort Service AvailableVastral Call Girls Book Now 7737669865 Top Class Escort Service Available
Vastral Call Girls Book Now 7737669865 Top Class Escort Service Availablegargpaaro
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNKTimothy Spann
 
Digital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareDigital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareGraham Ware
 
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxRESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxronsairoathenadugay
 
Gartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxGartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxchadhar227
 
Giridih Escorts Service Girl ^ 9332606886, WhatsApp Anytime Giridih
Giridih Escorts Service Girl ^ 9332606886, WhatsApp Anytime GiridihGiridih Escorts Service Girl ^ 9332606886, WhatsApp Anytime Giridih
Giridih Escorts Service Girl ^ 9332606886, WhatsApp Anytime Giridihmeghakumariji156
 
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...ThinkInnovation
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...Elaine Werffeli
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteedamy56318795
 
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...gajnagarg
 
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...HyderabadDolls
 

KĂźrzlich hochgeladen (20)

Dubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls DubaiDubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls Dubai
 
Top profile Call Girls In Rohtak [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Rohtak [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Rohtak [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Rohtak [ 7014168258 ] Call Me For Genuine Models We...
 
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
 
Introduction to Statistics Presentation.pptx
Introduction to Statistics Presentation.pptxIntroduction to Statistics Presentation.pptx
Introduction to Statistics Presentation.pptx
 
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
 
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
 
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book nowVadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
 
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt
 
Vastral Call Girls Book Now 7737669865 Top Class Escort Service Available
Vastral Call Girls Book Now 7737669865 Top Class Escort Service AvailableVastral Call Girls Book Now 7737669865 Top Class Escort Service Available
Vastral Call Girls Book Now 7737669865 Top Class Escort Service Available
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
 
Digital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareDigital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham Ware
 
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxRESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
 
Gartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxGartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptx
 
Giridih Escorts Service Girl ^ 9332606886, WhatsApp Anytime Giridih
Giridih Escorts Service Girl ^ 9332606886, WhatsApp Anytime GiridihGiridih Escorts Service Girl ^ 9332606886, WhatsApp Anytime Giridih
Giridih Escorts Service Girl ^ 9332606886, WhatsApp Anytime Giridih
 
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
Identify Customer Segments to Create Customer Offers for Each Segment - Appli...
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
 
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
 

Java MySQL Connector & Connection Pool Features & Optimization

  • 1. Java MySQL Connector & Connection Pool Features & Optimization Kenny Gryp <kenny.gryp@percona.com> April 14, 2015 @gryp
  • 2. DISCLAIMER Please excuse me for not being a Java developer 2
  • 3. What I Don’t Like • Brussels Sprouts • Taxes • Calories • Java(’s chattiness) 3
  • 5. MYSQL CONNECTORS CONNECTION POOLS Connectors Configuring Connector Creating A Database Connection Prepared Statements Example Transaction 5
  • 6. MySQL Connector/J & MariaDB Java Client • MySQL Connector/J – Oracle – 5.1.35 Latest – Compatible with • MySQL • Percona Server • MariaDB 6
  • 7. MySQL Connector/J & MariaDB Java Client • MariaDB Java Client • MariaDB • Fork from Drizzle Connector • Latest 1.1.8 • Compatible with – MySQL – Percona Server – MariaDB 7
  • 8. MySQL Connector/J Features • Enterprise Plugin: Query Analyzer • MySQL Fabric Integration • Load Balancing • Failover • Replication 8
  • 9. MYSQL CONNECTORS CONNECTION POOLS Connectors Configuring Connector Creating A Database Connection Prepared Statements Example Transaction 9
  • 10. Creating Connection Connection con = DriverManager.getConnection (“jdbc:mysql://node2/employees? user=connj&password=test"); Statement stmt = con.createStatement(); String query = "select * from employees where emp_no = 20000;"; ResultSet rs = stmt.executeQuery(query); ... MariaDB: jdbc:mariadb://node2/employees ?user=connj&password=test" 10
  • 11. Creating Connection - Tomcat w. JDBC- Pool context.xml (local): <Resource name="jdbc/test" auth="Container" type="javax.sql.DataSource" username=“jdbc-pool" password="test" driverClassName="com.mysql.jdbc.Driver" url=“jdbc:mysql://node2:3306/employees” /> MariaDB: driverClassName="org.mariadb.jdbc.Driver" 11
  • 12. Creating Connection - JDBC URL jdbc:mysql://node2:3306/employees? useServerPrepStmts=true&... 12
  • 13. MYSQL CONNECTORS CONNECTION POOLS Connectors Configuring Connector Creating A Database Connection Prepared Statements Example Transaction 13
  • 14. Connector/J - Creating Connection SHOW VARIABLES WHERE Variable_name ='language' OR… SELECT @@session.auto_increment_increment; SET NAMES latin1; SET character_set_results = NULL; SET autocommit=1; SET sql_mode= 'NO_ENGINE_SUBSTITUTION,STRICT_TRAN S_TABLES'; 14
  • 15. MariaDB - Creating Connection set autocommit=1; USE employees; show variables like 'sql_mode'; 15
  • 16. Creating Connection - Defaults • Connector/J: • MariaDB Java
 Client: 16
  • 17. Connector/J & MariaDB Java Client - Verbosity • Connector/J is more verbose when starting a connection • Usually not a problem: – connection pools are commonly used
 (more coming soon…) – connections are reused – Actually I like but not too much. 17
  • 18. Optimization • MariaDB Java Client vs MySQL Connector/J • Prepared Statements 18
  • 19. Connector Performance - SELECT 1 localhost, single threaded 19 QPS 0 4000 8000 12000 16000 localhost ConnectorJ MariaDB 15.213 13.477
  • 20. Connector Performance - MariaDB %faster 20 Faster% 5% 10% 15% 20% MariaDB Connector +Speed% ConnectorJ SELECT1 LO 13%
  • 21. Connector Performance - MariaDB %faster 21 Faster% 5% 10% 15% 20% MariaDB Connector +Speed% ConnectorJ SELECT1 LO SELECT1 net pk range 0% 4%4% 13% Benefit is relative!
  • 22. MYSQL CONNECTORS CONNECTION POOLS Connectors Configuring Connector Creating A Database Connection Prepared Statements Example Transaction 22
  • 23. Client or Server Side Prepared Statements • Server side Prepared statements: – reduce network traffic – query is already optimized on server. • Support: – MariaDB Java client only supports client side – Connector/J default in client side 23
  • 24. Server Side Prepared Statements PREPARE stmt1 FROM select * from employees where emp_no = ?; EXECUTE # API CALL select * from employees where emp_no = 20000; DEALLOCATE PREPARE stmt1; 24
  • 25. Connector/J: Server Side Prepared Statements • useServerPrepStmts = false – disabled by default • Mind looking at: – cachePrepStmts = false • do PREPARE, EXECUTE, DEALLOCATE every time…, 3 round trips? – prepStmtCacheSize = 25 – prepStmtCacheSqlLimit = 256 • low defaults 25 https://bugs.mysql.com/bug.php?id=74932
  • 26. Benchmark: Prepared Statements 26 QPS 900 1800 2700 3600 MariaDB CONN/J CONN/J SRVCONN/J SRV+Cache 3.506QPS 2.047QPS 3.342QPS3.400QPS select * from employees_alotofindexes where first_name='moss' and birth_date > "1954-06-14" and gender="M" and hire_date > "1998-01-01"G
  • 28. MYSQL CONNECTORS CONNECTION POOLS Connectors Configuring Connector Creating A Database Connection Prepared Statements Example Transaction 28
  • 29. Connector/J Optimization + Default JDBC- Pool Connection con = ds.getConnection(); con.setTransactionIsolation (Connection.TRANSACTION_READ_COMMITTED); con.setAutoCommit(false); PreparedStatement stmt = con.prepareStatement("select * from employees where emp_no = ?"); stmt.setInt(1, 20000); ResultSet rs = stmt.executeQuery(); stmt.close(); rs.close(); con.commit(); con.close(); 29
  • 30. Connector/J Optimization + Default JDBC- Pool SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; SET autocommit=0; # administrator command: Prepare; select * from employees where emp_no = 20000; # administrator command: Close stmt; commit; 30 Taxes
  • 31. Connector/J Optimization • useConfigs=maxPerformance – cachePrepStmts=true – cacheCallableStmts=true – cacheServerConfiguration=true – useLocalSessionState=true – elideSetAutoCommits=true – alwaysSendSetIsolation=false – enableQueryTimeouts=false 31
  • 33. Connector/J Optimization - Tuned JDBC URL: useConfigs=maxPerformance& useServerPrepStmts=true: select * from employees where emp_no = 20000; commit; 33
  • 34. MariaDB Java Client Optimization SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; select * from employees where emp_no = 20000; COMMIT; 34
  • 35. MariaDB Java Client Optimization - Code if ( con.getTransactionIsolation() != Connection.TRANSACTION_READ_COMMITTED ) { con.setTransactionIsolation (Connection.TRANSACTION_READ_COMMITTED); } 35
  • 36. MariaDB Java Client Optimization - Interceptors SELECT @@tx_isolation; select * from employees where emp_no = 20000; COMMIT; Still @@tx_isolation. Now add JDBC Interceptor: <Resource name="jdbc/test" auth="Container" factory= "org.apache.tomcat.jdbc.pool.DataSourceFactory" jdbcInterceptors="ConnectionState" driverClassName="org.mariadb.jdbc.Driver" url="jdbc:mysql://node2:3306/employees"/> 36
  • 37. MariaDB Java Client Optimization - Optimized! select * from employees where emp_no = 20000; COMMIT; 37
  • 38. Benchmark - Connector Concurrency - SELECT 1 38 HikariCP-bench with JDBC Pool, 4 Threads, SELECT 1 (4,8,16,32 Pool Size) QPS 17.500 35.000 52.500 70.000 MariaDB CONN/J
  • 39. Benchmark - Connector Concurrency - TRX 39 HikariCP-bench with JDBC Pool, 4 Threads, TRX (4,8,16,32 Pool Size) QPS 4.750 9.500 14.250 19.000 Conn/J MariaDB Conn/J Optim MariaDB Optim
  • 41. MYSQL CONNECTORS CONNECTION POOLS Connection Pools Issues Resetting Environment Testing Connectivity Pool Sizing Lingering Transactions Analysis Examples Graceful Failover Conn/J Extra Features 41
  • 42. Java Connection Pools – The Usual: – C3P0 – Commons-DBCP (v1&v2) – JDBC Pool (fork commons-DBCP) – Out In The Wild: – Vibur-DBCP – HikariCP – BoneCP 42
  • 43. Java Connection Pools – The Usual: – C3P0 – Commons-DBCP (v1&v2) – JDBC Pool (fork commons-DBCP) – Out In The Wild: – Vibur-DBCP – HikariCP – BoneCP 43
  • 44. Connection Pool Key Points • Connection Management • Pool Sizing • Connection Testing • Avoid Lingering Transactions 44
  • 45. MYSQL CONNECTORS CONNECTION POOLS Connection Pools Issues Resetting Environment Testing Connectivity Pool Sizing Lingering Transactions Analysis Examples Graceful Failover Conn/J Extra Features 45
  • 46. Connection Pool Issues • Coming from DBA side, I do not like ‘chattiness’ 46
  • 51. WHY DOES IT HAVE TO DO THAT? Because of ‘application bugs’ 51
  • 52. Connection Pools - Why Chattiness Examples • *maybe* forgot to COMMIT / ROLLBACK • wanting AUTOCOMMIT=1
 but a previous TRX set it to 0 • Changing TRX Isolation Level • Is connection still working? 52
  • 53. MYSQL CONNECTORS CONNECTION POOLS Connection Pools Issues Resetting Environment Testing Connectivity Pool Sizing Lingering Transactions Analysis Examples Graceful Failover Conn/J Extra Features 53
  • 54. Connection Pool - Resetting Status 54 JDBC-Pool C3P0 DBCP2 HikariCP Rollback rollbackOnReturn=false autoCommitOnClose=false rollbackOnReturn
 =true Commit commitOnReturn=false autoCommitOnClose=false n/a n/a Avoid see above forceIgnoreUnresolvedTransa ctions=false see above Auto Commit Driver Driver enableAutoCommit
 OnReturn=true Driver
  • 55. MYSQL CONNECTORS CONNECTION POOLS Connection Pools Issues Resetting Environment Testing Connectivity Pool Sizing Lingering Transactions Analysis Examples Graceful Failover Conn/J Extra Features 55
  • 56. Connection Pool - Testing • Making sure the connection is still active • If not, maybe reopen a connection • Not recommended as DB • However, applications: • do not like errors • do not retry gracefully 56
  • 57. Connection Pool - Testing • If connections REALLY need to be tested… • do not specify test query like: • SELECT 1 • SELECT * FROM DUAL • Leave default, all of the connection pools use:
 JDBC4 isValid(); 57
  • 58. Connection Pool - Testing 58 JDBC-Pool C3P0 DBCP2 HikariCP Test Before testOnBorrow=false testConnectionOnCheckOut
 =false testOnBorrow=false n/a Test After testOnReturn=false testConnectionOnCheckIn
 =false testOnReturn=false n/a Test While Idle testWhileIdle=false idleConnectionTestPeriod
 =0 testWhileIdle=false n/a JDBC4 isValid() default default default jdbc4ConnectionTest
 =true (default) Query validationQuery
 (isValid) preferredTestQuery=null validationQuery
 (isValid) connectionTestQuery
 =none Interval? validationInterval=30000 n/a n/a n/a
  • 59. Connection Pool - Testing • JDBC: validationInterval=30s
 WHY? It defeats the whole purpose! 59
  • 60. MYSQL CONNECTORS CONNECTION POOLS Connection Pools Issues Resetting Environment Testing Connectivity Pool Sizing Lingering Transactions Analysis Examples Graceful Failover Conn/J Extra Features 60
  • 61. Connection Pool - Pool Sizing • Funnelling on Application Level, is good • Smaller Number is Better • +- * CPU’s on DB • maybe a bit more (waiting on IO…) • all application servers combined • Response Time vs Throughput 61
  • 62. Connection Pool - Pool Sizing 62 JDBC-Pool C3P0 DBCP2 HikariCP Amount of Connections maxActive=100 maxPoolSize=15 maxTotal=8 maximumPoolSize=10 Maximum Idle Connections maxIdle=100 maxIdleTime=0** maxIdle=8 n/a Minimum Idle Connections minIdle=10 minPoolSize=3 minIdle=0 minimumIdle=max Startup Size initialSize=10 initialPoolSize=3 initialSize=0 minimumIdle
  • 63. MYSQL CONNECTORS CONNECTION POOLS Connection Pools Issues Resetting Environment Testing Connectivity Pool Sizing Lingering Transactions Analysis Examples Graceful Failover Conn/J Extra Features 63
  • 64. Connection Pool - Avoid Lingering Transactions • Application forgets to return the connection • Statements that take longer than … • Avoid this! • Fix Application 64
  • 65. Connection Pool - Avoid Lingering Transactions 65 KILL Warning JDBC-Pool removeAbandoned=false
 removeAbandonedTimeout=60
 abandonWhenPercentageFull=0 suspectTimeout=0 C3P0 unreturnedConnectionTimeout=0 n/a DBCP removeAbandoned=false
 removeAbandonedTimeout=300
 Only When: 
 getNumIdle() < 2 and getNumActive() > getMaxTotal() - 3) n/a HikariCP n/a leakDetectionThreshold=0
  • 66. MYSQL CONNECTORS CONNECTION POOLS Connection Pools Issues Resetting Environment Testing Connectivity Pool Sizing Lingering Transactions Analysis Examples Graceful Failover Conn/J Extra Features 66
  • 67. Connection Pools - How To Look At Workload? • Slow Query Log • tcpdump • pt-query-digest • Percona Cloud Tools 67
  • 68. MYSQL CONNECTORS CONNECTION POOLS Connection Pools Issues Resetting Environment Testing Connectivity Pool Sizing Lingering Transactions Analysis Examples Graceful Failover Conn/J Extra Features 68
  • 69. Connection Pool - Example Transaction Connection con = ds.getConnection(); con.setTransactionIsolation (Connection.TRANSACTION_READ_COMMITTED); con.setAutoCommit(false); PreparedStatement stmt = con.prepareStatement("select * from employees where emp_no = ?"); stmt.setInt(1, 20000); ResultSet rs = stmt.executeQuery(); stmt.close(); rs.close(); con.commit(); con.close(); 69
  • 70. For Connectors - RECAP • MySQL Connector/J • useConfigs=maxPerformance • useServerPrepStmts=true • MariaDB Java Client • HikariCP: Built in • JDBC-Pool: jdbcInterceptors=“ConnectionState" • Other Pools: UNKNOWN 70
  • 71. Connection Pool - TRX JDBC select * from employees where emp_no = 20000; commit; 71 200
  • 72. Connection Pool - TRX C3P0 SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; SET autocommit=0; select * from employees where emp_no = 20000; commit; SET autocommit=1; SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; 72 600
  • 73. Connection Pool - TRX C3P0 mysql> set global tx_isolation=“READ-COMMITTED”; forceIgnoreUnresolvedTransactions=true 73 200
  • 74. Connection Pool - TRX DBCP SET autocommit=1; # administrator command: Ping; SET autocommit=0; select * from employees where emp_no = 20000; commit; rollback; SET autocommit=1; 74 700
  • 75. Connection Pool - TRX DBCP testOnBorrow=false rollbackOnReturn=false enableAutoCommitOnReturn=false jdbcUrl: useLocalTransactionState=true 75 200
  • 76. Connection Pool - TRX HikariCP SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; SET autocommit=0; select * from employees where emp_no = 20000; commit; SET autocommit=1; SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; 76 600
  • 77. Connection Pool - TRX HikariCP mysql> set global tx_isolation=“READ-COMMITTED”; autoCommit=false 77 200
  • 80. MYSQL CONNECTORS CONNECTION POOLS Connection Pools Issues Resetting Environment Testing Connectivity Pool Sizing Lingering Transactions Analysis Examples Graceful Failover Conn/J Extra Features 80
  • 81. Connection Pools - Graceful Failover 81
  • 82. Connection Pools - Graceful Failover • HAProxy ‘stats socket’ /etc/haproxy/haproxy.cfg global . . . stats socket /tmp/haproxy.sock level admin • Disable Node # echo "disable server database/node1" 
 | socat stdio /tmp/haproxy.sock 82
  • 83. Connection Pools - Graceful Failover 83
  • 84. Connection Pools - Graceful Failover • During ‘maintenance’, what do we do? • KILL old connections? • Wait until connections are closed? (Define lifetimes?) • Ignore it? 84
  • 85. Connection Pools - Graceful Failover • Some connection pools can close connections gracefully, when idle. • For ‘synchronous’ replication systems • using JMX • No Application Errors! 85 Method JDBC-Pool purgeOnReturn() C3P0 softResetAllUsers() DBCP n/a HikariCP softEvictConnections(), suspendPool(), resumePool() <—- ASYNC
  • 86. Connection Pools - Graceful Failover 86
  • 87. Connection Pools - Graceful Failover 87
  • 88. Connection Pools - Graceful Failover 88
  • 89. Connection Pools - Graceful Failover • 0 Application Errors • Completely seamless 89
  • 90. MYSQL CONNECTORS CONNECTION POOLS Connection Pools Issues Resetting Environment Testing Connectivity Pool Sizing Lingering Transactions Analysis Examples Graceful Failover Conn/J Extra Features 90
  • 91. Connector/J - Extra Features • Load Balancing • jdbcUrl: ”jdbc:mysql:loadbalance:// node1,node2/db? loadBalanceConnectionGroup=lb&
 loadBalanceEnableJMX=true” • loadBalanceStrategy 
 (random/bestResponseTime) • Failover • ReplicationDriver (setReadOnly) • Combining with Connection Pools is less useful • Fabric 91
  • 92. Java MySQL Connector & 
 Connection Pool Optimization • http://dev.mysql.com/doc/connector-j/en • https://mariadb.com/kb/en/mariadb/client-libraries/mariadb-java- client/ • http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html • http://www.mchange.com/projects/c3p0 • http://commons.apache.org/proper/commons-dbcp/ • https://github.com/brettwooldridge/HikariCP 92 MYSQL CONNECTORS CONNECTION POOLS Kenny Gryp <kenny.gryp@percona.com> November 4, 2014 @gryp