exploring mysql cluster 7.4
TRANSCRIPT
Exploring the new release MySQL Cluster 7.4 In-Memory Real-Time Performance, Web Scalability & 99.999% Availability
Ivan Ma [email protected] 2015-04-11
February 2015
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 2
MySQL Replication
MySQL Fabric
DRBD
Windows/Solaris/Clusterware Clustering or Oracle VM
MySQL Cluster
MySQL HA Solutions
19th February 2015
Getting Higher & Higher Availability
Copyright 2015, Oracle and/or its affiliates. All rights reserved 3
MySQL Cluster NDB Engine History
NDB Engine 2003
…………. 6.2GA
Sep2007 6.3GA
Jan2008 7.0GA
April2009 7.1GA
April2010
7.2GA
Based on MySQL
5.5 Feb2012
7.3GA – Based on MySQL
5.6 June2013
7.4 GA Feb 015
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 4
MySQL Cluster Architecture
MySQL Cluster Data Nodes
Clients
Application / MySQL Node Layer
Data Layer
Copyright 2015, oracle and/or its affiliates. All rights reserved 5
MySQL Cluster Architecture
MySQL Cluster Data Nodes
Clients
Data Layer
Copyright 2015, oracle and/or its affiliates. All rights reserved 6
Application / MySQL Node Layer
MySQL Cluster Scaling
MySQL Cluster Data Nodes
Clients
Application Layer
Data Layer
Copyright 2015, oracle and/or its affiliates. All rights reserved 7
On-line Operations
• Scale the cluster (add & remove nodes on-line)
• Repartition tables
• Upgrade / patch servers & OS
• Upgrade / patch MySQL Cluster
• Back-Up
• Evolve the schema on-line, in real-time
Copyright 2015, oracle and/or its affiliates. All rights reserved 8
MySQL Cluster Auto-Installer
• Fast configuration
• Auto-discovery
• Workload optimized
• Repeatable best practices
Specify Workload
Auto-Discover
Define Topology Deploy
Copyright 2015, oracle and/or its affiliates. All rights reserved 9
NoSQL Access to MySQL Cluster data
Apps Apps Apps Apps Apps Apps Apps Apps Apps Apps Apps Apps
JPA
Cluster JPA
PHP Perl Python Ruby JDBC Cluster J JS Apache Memcached
MySQL JNI Node.JS mod_ndb ndb_eng
NDB API (C++)
MySQL Cluster Data Nodes
MySQL Cluster 7.4 GA
Copyright 2015, oracle and/or its affiliates. All rights reserved 11
MySQL Cluster 7.4 GA
• 200 Million NoSQL Reads/Sec
• 2.5M SQL Ops/Sec
• 50% Faster Reads
• 40% Faster Mixed
Performance
• Active-Active Geographic Redundancy
• Conflict Detection/Resolution
Active-Active
• 5X Faster Maintenance Ops
• Detailed Reporting
Management
Copyright 2015, oracle and/or its affiliates. All rights reserved 12
Performance Enhancements
MySQL Cluster 7.4
50% Read-Only Increase
Copyright 2015, oracle and/or its affiliates. All rights reserved 13
0
1000
2000
3000
4000
5000
6000
7000
8000
9000
64 128 192 256 320 384 448 512
Tran
saconspersecond
Threads
SysbenchR/W
7.4
7.3
7.2
0
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000
64 128 192 256 320 384 448 512
Tran
saconpersecond
Threads
SysbenchRO
7.4
7.3
7.2
40% Read/Write Increase
• Memory optimized tables
– Durable
– Mix with disk-based tables
• Massively concurrent OLTP
• Distributed Joins for analytics
• Parallel table scans for non-indexed searches
• MySQL Cluster 7.4 FlexAsych – 200M NoSQL Reads/Second
14
MySQL Cluster 7.4 NoSQL Performance 200 Million NoSQL Reads/Second
Copyright 2015, oracle and/or its affiliates. All rights reserved
-
50,000,000
100,000,000
150,000,000
200,000,000
250,000,000
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32
Readspersecond
DataNodes
FlexAsyncReads
• Memory optimized tables
– Durable
– Mix with disk-based tables
• Massively concurrent OLTP
• Distributed Joins for analytics
• Parallel table scans for non-indexed searches
• MySQL Cluster 7.4 DBT2 BM – 2.5M SQL Statements/Second
16/04/2015 15
MySQL Cluster 7.4 SQL Performance 2.5M SQL Statements/Second
Copyright 2015, oracle and/or its affiliates. All rights reserved
-
500,000
1,000,000
1,500,000
2,000,000
2,500,000
3,000,000
2 4 6 8 10 12 14 16
SQLStatements/sec
DataNodes
DBT2SQLStatementsperSecond
• Asynchronous replication between MySQL Clusters
• Active-Active
– Update anywhere
– Conflict detection • Application notified through exception tables
• Can opt to have conflicts resolved automatically
– Auto-conflict-resolution • Conflicting transaction and dependent ones
are rolled-back
• No changes to application schema
Active-Active Geo-Replication
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 16
What is a conflict?
John.balance==$100
John.balance==$100
Spend $40 Add $100
$60
$200
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 17
John.balance-=$40 John.balance==$60
John.balance==$200
John.balance+= $100 John.balance==$200
John.balance==$60
• NDB$EPOCH2 and NDB$EPOCH2_TRANS introduced
• Detects conflicting inserts/updates
• Entire transactions (and dependent ones) rolled back
• All conflicts are handled before switching primary
• Conflicting deletes
• Rolling back of transactions that read conflicted data
February 2015 18
Handling of Conflicts – Extensions in MySQL Cluster 7.4
Copyright 2015, oracle and/or its affiliates. All rights reserved
• Primary stores logical timestamp (GCI) against updated row
– Window for conflict opens
• GCI replicated with updated row to Secondary
• The same row and GCI is replicated back (reflected) from Secondary to Primary after it has been applied
– Closing window for conflict
• Primary checks every event originating from the Secondary to ensure it isn’t for a ‘conflictable’ row
Detecting Conflicts - Reflected GCI
John.balance==$100
John.balance-=$40 John.balance==$60
John.balance==$200
John.balance==$100
John.balance+= $100 John.balance==$200
John.balance==$60
Spend $40
Add $100
$60
$200
Primary Secondary
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 19
How to Use Conflict Detection/Resolution
Decide which tables need protecting
For each table, specify what to do on conflicts
Just record in exception table
Application or DBA acts on
content
Rollback the conflicting row
Rollback the conflicting transaction
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 20
Demo
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 21
simple1 (10)
simple2 (10)
simple3 (10)
simple1 (10)
simple2 (10)
simple3 (10)
simple1 (10) (13)
STOPPED
simple1 (10) (20) simple2 (10) (20)
simple3 (10) (20) OK (no stop)
simple1 (10) (20) simple2 (10) (20)
simple3 (10) (20) ????
Exception
simple1 (13), simple2(10), simple3(20)
simple1 $EX(10->20), simple2$EX(10->20) Started
simple1 (13), simple2(10), simple3(20)
simple1 (10) (20) simple2 (10) (20)
Rollback
MySQL Cluster 7.4 Restart Improvements
• Duration of long-running maintenance activities dominated by Data Node restart times
• MySQL Cluster 7.4 = 5.5X faster restarts
• Benefits both nodal and rolling restarts
– Upgrades, add-node,…
• Benefits both SQL and NoSQL APIs
• Benefits both ”manual” a MySQL Cluster Manager operations
• Achieve 5x as much during a single maintenance window
Make Data Node Restarts Fast!
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 22
MySQL Cluster 7.4 Restart Improvements
• Verbose logging
– Task start/completion
– Data volumes
– Parallelism & Wait times
• NDBINFO for recent node restarts
• More documentation of stages
• Goal: Make analysis of a slow restart possible
– Determine cause; Detect patterns; Understand the impact of indexes, local checkpoints etc.
Observability improvements
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 23
MySQL Cluster 7.4 – Enhanced memory reporting
• ndbinfo.memory_per_fragment memory usage information for each fragment replica, for each table and index
• Allocated memory and how much of that is actually in use.
• Exposes
– Fragmentation of fixed and var-sized fragment pages
– Accurate Data and Index Memory use
– Comparison of Primary and Backup fragment usage
– Partitioning effectiveness
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 24
Enhanced Memory Reporting
mysql> CREATE DATABASE clusterdb;USE clusterdb; mysql> CREATE TABLE simples (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=NDB; mysql> select node_id AS node, fragment_num AS frag, fixed_elem_alloc_bytes alloc_bytes, fixed_elem_free_bytes AS free_bytes, fixed_elem_free_rows AS spare_rows from memory_per_fragment where fq_name like '%simples%'; +------+------+-------------+------------+------------+ | node | frag | alloc_bytes | free_bytes | spare_rows | +------+------+-------------+------------+------------+ | 1 | 0 | 131072 | 5504 | 172 | | 1 | 2 | 131072 | 1280 | 40 | | 2 | 0 | 131072 | 5504 | 172 | | 2 | 2 | 131072 | 1280 | 40 | | 3 | 1 | 131072 | 3104 | 97 | | 3 | 3 | 131072 | 4256 | 133 | | 4 | 1 | 131072 | 3104 | 97 | | 4 | 3 | 131072 | 4256 | 133 | +------+------+-------------+------------+------------+
See how much memory a table is using
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 25
Enhanced Memory Reporting
+------+------+-------------+------------+------------+ | node | frag | alloc_bytes | free_bytes | spare_rows | +------+------+-------------+------------+------------+ | 1 | 0 | 131072 | 5504 | 172 | | 1 | 2 | 131072 | 1280 | 40 | | 2 | 0 | 131072 | 5504 | 172 | | 2 | 2 | 131072 | 1280 | 40 | | 3 | 1 | 131072 | 3104 | 97 | | 3 | 3 | 131072 | 4256 | 133 | | 4 | 1 | 131072 | 3104 | 97 | | 4 | 3 | 131072 | 4256 | 133 | +------+------+-------------+------------+------------+ mysql> DELETE FROM clusterdb.simples LIMIT 1; +------+------+-------------+------------+------------+ | node | frag | alloc_bytes | free_bytes | spare_rows | +------+------+-------------+------------+------------+ | 1 | 0 | 131072 | 5504 | 172 | | 1 | 2 | 131072 | 1312 | 41 | | 2 | 0 | 131072 | 5504 | 172 | | 2 | 2 | 131072 | 1312 | 41 | | 3 | 1 | 131072 | 3104 | 97 | | 3 | 3 | 131072 | 4288 | 134 | | 4 | 1 | 131072 | 3104 | 97 | | 4 | 3 | 131072 | 4288 | 134 | +------+------+-------------+------------+------------+
See how memory is made available after deleting rows
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 26
Enhanced Memory Reporting
mysql> CREATE TABLE simples (id INT NOT NULL AUTO_INCREMENT, species VARCHAR(20) DEFAULT "Human", PRIMARY KEY(id, species)) engine=ndb PARTITION BY KEY(species); // Add some data mysql> select node_id AS node, fragment_num AS frag, fixed_elem_alloc_bytes alloc_bytes, fixed_elem_free_bytes AS free_bytes, fixed_elem_free_rows AS spare_rows from ndbinfo.memory_per_fragment where fq_name like '%simples%'; +------+------+-------------+------------+------------+ | node | frag | alloc_bytes | free_bytes | spare_rows | +------+------+-------------+------------+------------+ | 1 | 0 | 0 | 0 | 0 | | 1 | 2 | 196608 | 11732 | 419 | | 2 | 0 | 0 | 0 | 0 | | 2 | 2 | 196608 | 11732 | 419 | | 3 | 1 | 0 | 0 | 0 | | 3 | 3 | 0 | 0 | 0 | | 4 | 1 | 0 | 0 | 0 | | 4 | 3 | 0 | 0 | 0 | +------+------+-------------+------------+------------+
Check how well partitioned/sharded a table is
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 27
MySQL Cluster 7.4 – Enhanced activity reporting
• ndbinfo.operations_per_fragment activity counters for each fragment replica, for each table and index
• PK & scan access – requests, bytes, rows…
• Exposes
– How traffic maps to tables and indices
– Query execution, use of indexes etc.
– LDM and node imbalances
– Hotspots and scan overloads
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 28
Exploring the new release MySQL Cluster 7.4
Thank You
February 2015