This document provides an overview and summary of MySQL Cluster, including:
- Key features of MySQL Cluster such as high performance, availability, and scalability
- Examples of major companies that use MySQL Cluster such as PayPal, Big Fish, and Alcatel-Lucent
- New capabilities in MySQL Cluster 7.4 such as improved performance, active-active replication between clusters, and enhanced conflict detection and resolution for multi-site deployments
5. Oracle MySQL HA & Scaling SoluGons
Copyright 2016, oracle and/or its affiliates. All rights reserved 5
MySQL Replica0on MySQL Fabric Oracle VM
Oracle
Clusterware
Solaris Cluster MySQL Cluster
App Auto-Failover MySQL Router ✔ ✔ ✔ ✔ ✔
Data Layer Auto-Failover MySQL Router ✔ ✔ ✔ ✔ ✔
Zero Data Loss MySQL 5.7 MySQL 5.7 ✔ ✔ ✔ ✔
Plaaorm Support All All All All Solaris All
Clustering Mode Master + Slaves Master + Slaves Ac0ve/Passive Ac0ve/Passive Ac0ve/Passive Mul0-Master
Failover Time Secs Secs Secs + Secs + Secs + < 1 Sec
Scale-out Reads ✔ ✖ ✖ ✖ ✔
Cross-shard operaGons N/A ✖ N/A N/A N/A ✔
Transparent rouGng MySQL Router For HA ✔ ✔ ✔ ✔
Shared Nothing ✔ ✔ ✖ ✖ ✖ ✔
Storage Engine InnoDB InnoDB InnoDB InnoDB InnoDB NDB
Single Vendor Support ✔ ✔ ✔ ✔ ✔ ✔
21. • NDB$EPOCH2 and
NDB$EPOCH2_TRANS introduced
• Detects conflicGng inserts/updates/
deletes/reads
• EnGre transacGons (and dependent
ones) rolled back
• Rolling back of transacGons that
read conflicted data
• Improved NDB ExcepGons table
format
– Non-PK columns, operaGon type,
transacGon id, before and aper values
• Online conflict role change
21
Handling of Conflicts – Extensions in MySQL Cluster 7.4
Copyright 2016, oracle and/or its affiliates. All rights reserved
22. • Primary stores logical Gmestamp (GCI)
against updated row(s)
– Window for conflict opens
• GCI is replicated with updated row(s) to
Secondary
• The same GCI is replicated back
(reflected) from Secondary to Primary
aper it has been applied
– Closing window for conflict
• Primary checks every event originaGng
from the Secondary to check for conflicts
DetecGng 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
Copyright 2016, oracle and/or its affiliates. All rights reserved 22
36. When to Consider MySQL Cluster
l UpGme requirements
l Cost per minute of downGme?
l Failure versus maintenance?
l Scalability demands
l Sharding for write scaling?
l Latency demands
l Cost of each millisecond?
l ApplicaGon agility
l Developer languages and frameworks?
l SQL and NoSQL?
Copyright 2016, oracle and/or its affiliates. All rights reserved 36
37. General Usage Considerations
• MySQL Cluster is designed for
– Short transactions
– Single key reads and writes
– Many parallel transactions
• Utilize simple access patterns for high running transactions
– Use efficient scans and batching interfaces
– Push down joins yield huge performance improvements for JOIN operations
– MySQL Cluster 7.4 speeds up table scans
• Storage Engine is configurable for each table…InnoDB or NDB
MySQL Cluster EvaluaGon Guide
h}p://mysql.com/why-mysql/white-papers/mysql_cluster_eval_guide.php
Copyright 2016, oracle and/or its affiliates. All rights reserved 37
38. D1 D2 D3 D4
API
----------
----------
----------
TC TC TC TC
1
2
Accessing Data: PK Lookups
• Single TransacGon
Coordinator (TC), no
addiGonal data
distribuGon handling
• First statement decides TC
• Keep transacGons short!
Copyright 2016, oracle and/or its affiliates. All rights reserved 38
39. D1 D2 D3 D4
API
----------
----------
----------
TC TC TC TC
1
2
3
Accessing data: Unique Secondary Key Lookups
• Secondary keys
implemented as hidden/
system tables
• Hidden tables have new
secondary key as PK and
base table’s PK as value
• Data may reside on same
node or other node
Copyright 2016, oracle and/or its affiliates. All rights reserved 39
40. D1 D2 D3 D4
API
----------
----------
----------
TC TC TC TC
1 3
2
Accessing data: Range Scans and Joins
• TC is chosen using round-
robin
• Data nodes return data
directly to API
• Flow:
– Choose data node
– Send request to all LDM
– Send data to API
Copyright 2016, oracle and/or its affiliates. All rights reserved 40
41. SELECT SUM(population) FROM towns WHERE
country=“UK”;
SELECT SUM(population) FROM towns WHERE
town=“Boston”;
• ParGGon selected using hash on
specified ParGGon Key
– Primary Key by default
– User can override in table definiGon
• MySQL Server (or NDB API) will
a}empt to send transacGon to the
correct data node
– If all data for the transacGon are in the
same parGGon, less messaging ->
be}er scalability
• Aim to have all rows for high-
running queries in same parGGon
DistribuGon Aware Apps
Copyright 2016, oracle and/or its affiliates. All rights reserved 41
43. Faster Joins – Pushdown Joins
• AcGvated when ndb_join_pushdown is on (default)
• Rules for a join to be pushed down:
1. Joined columns use idenGcal types
2. No reference to BLOB or TEXT columns
3. No explicit lock
4. Child tables in the Join must be accessed using ref, eq_ref, or const
5. Tables not explicitly parGGoned by [LINEAR] HASH, LIST, or RANGE
6. Query execuGon plan doesn’t use mysqld’s internal ‘join buffer'
7. If root of join is of the eq_ref or const type, child tables must be joined by eq_ref
• Run ANALYZE TABLE <table_name> on each table once
• Use EXPLAIN to see what components are being pushed down:
– For example: Extra: Child of 'd' in pushed join@1
Copyright 2016, oracle and/or its affiliates. All rights reserved 43
49. MySQL Cluster Hardware SelecGon
• Up to 64 x86_64 bit CPU threads (vCPUs)
– High frequency: enables faster processing of messages
• CalculaGng RAM per Data Node (in-memory database)
– Database Size * # Replicas * 1.25 / # data nodes
– 50GB database * 2 replicas * 1.25 / 2 data nodes = 64GB of RAM
– Non-indexed columns can be stored on disk, reduces RAM requirements
• 2 NICs and 2 PSUs
• Deep-dive into network best-pracGces in Reference Architecture Guide
• Use MaxNoOfExecutionThreads or ThreadConfig to configure how threads
should be allocated
Data Nodes
Copyright 2016, oracle and/or its affiliates. All rights reserved 49
60. MySQL Cluster Backups
• Backup of NDB tables
– Online – can have ongoing transacGons
– Consistent – only commi}ed data and changes
are backed up
• ndb_mgm -e "START BACKUP"
– Copy backup files from data nodes to safe
persistent locaGon
– Non-NDB tables must be backed up separately
– MySQL system tables are stored in MyISAM or
InnoDB
• You want to backup (for each MySQL
Server)
– mysql database/schema
– Triggers, rouGnes, events, ...
• Use mysqldump
– mysqldump mysql > mysql.sql
– mysqldump --no-data -A >
schemas.sql
– mysqldump --no-data --no-create-
info -R > routines.sql
• Copy my.cnf & config.ini files
Copyright 2016, oracle and/or its affiliates. All rights reserved 60
62. Features to Use With CauGon
• Large BLOBs
• Disk based tables
• Enforced Foreign Keys
• Large range scans and joins
• Spli…ng a single MySQL Cluster over mulGple data centers
• AcGve-AcGve Geographic ReplicaGon
– Fine to use but best if conflicts can be avoided on the applicaGon side
Copyright 2016, oracle and/or its affiliates. All rights reserved 62
Poten0al Impacts to Performance, Capacity, & Stability
73. Without MySQL Cluster Manager
• 1 x preliminary check of cluster state
• 8 x ssh commands per server
• 8 x per-process stop commands
• 4 x scp of config files (2 x mgmd & 2 x mysqld)
• 8 x per-process start commands
• 8 x checks for started and re-joined processes
• 8 x process compleGon verificaGons
• 1 x verify compleGon of the whole cluster
• Excludes manual ediGng of each configuraGon file
• Total: 46 commands
– 2.5 hours of aNended opera8on
With MySQL Cluster Manager
mcm> upgrade cluster
--package=7.4 mycluster;
• Total: 1 Command
– UnaNended Opera8on
Sopware Upgrade – Example of MCM Benefits
Copyright 2016, oracle and/or its affiliates. All rights reserved 73