SlideShare a Scribd company logo
1 of 59
Download to read offline
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 121
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 122
Insert Picture Here
Breakthrough performance
with MySQL Cluster
Frazer Clement
Senior Software Engineer, Oracle
frazer.clement@oracle.com
messagepassing.blogspot.com
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.3
Session Agenda
•
Introduction to MySQL Cluster performance
•
Understanding MySQL Cluster
•
Making Benchmarks
•
Monitoring and Measuring MySQL Cluster
•
Boosting performance
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.4
Disclaimer
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 DECISION. THE
DEVELOPMENT, RELEASE, AND TIMING OF ANY FEATURES OR
FUNCTIONALITY DESCRIBED FOR ORACLE'S PRODUCTS
REMAINS AT THE SOLE DISCRETION OF ORACLE
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.5
Insert Picture Here
Introduction to MySQL
Cluster performance
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.6
MySQL Cluster – Users & Applications
Extreme Scalability, Availability and Affordability
•
Web
•
High volume OLTP
•
eCommerce
•
On-Line Gaming
•
Digital Marketing
•
User Profile Management
•
Session Management & Caching
•
Telecoms
•
Service Delivery Platforms
•
VAS: VoIP, IPTV & VoD
•
Mobile Content Delivery
•
Mobile Payments
•
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.7
MySQL Cluster Architecture
Data
Nodes
Node Group 1
F1
F3
F3
F1
Node Group 2
F2
F4
F4
F2
Application Nodes
Cluster
Mgmt
Cluster
Mgmt
RESTJPA
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.8
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.9
4.3
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.10
4.3
/ 1 Billion Updates per Minute
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.11
MySQL Cluster Performance Gains
4.3 Billion + reads per minute, 30 node Intel Xeon cluster
NoSQL C++ API, flexAsynch benchmark
Huge increase in peak performance 7.1 -> 7.2
7.1
7.2
0 10 20 30 40 50 60 70 80
Million queries per second
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.12
1.2 Billion updates per minute, 30 node Intel E5-2600 based cluster
All updates transactional and synchronously replicated using 2PC
NoSQL, C++ API flexAsynch benchmark
Improvements due to enhanced per-node multicore scalability, inter-node
communication improvements, faster CPUs.
MySQL Cluster Performance Gains
Huge increase in peak performance 7.1 -> 7.2
MySQL Cluster continues to scale on new hardware
mikaelronstrom.blogspot.com
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.13
Gains on More Complex Transactions
Billions per minute benchmarks are on very simple transactions.
7.2 aims to better support more complex transactions using Adaptive
Query Localization (AQL) aka SPJ.
AQL has the data nodes execute some table joins, reducing round trips,
data transfer and increasing parallelism.
Aimed at small to medium sized joins.
Combined with new Index Statistics feature in 7.2, gives great joins
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.14
Gains on More Complex Transactions
Data
Node1
Data
Node2
MySQL
Server
Web-based Content Management System
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.15
Gains on More Complex Transactions
MySQL Cluster 7.1 MySQL Cluster 7.2
0
10
20
30
40
50
60
70
80
90
100
Query Execution Time Seconds
87.23 seconds
1.26 seconds
Index statistics + AQL give huge join performance gains 7.1->7.2
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.16
Performance and Optimisation
Rules of optimisation (http://c2.com/cgi/wiki?RulesOfOptimization)
i. Don't
ii. Don't yet (experts only)
iii. Profile before optimising
If you somehow reach iii) :
●
Know your goals, so you know when to stop.
●
Understand the system being optimised
●
Ignore DBMS vendors benchmarks! Build your own for your
application / queries / use cases.
●
Benchmarks should be easy to run, giving repeatable results
●
Use DBMS, OS and third party tools to profile and understand
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.17
Insert Picture Here
Understanding MySQL
Cluster
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.18
Understand Latency in MySQL Cluster
MySQL client MySQL server Data node 1 Data node 2
Angle
Dependent on
Network
technology
Batching,
batchsizes
Pushed joins
Distribution
awareness.
Batching
Partition
pruning
Standard
MySQL client
roundtrip
optimisation
(Stored
procedures,
joins)
Time
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.19
Understand Latency in MySQL Cluster
Round trips more expensive the higher up the stack they are.
Round trips are forced by data dependencies between operations – also
sometimes by the inability of lower stack layers to understand them.
Some dependencies can only be handled by the client/application.
Some can be handled by the MySQL Server (e.g. joins).
Some can be handled by the MySQL Cluster data nodes (e.g. as pushed
equi-joins in 7.2).
Handling data dependencies lower down the stack improves
performance, but not always possible.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.20
Understand Latency in MySQL Cluster
The MySQL Cluster data nodes have a huge request processing
capacity - the difficulty is in keeping them busy.
With synchronous clients, and requests which result in many roundtrips,
giving a high latency to work ratio, very many client threads are required
to drive a high load on the data nodes.
Reducing roundtrips makes it easier to load the cluster, avoiding
problems with heavy client thread concurrency.
Reducing roundtrips improves individual query response times
4.3 Bn reads/min benchmark uses asynchronous clients
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.21
Understand Latency in MySQL Cluster
MySQL client MySQL server Data node 1 Data node 2
1 1 2
INSERT INTO t1 VALUES (12, …);
INSERT INTO t1 VALUES (13, …);
INSERT INTO t1 VALUES (14, …);
…
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.22
Understand Latency in MySQL Cluster
MySQL client MySQL server Data node 1 Data node 2
1 1 2
INSERT INTO t1 VALUES
(12, …), (13, …), (14, …),
(15, …), (16, …), (17, …);
…
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.23
Understand Latency in MySQL Cluster
MySQL client MySQL server Data node 1 Data node 2
1 3 1
Unpushed
SELECT … FROM t1 JOIN t2
JOIN t3 ON t2.key =
t1.attr AND t3.key =
t2.attr AND t1.key =
<const>;
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.24
Understand Data Distribution in MySQL Cluster
●
Rows are spread around data nodes based on an MD5 hash of
(some/all) of their primary key columns. This is pseudo-random.
●
Random gives good balance, but defeats locality of access benefits.
●
Find (or add) some localising column in your primary key, partition by
this, and related data will be stored.
●
Benefits :
- Reduced data-node round trips for reads (Latency + efficiency)
- Fewer 2PC participants for writes (Latency + efficiency)
- Scans bounded by the localising column are 'pruned'
(Efficiency + scalability)
Ordered index scans must be pruned to scale with the number of data nodes
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.25
Understand Data Distribution in MySQL Cluster
NdbApi client Data node 1 Data node 2 Data node 3 Data node 3
Non pruned scan, all nodes involved, no scaling with # nodes
SELECT … FROM t1 WHERE
<expression using ordered
index without EQ on all
t1 partition key columns>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.26
Understand Data Distribution in MySQL Cluster
NdbApi client Data node 1 Data node 2 Data node 3 Data node 3
Pruned scan, 2 nodes involved, scales with # nodes
SELECT … FROM t1 WHERE
part_key1=A AND
part_key2=B AND
ordered_index_key3
=><=Whatever;
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.27
Understand Data Distribution in MySQL Cluster
NdbApi client Data node 1 Data node 2 Data node 3 Data node 3
Hinted pruned scan, 1 node involved, scales with # nodes
Ordered index scans must be pruned to scale with the number of data nodes
SELECT … FROM t1 WHERE
part_key1=A AND
part_key2=B AND
ordered_index_key3
=><=Whatever;
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.28
Understand Data Distribution in MySQL Cluster
●
MySQL Cluster provides an abstraction of a single database spread
across a cluster of machines. You don't need to care about how data is
distributed to execute any query.
●
But to go fast you must think about data distribution.
●
One easy way is to consider how data would be distributed in an
equivalent sharded database system – to minimise or remove cross-
shard queries, joins, transactions etc. (e.g. shard by user id, by function,
by geography, by hierarchy)
●
Unlike a sharded database system, MySQL Cluster supports queries
which require cross-shard queries or transactions, but if your 'high
runner' queries are effectively 'sharded', they will benefit.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.29
Understand Parallelism in MySQL Cluster
NdbApi client Data node 1 Data node 2 Data node 3 Data node 3
Batch of primary key reads, executing in parallel
Batching gives intra-transaction parallelism
Parallelism is good for large queries/transactions
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.30
Performance Goals with MySQL Cluster
Good
Primary key operations
Unique key operations
Batching
Pruned index scans
Distribution awareness
Pushed conditions
Pushed joins
Parallelism (for large
queries/operations)
Bad
Round trips
Non pruned scans
'High running' Non distribution
aware queries
Ugly
BLOB/TEXT columns
Generally require ~1 extra Api
round trip per row
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.31
Insert Picture Here
Making Benchmarks
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.32
Making a Benchmark
●
Ideally use your application in a known, repeatable, relevant
'traffic' scenario.
●
Use existing or add instrumentation to measure how it performs
against your goals.
●
If goals are not being met, look at how to break out parts of the
functionality so that they can be benchmarked and analysed
individually – ideally still via your application.
●
Benchmark, analyse, improve
●
Benchmark with application to check end-to-end gains.
●
Making microbenchmarks? Reuse and extend existing tools –
mysqlslap, flexAsynch, memslap, etc.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.33
Making a Simple SQL Join Benchmark
create.sql:
CREATE TABLE sub_name (sub_id INT NOT NULL PRIMARY KEY, name
VARCHAR(30)) engine=ndb;
CREATE TABLE sub_age (sub_id INT NOT NULL PRIMARY KEY, age INT)
engine=ndb;
INSERT INTO sub_name VALUES (1,'Bill'),(2,'Fred'),(3,'Bill'),
(4,'Jane'),(5,'Andrew'),(6,'Anne'),(7,'Juliette'),(8,'Awen'),
(9,'Leo'),(10,'Bill');
INSERT INTO sub_age VALUES (1,40),(2,23),(3,33),(4,19),(5,21),
(6,50),(7,31),(8,65),(9,18),(10,101);
query.sql:
SELECT sub_age.age FROM sub_name, sub_age WHERE
sub_name.name='Bill' AND sub_name.sub_id=sub_age.sub_id;
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.34
Making a Simple SQL Join Benchmark
shell> mysqlslap --concurrency=5 --iterations=100 --query=query.sql
--create=create.sql
Benchmark
Average number of seconds to run all queries: 0.132
seconds
Minimum number of seconds to run all queries: 0.037
seconds
Maximum number of seconds to run all queries: 0.268
seconds
Number of clients running queries: 5
Average number of queries per client: 1
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.35
Insert Picture Here
Monitoring and Measuring
MySQL Cluster
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.36
Understand the MySQL Cluster Server stack
Ndb storage engine implementation
Handler / Storage Engine Api
SQL parsing, optimisation, execution
Client threads
NdbApi
Network communication with data nodes
MySQL clients MySQL clients MySQL clients
Generic
MySQL
Server code
Generic NdbApi
code
Glue
SQL
Handler Api calls
NdbApi calls
MySQL client
protocol
'Protocol 6'
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.37
MySQL Server Explain Plan
mysql> EXPLAIN <query>;
mysql> EXPLAIN PARTITIONS <query>;
mysql> EXPLAIN EXTENDED <query>;
mysql> SHOW WARNINGS;
Interpretation of output here is mostly the same as for generic MySQL
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.38
MySQL Server Explain Plan
In 7.2, EXPLAIN includes information about how a join was (or was not) pushed
down to the data nodes :
mysql> EXPLAIN SELECT sub_age.age FROM sub_name, sub_age WHERE sub_name.name='Bill' AND
sub_name.sub_id=sub_age.sub_id;
+----+-------------+----------+--------+---------------+---------+---------+----------------------+------
+--------------------------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows |
Extra |
+----+-------------+----------+--------+---------------+---------+---------+----------------------+------
+--------------------------------------------------------------+
| 1 | SIMPLE | sub_name | ALL | PRIMARY | NULL | NULL | NULL | 10 |
Parent of 2 pushed join@1; Using where with pushed condition |
| 1 | SIMPLE | sub_age | eq_ref | PRIMARY | PRIMARY | 4 | test.sub_name.sub_id | 1 |
Child of 'sub_name' in pushed join@1 |
+----+-------------+----------+--------+---------------+---------+---------+----------------------+------
+--------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql>
Full table scan of sub_name with pushed filter
(name='Bill') linked to primary key ops on sub_age
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.39
MySQL Server Explain Plan
mysql> alter table sub_age change column sub_id sub_id bigint;
...
mysql> EXPLAIN EXTENDED SELECT sub_age.age FROM sub_name, sub_age WHERE sub_name.name='Bill' AND
sub_name.sub_id=sub_age.sub_id;
+----+-------------+----------+--------+---------------+---------+---------+----------------------+------
+----------+------------------------------------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows |
filtered | Extra |
+----+-------------+----------+--------+---------------+---------+---------+----------------------+------
+----------+------------------------------------------------------------------------+
| 1 | SIMPLE | sub_name | ALL | PRIMARY | NULL | NULL | NULL | 10 |
100.00 | Using where with pushed condition: (`test`.`sub_name`.`name` = 'Bill') |
| 1 | SIMPLE | sub_age | eq_ref | PRIMARY | PRIMARY | 8 | test.sub_name.sub_id | 1 |
100.00 | Using where |
+----+-------------+----------+--------+---------------+---------+---------+----------------------+------
+----------+------------------------------------------------------------------------+
2 rows in set, 2 warnings (0.00 sec)
mysql> show warnings;
...
| Note | 1003 | Can't push table 'sub_age' as child, column 'sub_id' does not have same datatype as ref'ed
column 'sub_name.sub_id' |
| Note | 1003 | select `test`.`sub_age`.`age` AS `age` from `test`.`sub_name` join `test`.`sub_age` where
((`test`.`sub_name`.`name` = 'Bill') and (`test`.`sub_name`.`sub_id` = `test`.`sub_age`.`sub_id`)) |
EXPLAIN EXTENDED gives
details of push-failure in warnings
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.40
MySQL Server Stack Profiles
GLOBAL/LOCAL STATUS variables Session
SHOW LOCAL STATUS LIKE 'Com_%'; SQL commands
SHOW LOCAL STATUS LIKE 'Handler%'; Handler Api calls
SHOW STATUS LIKE 'Ndb_api%session'; Ndb Api calls
Server
SHOW GLOBAL STATUS LIKE 'Com_%'; SQL commands
SHOW GLOBAL STATUS LIKE 'Handler%'; Handler Api calls
SHOW STATUS LIKE 'Ndb_api%count'; Ndb Api calls
SHOW STATUS LIKE 'Ndb'; Various stats
SHOW ENGINE NDB STATUS; Connection level
Understand SQL -> Handler -> NdbApi mapping
Also available from
INFORMATION_SCHEMA for
use in SELECTs + Views
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.41
MySQL Server NdbApi Call Profile
mysql> show status like 'ndb_api%session';
+----------------------------------------------+------------+
| Variable_name | Value |
+----------------------------------------------+------------+
| Ndb_api_wait_exec_complete_count_session | 12 |
| Ndb_api_wait_scan_result_count_session | 9 |
| Ndb_api_wait_meta_request_count_session | 24 |
| Ndb_api_wait_nanos_count_session | 1086595954 |
| Ndb_api_bytes_sent_count_session | 8504 |
| Ndb_api_bytes_received_count_session | 12032 |
| Ndb_api_trans_start_count_session | 6 |
| Ndb_api_trans_commit_count_session | 4 |
| Ndb_api_trans_abort_count_session | 1 |
| Ndb_api_trans_close_count_session | 6 |
| Ndb_api_pk_op_count_session | 11 |
| Ndb_api_uk_op_count_session | 0 |
| Ndb_api_table_scan_count_session | 2 |
...
+----------------------------------------------+------------+
21 rows in set (0.00 sec)
mysql> 
Network roundtrips
Api Data transfer
NdbApi api call
profile
Details : http://messagepassing.blogspot.com/
2011/04/journey-upriver-to-dark-heart-of.html
+ MySQL Cluster Reference Manual
Also available
from NdbApi!
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.42
NdbInfo Schema
●
NdbInfo tables are 'pseudo
tables' generated on demand
by data nodes.
●
Contain information about
resource usage levels,
dynamic counts, user operation
and transaction states etc.
●
Generally cluster-wide
●
Much more information will be
added to NdbInfo tables over
time.
mysql> show tables;
+----------------------+
| Tables_in_ndbinfo |
+----------------------+
| blocks |
| cluster_operations |
| cluster_transactions |
| config_params |
| counters |
| diskpagebuffer |
| logbuffers |
| logspaces |
| memoryusage |
| nodes |
| resources |
| server_operations |
| server_transactions |
| threadblocks |
| threadstat |
| transporters |
+----------------------+
16 rows in set (0.00 sec)
mysql>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.43
NdbInfo Counters Table Schema
mysql> select block_name, counter_name from
ndbinfo.counters group by block_name, counter_name;
+------------+-----------------------------------+
| block_name | counter_name |
+------------+-----------------------------------+
| DBLQH | OPERATIONS |
| DBSPJ | CONST_PRUNED_RANGE_SCANS_RECEIVED |
| DBSPJ | LOCAL_RANGE_SCANS_SENT |
| DBSPJ | LOCAL_READS_SENT |
| DBSPJ | LOCAL_TABLE_SCANS_SENT |
| DBSPJ | PRUNED_RANGE_SCANS_RECEIVED |
| DBSPJ | RANGE_SCANS_RECEIVED |
| DBSPJ | READS_NOT_FOUND |
| DBSPJ | READS_RECEIVED |
| DBSPJ | REMOTE_RANGE_SCANS_SENT |
| DBSPJ | REMOTE_READS_SENT |
| DBSPJ | SCAN_BATCHES_RETURNED |
| DBSPJ | SCAN_ROWS_RETURNED |
| DBSPJ | TABLE_SCANS_RECEIVED |
...
…
|
| DBTC | ABORTS |
| DBTC | ATTRINFO |
| DBTC | COMMITS |
| DBTC | LOCAL_READS |
| DBTC | LOCAL_WRITES |
| DBTC | RANGE_SCANS |
| DBTC | READS |
| DBTC | SIMPLE_READS |
| DBTC | TABLE_SCANS |
| DBTC | TRANSACTIONS |
| DBTC | WRITES |
+------------+-----------------------------------+
25 rows in set (0.01 sec)
mysql>
Information about how the data nodes are executing your transactions
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.44
Use OS-level Tools to Understand Performance
top
IOSTAT
VMSTAT
mpstat
strace
perf
dtrace
oprofile
netstat
Ifconfig
PMP
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.45
MySQL Server Profiling in Production
Enable the slow query log
set global slow_query_log=1;
set global long_query_time=3; //3 seconds
set global log_queries_not_using_indexes=1;
Slow queries will be written in the slow query log:
mysql> show global variables like 'slow_query_log_file';
+---------------------+------------------------------+
| Variable_name | Value |
+---------------------+------------------------------+
| slow_query_log_file | /data1/mysql/mysqld-slow.log |
+---------------------+------------------------------+
Queries will be written in plain text
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.46
Query Analyzer?
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.47
Insert Picture Here
Boosting Performance
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.48
Using AQL to Perform Efficient Joins (7.2 only)
Activated when ndb_join_pushdown is on (default)
Rules for a Join to be pushed down:
- Joined columns use identical types
- No reference to BLOB or TEXT columns
- No explicit locking
- Child tables in the Join must be accessed using one of the ref, eq_ref, or
const
- Tables not explicitly partitioned by [LINEAR] HASH, LIST, or RANGE
- Query plan doesn’t select ‘Using join buffer'
- If root of Join is an eq_ref or const, child tables must be joined by eq_ref
Run ANALYZE TABLE <tab-name> on each table once
Use EXPLAIN to see what components are being pushed down:
Extra: Child of 'd' in pushed join@1
EXPLAIN EXTENDED <query>;SHOW WARNINGS;.
Joins are far more time
efficient than before,
but can still be
resource heavy.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.49
Batching Within a Transaction
Batching amortises the round-trip latency across multiple operations and/or
results.
Primary and unique key operations can be sent in batches, which will be
executed concurrently + in parallel if on different nodes/fragments.
Ordered index and table scans send their results in batches, allowing buffer
space to be traded for round trips.
Example – Insert 1M records
No batching:
INSERT INTO t1(data) VALUES (<data>);
765 seconds to insert 1M records
Batching (batches of 16):
INSERT INTO t1(<columns>) VALUES (<data>), (<data>)...
50 seconds to insert 1M records
Time ratio here is 15.3:1 –
almost the same as the
batching factor. Most of
the response time is
request/response latency.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.50
Batching Within a Transaction
SELECT * FROM t1 WHERE userid=1 AND serviceid IN
(1,2,3,4,5,7,8,9,10);
SET transaction_allow_batching=1; //must be set on the connection
BEGIN;
INSERT INTO t1 ....;
INSERT INTO t2 ....;
INSERT INTO t3 ....;
INSERT INTO t4 ....;
DELETE FROM t5 ....;
UPDATE t1 SET value='new value' WHERE id=1;
COMMIT;
Verify the effect of these statements using the SHOW STATUS LIKE
'ndb_api_wait%session' counters.
Errors associated with a
statement may be
reported against a later
statement in the
transaction.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.51
Distribution Awareness
Select a partitioning key for your schema which maximises the locality of your
high-running queries (Subscriber id, Session id, Product id, Order id, Tree root
nodes)
Doesn't matter if low-running queries have no locality.
Consider adding extra key columns to your tables to enable this, using a
secondary unique index to enforce uniqueness on the original PK if necessary.
Change DDL to use partitioning key : CREATE TABLE t1 … ENGINE=NDB
PARTITION BY KEY <My key(s)>;
In 'high running' transactions, perform first query using EQ on partitioning key
column(s) to give placement hint to MySQL Server.
Consider splitting your transactions if the partitioning key value is not known at
the start of a high running transaction. Do you need transactional semantics?
Specified per-table,
used across tables
Monitor distribution awareness and pruning
using SHOW STATUS and NdbInfo
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.52
Simplify Transactions
Simpler transactions (fewer tables, fewer rows, primary key access) are much
simpler for the system to run fast.
Schema denormalisation can remove the need for some joins.
Some applications have data which need not be disk-persistent (WAL redo
logged and checkpointed). By removing their disk-persistence, they can sustain
high write rates without pressuring disk IO. After a system recovery, the table will
be empty.
mysql> set ndb_table_no_logging=1;
mysql> create table session_table(..) engine=ndb;
mysql> set ndb_table_no_logging=0;
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.53
Multithreaded Data Nodes
MySQL Cluster data nodes use many threads for disk and network IO, and
database request processing. Request processing threads use a shared-nothing,
non-blocking message passing model with very little inter-thread locking.
Multithreading in Ndb is to enable use of multiple HW cores, therefore, roughly
one request processing thread per HW core is used as a guideline when
configuring.
The threads are asymmetric – work is partitioned among them functionally. This
means that the balance of thread types and counts depends on the workload to
be handled. If in doubt, use the default configuration for your HW core
count.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.54
Multithreaded Data Nodes
Replication thread
Main thread
LDM threads
TC threads
Send threads
Request
processing
threads
TC and LDM threads
do most work, must
be well fed by Send +
Receive threads
Receive threads IO threads
Connect threads Watchdog
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.55
Hardware for Performance
High bandwidth, low latency network
- Infiniband is nice
Multiple disks if disk IO is a problem
- Split checkpoints from Redo logs from DD Tablespaces
Consider SSDs
- Best for DD Tablespaces as logs and Checkpoints are mostly serialised writes
Refer to MySQL Cluster Evaluation Guide for more advice
MySQL Cluster runs great on low end hardware, especially where applications,
schemas and queries are tuned for it.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.56
Choice of Api
Lower level Apis can give more control, as well as removing latency and
complexity.
However, they may require development to integrate with your systems.
For the best performance, use C++ NdbApi, or the ClusterJ Java Api. NdbApi
gives greater control, at the cost of greater complexity.
The memcached or HTTP/REST Apis also expose good performance through a
simplified Api.
Native memcached HTTP/REST
JDBC / ODBC
PHP / PERL
Python / Ruby
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.57
Breakthrough Performance?
1. Understand the system and its bottlenecks
MySQL manual, blogs, whitepapers, forum, mailing list,
Experimentation
2. Set goals
3. while (!goal.met())
{Benchmark, Monitor, Measure, Optimise}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1258
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.59
Connection Pooling and the Query Cache
Connection pooling here refers to having more than one logical connection from a
MySQL Server to the Ndb data nodes. (Each logical connection has many
internal socket connections).
This can be used to avoid bottlenecks due to per-logical connection locking.
Consumes [API] slots.
The MySQL Query cache caches query results. However it is asynchronously
invalidated by Ndb as the cached tables are changed in the cluster.
With a high change rate, the rate of query cache invalidations can become
excessive.
Should only really be considered for very static tables, where applications can
tolerate some staleness.

More Related Content

What's hot

Posscon my sql56
Posscon my sql56Posscon my sql56
Posscon my sql56Dave Stokes
 
MySQL For Oracle Developers
MySQL For Oracle DevelopersMySQL For Oracle Developers
MySQL For Oracle DevelopersRonald Bradford
 
OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09
OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09
OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09OSSCube
 
Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...
Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...
Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...Keith Hollman
 
MySQL Performance Best Practices
MySQL Performance Best PracticesMySQL Performance Best Practices
MySQL Performance Best PracticesOlivier DASINI
 
MySQL Cluster 8.0 tutorial text
MySQL Cluster 8.0 tutorial textMySQL Cluster 8.0 tutorial text
MySQL Cluster 8.0 tutorial textFrazer Clement
 
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014Dave Stokes
 
MySQL NDB Cluster 8.0
MySQL NDB Cluster 8.0MySQL NDB Cluster 8.0
MySQL NDB Cluster 8.0Ted Wennmark
 
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007eLiberatica
 
MySql's NoSQL -- best of both worlds on the same disks
MySql's NoSQL -- best of both worlds on the same disksMySql's NoSQL -- best of both worlds on the same disks
MySql's NoSQL -- best of both worlds on the same disksDave Stokes
 
The Great Debate: PostgreSQL vs MySQL
The Great Debate: PostgreSQL vs MySQLThe Great Debate: PostgreSQL vs MySQL
The Great Debate: PostgreSQL vs MySQLEDB
 
Confoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New FeaturesConfoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New FeaturesDave Stokes
 
Midwest PHP Presentation - New MSQL Features
Midwest PHP Presentation - New MSQL FeaturesMidwest PHP Presentation - New MSQL Features
Midwest PHP Presentation - New MSQL FeaturesDave Stokes
 
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...Dave Stokes
 
High-Availability using MySQL Fabric
High-Availability using MySQL FabricHigh-Availability using MySQL Fabric
High-Availability using MySQL FabricMats Kindahl
 
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San FranciscoMySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San FranciscoDave Stokes
 
MySQL Document Store for Modern Applications
MySQL Document Store for Modern ApplicationsMySQL Document Store for Modern Applications
MySQL Document Store for Modern ApplicationsOlivier DASINI
 
Run Cloud Native MySQL NDB Cluster in Kubernetes
Run Cloud Native MySQL NDB Cluster in KubernetesRun Cloud Native MySQL NDB Cluster in Kubernetes
Run Cloud Native MySQL NDB Cluster in KubernetesBernd Ocklin
 
Postgres_9.0 vs MySQL_5.5
Postgres_9.0 vs MySQL_5.5Postgres_9.0 vs MySQL_5.5
Postgres_9.0 vs MySQL_5.5Trieu Dao Minh
 

What's hot (20)

Posscon my sql56
Posscon my sql56Posscon my sql56
Posscon my sql56
 
MySQL For Oracle Developers
MySQL For Oracle DevelopersMySQL For Oracle Developers
MySQL For Oracle Developers
 
My sql 5.6&MySQL Cluster 7.3
My sql 5.6&MySQL Cluster 7.3My sql 5.6&MySQL Cluster 7.3
My sql 5.6&MySQL Cluster 7.3
 
OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09
OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09
OSSCube MySQL Cluster Tutorial By Sonali At Osspac 09
 
Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...
Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...
Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...
 
MySQL Performance Best Practices
MySQL Performance Best PracticesMySQL Performance Best Practices
MySQL Performance Best Practices
 
MySQL Cluster 8.0 tutorial text
MySQL Cluster 8.0 tutorial textMySQL Cluster 8.0 tutorial text
MySQL Cluster 8.0 tutorial text
 
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
 
MySQL NDB Cluster 8.0
MySQL NDB Cluster 8.0MySQL NDB Cluster 8.0
MySQL NDB Cluster 8.0
 
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007
 
MySql's NoSQL -- best of both worlds on the same disks
MySql's NoSQL -- best of both worlds on the same disksMySql's NoSQL -- best of both worlds on the same disks
MySql's NoSQL -- best of both worlds on the same disks
 
The Great Debate: PostgreSQL vs MySQL
The Great Debate: PostgreSQL vs MySQLThe Great Debate: PostgreSQL vs MySQL
The Great Debate: PostgreSQL vs MySQL
 
Confoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New FeaturesConfoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New Features
 
Midwest PHP Presentation - New MSQL Features
Midwest PHP Presentation - New MSQL FeaturesMidwest PHP Presentation - New MSQL Features
Midwest PHP Presentation - New MSQL Features
 
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
 
High-Availability using MySQL Fabric
High-Availability using MySQL FabricHigh-Availability using MySQL Fabric
High-Availability using MySQL Fabric
 
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San FranciscoMySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
 
MySQL Document Store for Modern Applications
MySQL Document Store for Modern ApplicationsMySQL Document Store for Modern Applications
MySQL Document Store for Modern Applications
 
Run Cloud Native MySQL NDB Cluster in Kubernetes
Run Cloud Native MySQL NDB Cluster in KubernetesRun Cloud Native MySQL NDB Cluster in Kubernetes
Run Cloud Native MySQL NDB Cluster in Kubernetes
 
Postgres_9.0 vs MySQL_5.5
Postgres_9.0 vs MySQL_5.5Postgres_9.0 vs MySQL_5.5
Postgres_9.0 vs MySQL_5.5
 

Similar to Breakthrough performance with MySQL Cluster (2012)

Ohio Linux Fest -- MySQL's NoSQL
Ohio Linux Fest -- MySQL's NoSQLOhio Linux Fest -- MySQL's NoSQL
Ohio Linux Fest -- MySQL's NoSQLDave Stokes
 
MySQL's NoSQL -- Texas Linuxfest August 22nd 2015
MySQL's NoSQL  -- Texas Linuxfest August 22nd 2015MySQL's NoSQL  -- Texas Linuxfest August 22nd 2015
MySQL's NoSQL -- Texas Linuxfest August 22nd 2015Dave Stokes
 
NoSQL and MySQL: News about JSON
NoSQL and MySQL: News about JSONNoSQL and MySQL: News about JSON
NoSQL and MySQL: News about JSONMario Beck
 
MIGRATION OF AN OLTP SYSTEM FROM ORACLE TO MYSQL AND COMPARATIVE PERFORMANCE ...
MIGRATION OF AN OLTP SYSTEM FROM ORACLE TO MYSQL AND COMPARATIVE PERFORMANCE ...MIGRATION OF AN OLTP SYSTEM FROM ORACLE TO MYSQL AND COMPARATIVE PERFORMANCE ...
MIGRATION OF AN OLTP SYSTEM FROM ORACLE TO MYSQL AND COMPARATIVE PERFORMANCE ...cscpconf
 
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
 
Meetup my sql5.6_cluster
Meetup my sql5.6_clusterMeetup my sql5.6_cluster
Meetup my sql5.6_clusterLee Stigile
 
State of The Dolphin - May 2021
State of The Dolphin - May 2021State of The Dolphin - May 2021
State of The Dolphin - May 2021Frederic Descamps
 
From Nice to Have to Mission Critical: MySQL Enterprise Edition
From Nice to Have to Mission Critical: MySQL Enterprise EditionFrom Nice to Have to Mission Critical: MySQL Enterprise Edition
From Nice to Have to Mission Critical: MySQL Enterprise Edition郁萍 王
 
200 million qps on commodity hardware : Getting started with MySQL Cluster 7.4
200 million qps on commodity hardware : Getting started with MySQL Cluster 7.4200 million qps on commodity hardware : Getting started with MySQL Cluster 7.4
200 million qps on commodity hardware : Getting started with MySQL Cluster 7.4Frazer Clement
 
NewSQL - Deliverance from BASE and back to SQL and ACID
NewSQL - Deliverance from BASE and back to SQL and ACIDNewSQL - Deliverance from BASE and back to SQL and ACID
NewSQL - Deliverance from BASE and back to SQL and ACIDTony Rogerson
 
My sql 56_roadmap_april2012
My sql 56_roadmap_april2012My sql 56_roadmap_april2012
My sql 56_roadmap_april2012sqlhjalp
 
20190817 coscup-oracle my sql innodb cluster sharing
20190817 coscup-oracle my sql innodb cluster sharing20190817 coscup-oracle my sql innodb cluster sharing
20190817 coscup-oracle my sql innodb cluster sharingIvan Ma
 
MySQL High Availability Solutions - Avoid loss of service by reducing the r...
MySQL High Availability Solutions  -  Avoid loss of service by reducing the r...MySQL High Availability Solutions  -  Avoid loss of service by reducing the r...
MySQL High Availability Solutions - Avoid loss of service by reducing the r...Olivier DASINI
 
RivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdfRivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdfFrederic Descamps
 
Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...
Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...
Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...Trivadis
 
My sql crashcourse_2012
My sql crashcourse_2012My sql crashcourse_2012
My sql crashcourse_2012sqlhjalp
 
MySQL Goes to 8! FOSDEM 2020 Database Track, January 2nd, 2020
MySQL Goes to 8!  FOSDEM 2020 Database Track, January 2nd, 2020MySQL Goes to 8!  FOSDEM 2020 Database Track, January 2nd, 2020
MySQL Goes to 8! FOSDEM 2020 Database Track, January 2nd, 2020Geir Høydalsvik
 
Oracle Database Migration to Oracle Cloud Infrastructure
Oracle Database Migration to Oracle Cloud InfrastructureOracle Database Migration to Oracle Cloud Infrastructure
Oracle Database Migration to Oracle Cloud InfrastructureSinanPetrusToma
 

Similar to Breakthrough performance with MySQL Cluster (2012) (20)

Ohio Linux Fest -- MySQL's NoSQL
Ohio Linux Fest -- MySQL's NoSQLOhio Linux Fest -- MySQL's NoSQL
Ohio Linux Fest -- MySQL's NoSQL
 
NoSQL and MySQL
NoSQL and MySQLNoSQL and MySQL
NoSQL and MySQL
 
MySQL Cluster
MySQL ClusterMySQL Cluster
MySQL Cluster
 
MySQL's NoSQL -- Texas Linuxfest August 22nd 2015
MySQL's NoSQL  -- Texas Linuxfest August 22nd 2015MySQL's NoSQL  -- Texas Linuxfest August 22nd 2015
MySQL's NoSQL -- Texas Linuxfest August 22nd 2015
 
NoSQL and MySQL: News about JSON
NoSQL and MySQL: News about JSONNoSQL and MySQL: News about JSON
NoSQL and MySQL: News about JSON
 
MIGRATION OF AN OLTP SYSTEM FROM ORACLE TO MYSQL AND COMPARATIVE PERFORMANCE ...
MIGRATION OF AN OLTP SYSTEM FROM ORACLE TO MYSQL AND COMPARATIVE PERFORMANCE ...MIGRATION OF AN OLTP SYSTEM FROM ORACLE TO MYSQL AND COMPARATIVE PERFORMANCE ...
MIGRATION OF AN OLTP SYSTEM FROM ORACLE TO MYSQL AND COMPARATIVE PERFORMANCE ...
 
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
 
Meetup my sql5.6_cluster
Meetup my sql5.6_clusterMeetup my sql5.6_cluster
Meetup my sql5.6_cluster
 
State of The Dolphin - May 2021
State of The Dolphin - May 2021State of The Dolphin - May 2021
State of The Dolphin - May 2021
 
From Nice to Have to Mission Critical: MySQL Enterprise Edition
From Nice to Have to Mission Critical: MySQL Enterprise EditionFrom Nice to Have to Mission Critical: MySQL Enterprise Edition
From Nice to Have to Mission Critical: MySQL Enterprise Edition
 
200 million qps on commodity hardware : Getting started with MySQL Cluster 7.4
200 million qps on commodity hardware : Getting started with MySQL Cluster 7.4200 million qps on commodity hardware : Getting started with MySQL Cluster 7.4
200 million qps on commodity hardware : Getting started with MySQL Cluster 7.4
 
NewSQL - Deliverance from BASE and back to SQL and ACID
NewSQL - Deliverance from BASE and back to SQL and ACIDNewSQL - Deliverance from BASE and back to SQL and ACID
NewSQL - Deliverance from BASE and back to SQL and ACID
 
My sql 56_roadmap_april2012
My sql 56_roadmap_april2012My sql 56_roadmap_april2012
My sql 56_roadmap_april2012
 
20190817 coscup-oracle my sql innodb cluster sharing
20190817 coscup-oracle my sql innodb cluster sharing20190817 coscup-oracle my sql innodb cluster sharing
20190817 coscup-oracle my sql innodb cluster sharing
 
MySQL High Availability Solutions - Avoid loss of service by reducing the r...
MySQL High Availability Solutions  -  Avoid loss of service by reducing the r...MySQL High Availability Solutions  -  Avoid loss of service by reducing the r...
MySQL High Availability Solutions - Avoid loss of service by reducing the r...
 
RivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdfRivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdf
 
Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...
Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...
Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...
 
My sql crashcourse_2012
My sql crashcourse_2012My sql crashcourse_2012
My sql crashcourse_2012
 
MySQL Goes to 8! FOSDEM 2020 Database Track, January 2nd, 2020
MySQL Goes to 8!  FOSDEM 2020 Database Track, January 2nd, 2020MySQL Goes to 8!  FOSDEM 2020 Database Track, January 2nd, 2020
MySQL Goes to 8! FOSDEM 2020 Database Track, January 2nd, 2020
 
Oracle Database Migration to Oracle Cloud Infrastructure
Oracle Database Migration to Oracle Cloud InfrastructureOracle Database Migration to Oracle Cloud Infrastructure
Oracle Database Migration to Oracle Cloud Infrastructure
 

Recently uploaded

Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 

Recently uploaded (20)

Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 

Breakthrough performance with MySQL Cluster (2012)

  • 1. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 121
  • 2. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 122 Insert Picture Here Breakthrough performance with MySQL Cluster Frazer Clement Senior Software Engineer, Oracle frazer.clement@oracle.com messagepassing.blogspot.com
  • 3. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.3 Session Agenda • Introduction to MySQL Cluster performance • Understanding MySQL Cluster • Making Benchmarks • Monitoring and Measuring MySQL Cluster • Boosting performance
  • 4. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.4 Disclaimer 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 DECISION. THE DEVELOPMENT, RELEASE, AND TIMING OF ANY FEATURES OR FUNCTIONALITY DESCRIBED FOR ORACLE'S PRODUCTS REMAINS AT THE SOLE DISCRETION OF ORACLE
  • 5. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.5 Insert Picture Here Introduction to MySQL Cluster performance
  • 6. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.6 MySQL Cluster – Users & Applications Extreme Scalability, Availability and Affordability • Web • High volume OLTP • eCommerce • On-Line Gaming • Digital Marketing • User Profile Management • Session Management & Caching • Telecoms • Service Delivery Platforms • VAS: VoIP, IPTV & VoD • Mobile Content Delivery • Mobile Payments •
  • 7. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.7 MySQL Cluster Architecture Data Nodes Node Group 1 F1 F3 F3 F1 Node Group 2 F2 F4 F4 F2 Application Nodes Cluster Mgmt Cluster Mgmt RESTJPA
  • 8. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.8
  • 9. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.9 4.3
  • 10. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.10 4.3 / 1 Billion Updates per Minute
  • 11. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.11 MySQL Cluster Performance Gains 4.3 Billion + reads per minute, 30 node Intel Xeon cluster NoSQL C++ API, flexAsynch benchmark Huge increase in peak performance 7.1 -> 7.2 7.1 7.2 0 10 20 30 40 50 60 70 80 Million queries per second
  • 12. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.12 1.2 Billion updates per minute, 30 node Intel E5-2600 based cluster All updates transactional and synchronously replicated using 2PC NoSQL, C++ API flexAsynch benchmark Improvements due to enhanced per-node multicore scalability, inter-node communication improvements, faster CPUs. MySQL Cluster Performance Gains Huge increase in peak performance 7.1 -> 7.2 MySQL Cluster continues to scale on new hardware mikaelronstrom.blogspot.com
  • 13. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.13 Gains on More Complex Transactions Billions per minute benchmarks are on very simple transactions. 7.2 aims to better support more complex transactions using Adaptive Query Localization (AQL) aka SPJ. AQL has the data nodes execute some table joins, reducing round trips, data transfer and increasing parallelism. Aimed at small to medium sized joins. Combined with new Index Statistics feature in 7.2, gives great joins
  • 14. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.14 Gains on More Complex Transactions Data Node1 Data Node2 MySQL Server Web-based Content Management System
  • 15. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.15 Gains on More Complex Transactions MySQL Cluster 7.1 MySQL Cluster 7.2 0 10 20 30 40 50 60 70 80 90 100 Query Execution Time Seconds 87.23 seconds 1.26 seconds Index statistics + AQL give huge join performance gains 7.1->7.2
  • 16. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.16 Performance and Optimisation Rules of optimisation (http://c2.com/cgi/wiki?RulesOfOptimization) i. Don't ii. Don't yet (experts only) iii. Profile before optimising If you somehow reach iii) : ● Know your goals, so you know when to stop. ● Understand the system being optimised ● Ignore DBMS vendors benchmarks! Build your own for your application / queries / use cases. ● Benchmarks should be easy to run, giving repeatable results ● Use DBMS, OS and third party tools to profile and understand
  • 17. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.17 Insert Picture Here Understanding MySQL Cluster
  • 18. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.18 Understand Latency in MySQL Cluster MySQL client MySQL server Data node 1 Data node 2 Angle Dependent on Network technology Batching, batchsizes Pushed joins Distribution awareness. Batching Partition pruning Standard MySQL client roundtrip optimisation (Stored procedures, joins) Time
  • 19. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.19 Understand Latency in MySQL Cluster Round trips more expensive the higher up the stack they are. Round trips are forced by data dependencies between operations – also sometimes by the inability of lower stack layers to understand them. Some dependencies can only be handled by the client/application. Some can be handled by the MySQL Server (e.g. joins). Some can be handled by the MySQL Cluster data nodes (e.g. as pushed equi-joins in 7.2). Handling data dependencies lower down the stack improves performance, but not always possible.
  • 20. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.20 Understand Latency in MySQL Cluster The MySQL Cluster data nodes have a huge request processing capacity - the difficulty is in keeping them busy. With synchronous clients, and requests which result in many roundtrips, giving a high latency to work ratio, very many client threads are required to drive a high load on the data nodes. Reducing roundtrips makes it easier to load the cluster, avoiding problems with heavy client thread concurrency. Reducing roundtrips improves individual query response times 4.3 Bn reads/min benchmark uses asynchronous clients
  • 21. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.21 Understand Latency in MySQL Cluster MySQL client MySQL server Data node 1 Data node 2 1 1 2 INSERT INTO t1 VALUES (12, …); INSERT INTO t1 VALUES (13, …); INSERT INTO t1 VALUES (14, …); …
  • 22. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.22 Understand Latency in MySQL Cluster MySQL client MySQL server Data node 1 Data node 2 1 1 2 INSERT INTO t1 VALUES (12, …), (13, …), (14, …), (15, …), (16, …), (17, …); …
  • 23. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.23 Understand Latency in MySQL Cluster MySQL client MySQL server Data node 1 Data node 2 1 3 1 Unpushed SELECT … FROM t1 JOIN t2 JOIN t3 ON t2.key = t1.attr AND t3.key = t2.attr AND t1.key = <const>;
  • 24. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.24 Understand Data Distribution in MySQL Cluster ● Rows are spread around data nodes based on an MD5 hash of (some/all) of their primary key columns. This is pseudo-random. ● Random gives good balance, but defeats locality of access benefits. ● Find (or add) some localising column in your primary key, partition by this, and related data will be stored. ● Benefits : - Reduced data-node round trips for reads (Latency + efficiency) - Fewer 2PC participants for writes (Latency + efficiency) - Scans bounded by the localising column are 'pruned' (Efficiency + scalability) Ordered index scans must be pruned to scale with the number of data nodes
  • 25. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.25 Understand Data Distribution in MySQL Cluster NdbApi client Data node 1 Data node 2 Data node 3 Data node 3 Non pruned scan, all nodes involved, no scaling with # nodes SELECT … FROM t1 WHERE <expression using ordered index without EQ on all t1 partition key columns>
  • 26. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.26 Understand Data Distribution in MySQL Cluster NdbApi client Data node 1 Data node 2 Data node 3 Data node 3 Pruned scan, 2 nodes involved, scales with # nodes SELECT … FROM t1 WHERE part_key1=A AND part_key2=B AND ordered_index_key3 =><=Whatever;
  • 27. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.27 Understand Data Distribution in MySQL Cluster NdbApi client Data node 1 Data node 2 Data node 3 Data node 3 Hinted pruned scan, 1 node involved, scales with # nodes Ordered index scans must be pruned to scale with the number of data nodes SELECT … FROM t1 WHERE part_key1=A AND part_key2=B AND ordered_index_key3 =><=Whatever;
  • 28. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.28 Understand Data Distribution in MySQL Cluster ● MySQL Cluster provides an abstraction of a single database spread across a cluster of machines. You don't need to care about how data is distributed to execute any query. ● But to go fast you must think about data distribution. ● One easy way is to consider how data would be distributed in an equivalent sharded database system – to minimise or remove cross- shard queries, joins, transactions etc. (e.g. shard by user id, by function, by geography, by hierarchy) ● Unlike a sharded database system, MySQL Cluster supports queries which require cross-shard queries or transactions, but if your 'high runner' queries are effectively 'sharded', they will benefit.
  • 29. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.29 Understand Parallelism in MySQL Cluster NdbApi client Data node 1 Data node 2 Data node 3 Data node 3 Batch of primary key reads, executing in parallel Batching gives intra-transaction parallelism Parallelism is good for large queries/transactions
  • 30. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.30 Performance Goals with MySQL Cluster Good Primary key operations Unique key operations Batching Pruned index scans Distribution awareness Pushed conditions Pushed joins Parallelism (for large queries/operations) Bad Round trips Non pruned scans 'High running' Non distribution aware queries Ugly BLOB/TEXT columns Generally require ~1 extra Api round trip per row
  • 31. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.31 Insert Picture Here Making Benchmarks
  • 32. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.32 Making a Benchmark ● Ideally use your application in a known, repeatable, relevant 'traffic' scenario. ● Use existing or add instrumentation to measure how it performs against your goals. ● If goals are not being met, look at how to break out parts of the functionality so that they can be benchmarked and analysed individually – ideally still via your application. ● Benchmark, analyse, improve ● Benchmark with application to check end-to-end gains. ● Making microbenchmarks? Reuse and extend existing tools – mysqlslap, flexAsynch, memslap, etc.
  • 33. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.33 Making a Simple SQL Join Benchmark create.sql: CREATE TABLE sub_name (sub_id INT NOT NULL PRIMARY KEY, name VARCHAR(30)) engine=ndb; CREATE TABLE sub_age (sub_id INT NOT NULL PRIMARY KEY, age INT) engine=ndb; INSERT INTO sub_name VALUES (1,'Bill'),(2,'Fred'),(3,'Bill'), (4,'Jane'),(5,'Andrew'),(6,'Anne'),(7,'Juliette'),(8,'Awen'), (9,'Leo'),(10,'Bill'); INSERT INTO sub_age VALUES (1,40),(2,23),(3,33),(4,19),(5,21), (6,50),(7,31),(8,65),(9,18),(10,101); query.sql: SELECT sub_age.age FROM sub_name, sub_age WHERE sub_name.name='Bill' AND sub_name.sub_id=sub_age.sub_id;
  • 34. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.34 Making a Simple SQL Join Benchmark shell> mysqlslap --concurrency=5 --iterations=100 --query=query.sql --create=create.sql Benchmark Average number of seconds to run all queries: 0.132 seconds Minimum number of seconds to run all queries: 0.037 seconds Maximum number of seconds to run all queries: 0.268 seconds Number of clients running queries: 5 Average number of queries per client: 1
  • 35. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.35 Insert Picture Here Monitoring and Measuring MySQL Cluster
  • 36. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.36 Understand the MySQL Cluster Server stack Ndb storage engine implementation Handler / Storage Engine Api SQL parsing, optimisation, execution Client threads NdbApi Network communication with data nodes MySQL clients MySQL clients MySQL clients Generic MySQL Server code Generic NdbApi code Glue SQL Handler Api calls NdbApi calls MySQL client protocol 'Protocol 6'
  • 37. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.37 MySQL Server Explain Plan mysql> EXPLAIN <query>; mysql> EXPLAIN PARTITIONS <query>; mysql> EXPLAIN EXTENDED <query>; mysql> SHOW WARNINGS; Interpretation of output here is mostly the same as for generic MySQL
  • 38. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.38 MySQL Server Explain Plan In 7.2, EXPLAIN includes information about how a join was (or was not) pushed down to the data nodes : mysql> EXPLAIN SELECT sub_age.age FROM sub_name, sub_age WHERE sub_name.name='Bill' AND sub_name.sub_id=sub_age.sub_id; +----+-------------+----------+--------+---------------+---------+---------+----------------------+------ +--------------------------------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+----------+--------+---------------+---------+---------+----------------------+------ +--------------------------------------------------------------+ | 1 | SIMPLE | sub_name | ALL | PRIMARY | NULL | NULL | NULL | 10 | Parent of 2 pushed join@1; Using where with pushed condition | | 1 | SIMPLE | sub_age | eq_ref | PRIMARY | PRIMARY | 4 | test.sub_name.sub_id | 1 | Child of 'sub_name' in pushed join@1 | +----+-------------+----------+--------+---------------+---------+---------+----------------------+------ +--------------------------------------------------------------+ 2 rows in set (0.00 sec) mysql> Full table scan of sub_name with pushed filter (name='Bill') linked to primary key ops on sub_age
  • 39. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.39 MySQL Server Explain Plan mysql> alter table sub_age change column sub_id sub_id bigint; ... mysql> EXPLAIN EXTENDED SELECT sub_age.age FROM sub_name, sub_age WHERE sub_name.name='Bill' AND sub_name.sub_id=sub_age.sub_id; +----+-------------+----------+--------+---------------+---------+---------+----------------------+------ +----------+------------------------------------------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+----------+--------+---------------+---------+---------+----------------------+------ +----------+------------------------------------------------------------------------+ | 1 | SIMPLE | sub_name | ALL | PRIMARY | NULL | NULL | NULL | 10 | 100.00 | Using where with pushed condition: (`test`.`sub_name`.`name` = 'Bill') | | 1 | SIMPLE | sub_age | eq_ref | PRIMARY | PRIMARY | 8 | test.sub_name.sub_id | 1 | 100.00 | Using where | +----+-------------+----------+--------+---------------+---------+---------+----------------------+------ +----------+------------------------------------------------------------------------+ 2 rows in set, 2 warnings (0.00 sec) mysql> show warnings; ... | Note | 1003 | Can't push table 'sub_age' as child, column 'sub_id' does not have same datatype as ref'ed column 'sub_name.sub_id' | | Note | 1003 | select `test`.`sub_age`.`age` AS `age` from `test`.`sub_name` join `test`.`sub_age` where ((`test`.`sub_name`.`name` = 'Bill') and (`test`.`sub_name`.`sub_id` = `test`.`sub_age`.`sub_id`)) | EXPLAIN EXTENDED gives details of push-failure in warnings
  • 40. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.40 MySQL Server Stack Profiles GLOBAL/LOCAL STATUS variables Session SHOW LOCAL STATUS LIKE 'Com_%'; SQL commands SHOW LOCAL STATUS LIKE 'Handler%'; Handler Api calls SHOW STATUS LIKE 'Ndb_api%session'; Ndb Api calls Server SHOW GLOBAL STATUS LIKE 'Com_%'; SQL commands SHOW GLOBAL STATUS LIKE 'Handler%'; Handler Api calls SHOW STATUS LIKE 'Ndb_api%count'; Ndb Api calls SHOW STATUS LIKE 'Ndb'; Various stats SHOW ENGINE NDB STATUS; Connection level Understand SQL -> Handler -> NdbApi mapping Also available from INFORMATION_SCHEMA for use in SELECTs + Views
  • 41. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.41 MySQL Server NdbApi Call Profile mysql> show status like 'ndb_api%session'; +----------------------------------------------+------------+ | Variable_name | Value | +----------------------------------------------+------------+ | Ndb_api_wait_exec_complete_count_session | 12 | | Ndb_api_wait_scan_result_count_session | 9 | | Ndb_api_wait_meta_request_count_session | 24 | | Ndb_api_wait_nanos_count_session | 1086595954 | | Ndb_api_bytes_sent_count_session | 8504 | | Ndb_api_bytes_received_count_session | 12032 | | Ndb_api_trans_start_count_session | 6 | | Ndb_api_trans_commit_count_session | 4 | | Ndb_api_trans_abort_count_session | 1 | | Ndb_api_trans_close_count_session | 6 | | Ndb_api_pk_op_count_session | 11 | | Ndb_api_uk_op_count_session | 0 | | Ndb_api_table_scan_count_session | 2 | ... +----------------------------------------------+------------+ 21 rows in set (0.00 sec) mysql>  Network roundtrips Api Data transfer NdbApi api call profile Details : http://messagepassing.blogspot.com/ 2011/04/journey-upriver-to-dark-heart-of.html + MySQL Cluster Reference Manual Also available from NdbApi!
  • 42. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.42 NdbInfo Schema ● NdbInfo tables are 'pseudo tables' generated on demand by data nodes. ● Contain information about resource usage levels, dynamic counts, user operation and transaction states etc. ● Generally cluster-wide ● Much more information will be added to NdbInfo tables over time. mysql> show tables; +----------------------+ | Tables_in_ndbinfo | +----------------------+ | blocks | | cluster_operations | | cluster_transactions | | config_params | | counters | | diskpagebuffer | | logbuffers | | logspaces | | memoryusage | | nodes | | resources | | server_operations | | server_transactions | | threadblocks | | threadstat | | transporters | +----------------------+ 16 rows in set (0.00 sec) mysql>
  • 43. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.43 NdbInfo Counters Table Schema mysql> select block_name, counter_name from ndbinfo.counters group by block_name, counter_name; +------------+-----------------------------------+ | block_name | counter_name | +------------+-----------------------------------+ | DBLQH | OPERATIONS | | DBSPJ | CONST_PRUNED_RANGE_SCANS_RECEIVED | | DBSPJ | LOCAL_RANGE_SCANS_SENT | | DBSPJ | LOCAL_READS_SENT | | DBSPJ | LOCAL_TABLE_SCANS_SENT | | DBSPJ | PRUNED_RANGE_SCANS_RECEIVED | | DBSPJ | RANGE_SCANS_RECEIVED | | DBSPJ | READS_NOT_FOUND | | DBSPJ | READS_RECEIVED | | DBSPJ | REMOTE_RANGE_SCANS_SENT | | DBSPJ | REMOTE_READS_SENT | | DBSPJ | SCAN_BATCHES_RETURNED | | DBSPJ | SCAN_ROWS_RETURNED | | DBSPJ | TABLE_SCANS_RECEIVED | ... … | | DBTC | ABORTS | | DBTC | ATTRINFO | | DBTC | COMMITS | | DBTC | LOCAL_READS | | DBTC | LOCAL_WRITES | | DBTC | RANGE_SCANS | | DBTC | READS | | DBTC | SIMPLE_READS | | DBTC | TABLE_SCANS | | DBTC | TRANSACTIONS | | DBTC | WRITES | +------------+-----------------------------------+ 25 rows in set (0.01 sec) mysql> Information about how the data nodes are executing your transactions
  • 44. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.44 Use OS-level Tools to Understand Performance top IOSTAT VMSTAT mpstat strace perf dtrace oprofile netstat Ifconfig PMP
  • 45. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.45 MySQL Server Profiling in Production Enable the slow query log set global slow_query_log=1; set global long_query_time=3; //3 seconds set global log_queries_not_using_indexes=1; Slow queries will be written in the slow query log: mysql> show global variables like 'slow_query_log_file'; +---------------------+------------------------------+ | Variable_name | Value | +---------------------+------------------------------+ | slow_query_log_file | /data1/mysql/mysqld-slow.log | +---------------------+------------------------------+ Queries will be written in plain text
  • 46. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.46 Query Analyzer?
  • 47. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.47 Insert Picture Here Boosting Performance
  • 48. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.48 Using AQL to Perform Efficient Joins (7.2 only) Activated when ndb_join_pushdown is on (default) Rules for a Join to be pushed down: - Joined columns use identical types - No reference to BLOB or TEXT columns - No explicit locking - Child tables in the Join must be accessed using one of the ref, eq_ref, or const - Tables not explicitly partitioned by [LINEAR] HASH, LIST, or RANGE - Query plan doesn’t select ‘Using join buffer' - If root of Join is an eq_ref or const, child tables must be joined by eq_ref Run ANALYZE TABLE <tab-name> on each table once Use EXPLAIN to see what components are being pushed down: Extra: Child of 'd' in pushed join@1 EXPLAIN EXTENDED <query>;SHOW WARNINGS;. Joins are far more time efficient than before, but can still be resource heavy.
  • 49. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.49 Batching Within a Transaction Batching amortises the round-trip latency across multiple operations and/or results. Primary and unique key operations can be sent in batches, which will be executed concurrently + in parallel if on different nodes/fragments. Ordered index and table scans send their results in batches, allowing buffer space to be traded for round trips. Example – Insert 1M records No batching: INSERT INTO t1(data) VALUES (<data>); 765 seconds to insert 1M records Batching (batches of 16): INSERT INTO t1(<columns>) VALUES (<data>), (<data>)... 50 seconds to insert 1M records Time ratio here is 15.3:1 – almost the same as the batching factor. Most of the response time is request/response latency.
  • 50. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.50 Batching Within a Transaction SELECT * FROM t1 WHERE userid=1 AND serviceid IN (1,2,3,4,5,7,8,9,10); SET transaction_allow_batching=1; //must be set on the connection BEGIN; INSERT INTO t1 ....; INSERT INTO t2 ....; INSERT INTO t3 ....; INSERT INTO t4 ....; DELETE FROM t5 ....; UPDATE t1 SET value='new value' WHERE id=1; COMMIT; Verify the effect of these statements using the SHOW STATUS LIKE 'ndb_api_wait%session' counters. Errors associated with a statement may be reported against a later statement in the transaction.
  • 51. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.51 Distribution Awareness Select a partitioning key for your schema which maximises the locality of your high-running queries (Subscriber id, Session id, Product id, Order id, Tree root nodes) Doesn't matter if low-running queries have no locality. Consider adding extra key columns to your tables to enable this, using a secondary unique index to enforce uniqueness on the original PK if necessary. Change DDL to use partitioning key : CREATE TABLE t1 … ENGINE=NDB PARTITION BY KEY <My key(s)>; In 'high running' transactions, perform first query using EQ on partitioning key column(s) to give placement hint to MySQL Server. Consider splitting your transactions if the partitioning key value is not known at the start of a high running transaction. Do you need transactional semantics? Specified per-table, used across tables Monitor distribution awareness and pruning using SHOW STATUS and NdbInfo
  • 52. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.52 Simplify Transactions Simpler transactions (fewer tables, fewer rows, primary key access) are much simpler for the system to run fast. Schema denormalisation can remove the need for some joins. Some applications have data which need not be disk-persistent (WAL redo logged and checkpointed). By removing their disk-persistence, they can sustain high write rates without pressuring disk IO. After a system recovery, the table will be empty. mysql> set ndb_table_no_logging=1; mysql> create table session_table(..) engine=ndb; mysql> set ndb_table_no_logging=0;
  • 53. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.53 Multithreaded Data Nodes MySQL Cluster data nodes use many threads for disk and network IO, and database request processing. Request processing threads use a shared-nothing, non-blocking message passing model with very little inter-thread locking. Multithreading in Ndb is to enable use of multiple HW cores, therefore, roughly one request processing thread per HW core is used as a guideline when configuring. The threads are asymmetric – work is partitioned among them functionally. This means that the balance of thread types and counts depends on the workload to be handled. If in doubt, use the default configuration for your HW core count.
  • 54. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.54 Multithreaded Data Nodes Replication thread Main thread LDM threads TC threads Send threads Request processing threads TC and LDM threads do most work, must be well fed by Send + Receive threads Receive threads IO threads Connect threads Watchdog
  • 55. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.55 Hardware for Performance High bandwidth, low latency network - Infiniband is nice Multiple disks if disk IO is a problem - Split checkpoints from Redo logs from DD Tablespaces Consider SSDs - Best for DD Tablespaces as logs and Checkpoints are mostly serialised writes Refer to MySQL Cluster Evaluation Guide for more advice MySQL Cluster runs great on low end hardware, especially where applications, schemas and queries are tuned for it.
  • 56. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.56 Choice of Api Lower level Apis can give more control, as well as removing latency and complexity. However, they may require development to integrate with your systems. For the best performance, use C++ NdbApi, or the ClusterJ Java Api. NdbApi gives greater control, at the cost of greater complexity. The memcached or HTTP/REST Apis also expose good performance through a simplified Api. Native memcached HTTP/REST JDBC / ODBC PHP / PERL Python / Ruby
  • 57. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.57 Breakthrough Performance? 1. Understand the system and its bottlenecks MySQL manual, blogs, whitepapers, forum, mailing list, Experimentation 2. Set goals 3. while (!goal.met()) {Benchmark, Monitor, Measure, Optimise}
  • 58. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1258
  • 59. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.59 Connection Pooling and the Query Cache Connection pooling here refers to having more than one logical connection from a MySQL Server to the Ndb data nodes. (Each logical connection has many internal socket connections). This can be used to avoid bottlenecks due to per-logical connection locking. Consumes [API] slots. The MySQL Query cache caches query results. However it is asynchronously invalidated by Ndb as the cached tables are changed in the cluster. With a high change rate, the rate of query cache invalidations can become excessive. Should only really be considered for very static tables, where applications can tolerate some staleness.