SlideShare a Scribd company logo
1 of 92
Download to read offline
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

More Related Content

What's hot

Cilium - overview and recent updates
Cilium - overview and recent updatesCilium - overview and recent updates
Cilium - overview and recent updatesMichal Rostecki
 
Distributed Point-in-Time Recovery with Postgres | PGConf.Russia 2018 | Eren ...
Distributed Point-in-Time Recovery with Postgres | PGConf.Russia 2018 | Eren ...Distributed Point-in-Time Recovery with Postgres | PGConf.Russia 2018 | Eren ...
Distributed Point-in-Time Recovery with Postgres | PGConf.Russia 2018 | Eren ...Citus Data
 
Using eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in CiliumUsing eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in CiliumScyllaDB
 
Apache Kafka in the Airline, Aviation and Travel Industry
Apache Kafka in the Airline, Aviation and Travel IndustryApache Kafka in the Airline, Aviation and Travel Industry
Apache Kafka in the Airline, Aviation and Travel IndustryKai Wähner
 
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera ) Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera ) Mydbops
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetesRishabh Indoria
 
How Netflix Tunes EC2 Instances for Performance
How Netflix Tunes EC2 Instances for PerformanceHow Netflix Tunes EC2 Instances for Performance
How Netflix Tunes EC2 Instances for PerformanceBrendan Gregg
 
Kubernetes Architecture - beyond a black box - Part 2
Kubernetes Architecture - beyond a black box - Part 2Kubernetes Architecture - beyond a black box - Part 2
Kubernetes Architecture - beyond a black box - Part 2Hao H. Zhang
 
Cassandra Introduction & Features
Cassandra Introduction & FeaturesCassandra Introduction & Features
Cassandra Introduction & FeaturesDataStax Academy
 
Ensuring Kubernetes Cost Efficiency across (many) Clusters - DevOps Gathering...
Ensuring Kubernetes Cost Efficiency across (many) Clusters - DevOps Gathering...Ensuring Kubernetes Cost Efficiency across (many) Clusters - DevOps Gathering...
Ensuring Kubernetes Cost Efficiency across (many) Clusters - DevOps Gathering...Henning Jacobs
 
Scaling Push Messaging for Millions of Netflix Devices
Scaling Push Messaging for Millions of Netflix DevicesScaling Push Messaging for Millions of Netflix Devices
Scaling Push Messaging for Millions of Netflix DevicesSusheel Aroskar
 
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018Will Huang
 
Distributed stream processing with Apache Kafka
Distributed stream processing with Apache KafkaDistributed stream processing with Apache Kafka
Distributed stream processing with Apache Kafkaconfluent
 
Everything you ever needed to know about Kafka on Kubernetes but were afraid ...
Everything you ever needed to know about Kafka on Kubernetes but were afraid ...Everything you ever needed to know about Kafka on Kubernetes but were afraid ...
Everything you ever needed to know about Kafka on Kubernetes but were afraid ...HostedbyConfluent
 
K8s security best practices
K8s security best practicesK8s security best practices
K8s security best practicesSharon Vendrov
 
Midi technique - présentation docker
Midi technique - présentation dockerMidi technique - présentation docker
Midi technique - présentation dockerOlivier Eeckhoutte
 
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안SANG WON PARK
 
Kafka: All an engineer needs to know
Kafka: All an engineer needs to knowKafka: All an engineer needs to know
Kafka: All an engineer needs to knowThao Huynh Quang
 
Common issues with Apache Kafka® Producer
Common issues with Apache Kafka® ProducerCommon issues with Apache Kafka® Producer
Common issues with Apache Kafka® Producerconfluent
 

What's hot (20)

Cilium - overview and recent updates
Cilium - overview and recent updatesCilium - overview and recent updates
Cilium - overview and recent updates
 
Introduction to Apache Storm
Introduction to Apache StormIntroduction to Apache Storm
Introduction to Apache Storm
 
Distributed Point-in-Time Recovery with Postgres | PGConf.Russia 2018 | Eren ...
Distributed Point-in-Time Recovery with Postgres | PGConf.Russia 2018 | Eren ...Distributed Point-in-Time Recovery with Postgres | PGConf.Russia 2018 | Eren ...
Distributed Point-in-Time Recovery with Postgres | PGConf.Russia 2018 | Eren ...
 
Using eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in CiliumUsing eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in Cilium
 
Apache Kafka in the Airline, Aviation and Travel Industry
Apache Kafka in the Airline, Aviation and Travel IndustryApache Kafka in the Airline, Aviation and Travel Industry
Apache Kafka in the Airline, Aviation and Travel Industry
 
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera ) Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
How Netflix Tunes EC2 Instances for Performance
How Netflix Tunes EC2 Instances for PerformanceHow Netflix Tunes EC2 Instances for Performance
How Netflix Tunes EC2 Instances for Performance
 
Kubernetes Architecture - beyond a black box - Part 2
Kubernetes Architecture - beyond a black box - Part 2Kubernetes Architecture - beyond a black box - Part 2
Kubernetes Architecture - beyond a black box - Part 2
 
Cassandra Introduction & Features
Cassandra Introduction & FeaturesCassandra Introduction & Features
Cassandra Introduction & Features
 
Ensuring Kubernetes Cost Efficiency across (many) Clusters - DevOps Gathering...
Ensuring Kubernetes Cost Efficiency across (many) Clusters - DevOps Gathering...Ensuring Kubernetes Cost Efficiency across (many) Clusters - DevOps Gathering...
Ensuring Kubernetes Cost Efficiency across (many) Clusters - DevOps Gathering...
 
Scaling Push Messaging for Millions of Netflix Devices
Scaling Push Messaging for Millions of Netflix DevicesScaling Push Messaging for Millions of Netflix Devices
Scaling Push Messaging for Millions of Netflix Devices
 
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
 
Distributed stream processing with Apache Kafka
Distributed stream processing with Apache KafkaDistributed stream processing with Apache Kafka
Distributed stream processing with Apache Kafka
 
Everything you ever needed to know about Kafka on Kubernetes but were afraid ...
Everything you ever needed to know about Kafka on Kubernetes but were afraid ...Everything you ever needed to know about Kafka on Kubernetes but were afraid ...
Everything you ever needed to know about Kafka on Kubernetes but were afraid ...
 
K8s security best practices
K8s security best practicesK8s security best practices
K8s security best practices
 
Midi technique - présentation docker
Midi technique - présentation dockerMidi technique - présentation docker
Midi technique - présentation docker
 
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
 
Kafka: All an engineer needs to know
Kafka: All an engineer needs to knowKafka: All an engineer needs to know
Kafka: All an engineer needs to know
 
Common issues with Apache Kafka® Producer
Common issues with Apache Kafka® ProducerCommon issues with Apache Kafka® Producer
Common issues with Apache Kafka® Producer
 

Viewers also liked

Эффективная отладка репликации 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
 
MySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group ReplicationMySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group ReplicationFrederic Descamps
 
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
 

Viewers also liked (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!
 
MySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group ReplicationMySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group Replication
 
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
 

Similar to 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
 
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
 

Similar to 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
 

More from 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
 

More from 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
 

Recently uploaded

办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degreeyuu sss
 
Business Analytics using Microsoft Excel
Business Analytics using Microsoft ExcelBusiness Analytics using Microsoft Excel
Business Analytics using Microsoft Excelysmaelreyes
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPTBoston Institute of Analytics
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queensdataanalyticsqueen03
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxMike Bennett
 
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Boston Institute of Analytics
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]📊 Markus Baersch
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Cantervoginip
 
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxmodul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxaleedritatuxx
 
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...Boston Institute of Analytics
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDRafezzaman
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degreeyuu sss
 
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Thomas Poetter
 
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Boston Institute of Analytics
 
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...ssuserf63bd7
 
Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Seán Kennedy
 
LLMs, LMMs, their Improvement Suggestions and the Path towards AGI
LLMs, LMMs, their Improvement Suggestions and the Path towards AGILLMs, LMMs, their Improvement Suggestions and the Path towards AGI
LLMs, LMMs, their Improvement Suggestions and the Path towards AGIThomas Poetter
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 217djon017
 
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.natarajan8993
 
Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Cathrine Wilhelmsen
 

Recently uploaded (20)

办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
 
Business Analytics using Microsoft Excel
Business Analytics using Microsoft ExcelBusiness Analytics using Microsoft Excel
Business Analytics using Microsoft Excel
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queens
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptx
 
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Canter
 
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxmodul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
 
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
 
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
 
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
 
Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...
 
LLMs, LMMs, their Improvement Suggestions and the Path towards AGI
LLMs, LMMs, their Improvement Suggestions and the Path towards AGILLMs, LMMs, their Improvement Suggestions and the Path towards AGI
LLMs, LMMs, their Improvement Suggestions and the Path towards AGI
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2
 
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.
 
Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)Data Factory in Microsoft Fabric (MsBIP #82)
Data Factory in Microsoft Fabric (MsBIP #82)
 

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