mysql & nosql: the best of both...
TRANSCRIPT
![Page 1: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/1.jpg)
1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
MySQL & NoSQL: The Best of Both Worlds Mark Swarbrick Principal System Consultant MySQL [email protected]
![Page 2: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/2.jpg)
2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Safe Harbour 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.
![Page 3: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/3.jpg)
3 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
History of MySQL I
! 2001 MySQL 3.23 GA – our first GA release ever!
! 2005 Oracle Corporation acquired Innobase OY
! 2008 Sun acquired MySQL AB for $1 billion
! 2010 Oracle acquired Sun on 27 January
! 2010 MySQL 5.5 first Oracle release, great feedback from community!
! 2012 MySQL 5.6 “Best release ever“
![Page 4: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/4.jpg)
4 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
History of MySQL II
! World’s Most Popular Open Source Database
! Over 12 million product installations
! 65,000 downloads/day
! The ”M” of the widely deployed LAMP stack
! MySQL Commercial Editions Available
![Page 5: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/5.jpg)
5 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
World wide use
![Page 6: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/6.jpg)
6 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
World wide use “at night”
![Page 7: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/7.jpg)
7 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Session Agenda
• NoSQL – What are people looking for? • RDBMS – What advantages do they still have? • How MySQL Delivers the Best of Both Worlds
– MySQL Cluster • NoSQL attributes: Scale-out, performance, ease-of-use, schema
flexibility, on-line operations • NoSQL APIs
– Key-Value store access to InnoDB (Memcached)
• What is coming with future releases
![Page 8: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/8.jpg)
8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
What NoSQL must deliver
• Massive scalability – No application-level sharding
• Performance • High Availability/Fault Tolerance • Ease of use
– Simple operations/administration – Simple APIs – Quickly evolve application & schema
Scalability)
Performance)
HA)
Ease)of)use)
![Page 9: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/9.jpg)
9 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Still a role for the RDBMS?
NoSQL&
Simple&access&pa/erns&
Compromise&on&consistency&for&performance&
Ad8hoc&data&format&
Simple&opera:on&
RDBMS&
Complex&queries&with&joins&
ACID&transac:ons&
Well&defined&schemas&
Rich&set&of&tools&
• No best single solution fits all • Mix and match
Scalability)
Performance)
HA)
Ease)of)use)
SQL/Joins)
ACID)Transac>ons)
![Page 10: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/10.jpg)
10 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
MySQL Cluster introduction
![Page 11: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/11.jpg)
11 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
MySQL Cluster Architecture
Data Nodes
Node Group 1
F1
F3
F3
F1
Nod
e 1
Nod
e 2
Node Group 2
F2
F4
F4
F2 N
ode
3 N
ode
4
Application Nodes
Cluster Mgr
Cluster Mgr
REST Scalability)
Performance)
HA)
Ease)of)use)
SQL/Joins) "
ACID)Transac>ons) "
![Page 12: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/12.jpg)
12 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Copyright 2013, Oracle and/or its affiliates. All rights reserved.
MySQL Cluster: Extensive Choice of NoSQL APIs
Mix &
Match
![Page 13: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/13.jpg)
13 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
C++ example
NdbOperation *op = trx->getNdbOperation(myTable); op->insertTuple(); op->equal("key", i); op->setValue("value", &value); trx->execute( NdbTransaction::Commit );
![Page 14: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/14.jpg)
14 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Copyright 2013, Oracle and/or its affiliates. All rights reserved.
• NoSQL C++ API, flexaSynch benchmark • 30 x Intel E5-2600 Intel Servers, 2 socket, 64GB • ACID Transactions, with Synchronous Replication
0
5
10
15
20
25
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30
Mill
ions
of U
PDAT
Es p
er
Seco
nd
MySQL Cluster Data Nodes
1.2 Billion UPDATEs per Minute
![Page 15: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/15.jpg)
15 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
MySQL Cluster Architecture
Data Nodes
Node Group 1
F1
F3
F3
F1
Nod
e 1
Nod
e 2
Node Group 2
F2
F4
F4
F2 N
ode
3 N
ode
4
Application Nodes
Cluster Mgr
Cluster Mgr
REST Scalability)
Performance)
HA) "
Ease)of)use)
SQL/Joins) "
ACID)Transac>ons) "
http://clusterdb.com/u/demo
![Page 16: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/16.jpg)
16 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Data Node 1
Data Node 2
Data Node 3
Data Node 4
Table T1
P2 P3 P4
P1
Scale-Out: Auto-Partitioning
![Page 17: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/17.jpg)
17 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Data Node 1
Data Node 2
F1
Data Node 3
Data Node 4
Table T1
P2 P3 P4
P1
Scale-Out: Auto-Partitioning
![Page 18: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/18.jpg)
18 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Data Node 1
Data Node 2
F1
F1
Data Node 3
Data Node 4
Table T1
P2 P3 P4
P1
Scale-Out: Auto-Partitioning
![Page 19: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/19.jpg)
19 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Data Node 1
Data Node 2
F1
F3 F1
Data Node 3
Data Node 4
Table T1
P2 P3 P4
P1
Scale-Out: Auto-Partitioning
![Page 20: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/20.jpg)
20 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Data Node 1
Data Node 2
F1 F3
F3 F1
Data Node 3
Data Node 4
Table T1
P2 P3 P4
P1
Scale-Out: Auto-Partitioning
![Page 21: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/21.jpg)
21 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Data Node 1
Data Node 2
F1 F3
F3 F1
Data Node 3
Data Node 4
F2 F4
F4 F2
Node Group 1
Node Group 2
Table T1
P2 P3 P4
P1
Scale-Out: Auto-Partitioning
![Page 22: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/22.jpg)
22 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Data Node 1
Data Node 2
F1 F3
F3 F1
Data Node 3
Data Node 4
F2 F4
F4 F2
Node Group 1
Node Group 2
Table T1
P2 P3 P4
P1
Scale-Out: Auto-Partitioning
![Page 23: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/23.jpg)
23 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Table T1
P2 P3 P4
P1
Scale-Out: Auto-Partitioning
Scalability) "
Performance)
HA) "
Ease)of)use)
SQL/Joins) "
ACID)Transac>ons) "
![Page 24: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/24.jpg)
24 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Scale-Out Reads & Writes on Commodity Hardware
• 8 x Commodity Intel Servers – 2 x 6-core processors 2.93GHz – x5670 processors (24 threads) – 48GB RAM
• Infiniband networking • flexAsynch benchmark (NDB API)
0
200
400
600
800
1,000
1,200
2 4 8
Mill
ions
Number of Data Nodes
SELECT Queries per Minute
0
50
100
150
4 8
Mill
ions
Number of Data Nodes
UPDATE Queries per Minute
![Page 25: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/25.jpg)
25 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Scalability) "
Performance) "
HA) "
Ease)of)use)
SQL/Joins) "
ACID)Transac>ons) "
![Page 26: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/26.jpg)
26 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
On-line Schema changes
• 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
On-Line Operations
![Page 27: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/27.jpg)
27 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
! Foreign Key Support ! Connection Thread Scalability ! MySQL 5.6
! Auto-Installer ! NoSQL JavaScript for
node.js
![Page 28: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/28.jpg)
28 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
MySQL Cluster 7.3: Auto-Installer
• Fast configuration • Auto-discovery • Workload optimized • Repeatable best
practices • For MySQL Cluster
7.2 + 7.3
Specify Workload
Auto-Discover
Define Topology Deploy
![Page 29: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/29.jpg)
29 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Scalability) "
Performance) "
HA) "
Ease)of)use) "
SQL/Joins) "
ACID)Transac>ons) "
![Page 30: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/30.jpg)
30 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
NoSQL Access to MySQL Cluster data
Mix & Match! Same data accessed
simultaneously through SQL & NoSQL interfaces
![Page 31: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/31.jpg)
31 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
MySQL Cluster 7.1: ClusterJ/JPA
• New Domain Object Model Persistence API (ClusterJ) : – Java API – High performance, low latency – Feature rich
• JPA interface built upon this new Java layer: – Java Persistence API compliant
• Implemented as an OpenJPA plugin
– Uses ClusterJ where possible, reverts to JDBC for some operations
– Higher performance than JDBC – More natural for most Java designers – Easier Cluster adoption for web applications
![Page 32: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/32.jpg)
32 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Java Access Performance
http://www.mysql.com/why-mysql/white-papers/mysql_wp_cluster_connector_for_java.php
![Page 33: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/33.jpg)
33 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
NoSQL with Memcached (MySQL Cluster 7.2)
• Memcached is a distributed memory based hash-key/value store with no persistence to disk
• NoSQL, simple API, popular with developers • MySQL Cluster already provides scalable, in-memory
performance with NoSQL (hashed) access as well as persistence – Provide the Memcached API but map to NDB API calls
• Writes-in-place, so no need to invalidate cache • Simplifies architecture as caching & database integrated
into 1 tier • Access data from existing relational tables
![Page 34: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/34.jpg)
34 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Traditional Memcached Architecture
• Two levels of hashing
Memcache
httpd memcached
memcached
memcached memcache key
PHP/Perl
friends:12389!
hash key to find data
hash key to pick server
![Page 35: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/35.jpg)
35 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Cache hit
Memcache
httpd
memcached PHP/Perl
friends:12389!
hash key to find data
VALUE friends:12389 0 31\r\n!101, 11009, 11150, 55881, 77798 \r\n!
hash key to pick server
![Page 36: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/36.jpg)
36 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Cache miss (1): fetch from DB
Memcache
httpd
memcache PHP/Perl hash key to find data
hash key to pick server
NOT FOUND
mysql
MySQL Slave
SELECT friend_id !FROM user_friends !WHERE user_id = ?!
memcached
![Page 37: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/37.jpg)
37 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Cache miss (2): manage cache
Memcache
httpd
PHP/Perl hash key to find data
set friends:12389 31\r\n!
101, 11009, 11150, 55881, 77798 \r\n!
memcached
![Page 38: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/38.jpg)
38 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Data change (1): Write to DB
mysql
httpd
PHP/Perl
MySQL Master
DELETE FROM user_friends ! VALUES (12389, 999101);!
![Page 39: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/39.jpg)
39 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Data change (2): manage cache
mysql
httpd
PHP/Perl
MySQL Master
delete friends:12389 \r\n!
memcached
![Page 40: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/40.jpg)
40 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
NoSQL with Memcached
• Flexible: – Deployment options – Multiple Clusters – Simultaneous SQL Access – Can still cache in Memcached server – Flat key-value store or map to multiple tables/
columns
set maidenhead 0 0 3 SL6 STORED get maidenhead VALUE maidenhead 0 3 SL6 END
![Page 41: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/41.jpg)
41 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Cluster & Memcached – Schema-Free
<town:maidenhead,SL6>
key value
<town:maidenhead,SL6>
key value
Key) Value)
town:maidenhead& SL6&
generic table
Application view
SQL view
![Page 42: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/42.jpg)
42 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Cluster & Memcached - Configured Schema
<town:maidenhead,SL6>
prefix key value
<town:maidenhead,SL6>
key value
Prefix) Table) KeyCcol) ValCcol) policy)
town:& map.zip& town& code& cluster&
pop:& map.zip& town& popul& cluster&
Config tables
town) ...) code) popul)
maidenhead& ...& SL6& ...&
map.zip
Application view
SQL view
![Page 43: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/43.jpg)
43 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Memcached with MySQL Cluster
http://clusterdb.com/u/memcached
Try it out
![Page 44: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/44.jpg)
44 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Memcached NoSQL Access with InnoDB • Memcached as a plugin of MySQL Server;
same process space, with very low latency access to data
• Memcapable: supports both memcached ascii protocol and binary protocol
• Support multiple columns: users can map multiple columns into “value”
• Optional local caching: “innodb-only”, “cache-only”, and “caching”
• Batch operations for performance
• Available from in MySQL 5.6
InnoDB Storage Engine
Handler API
MySQL Server
InnoDB API
memcached plugin
Application
SQL Memcached protocol
mysqld
innodb_memcache local cache (optional)
![Page 45: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/45.jpg)
45 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Performance
Copyright 2013, Oracle and/or its affiliates. All rights reserved.
Up to 9x Higher “SET / INSERT” Throughput
0
10000
20000
30000
40000
50000
60000
70000
80000
8 32 128 512
TPS
Client Connections
MySQL 5.6: NoSQL Benchmarking
Memcached API
SQL
16 GB, Intel Xeon 2.0 GHz CPU X86_64 2 CPUs- 4 Core Each, 2 RAID DISKS
![Page 46: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/46.jpg)
46 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
InnoDB & Memcached - Configured Schema
<town:maidenhead,SL6:12000>
prefix key value
<@@town:maidenhead,SL6:12000>
key value
name) schema) table) keycol) valcols) flags)
town& map& city& town& code,popul&
country& world& state& code& name,capital&
Config tables
town) ...) code) popul)
maidenhead& ...& SL6& 12000&
map.city
Application view
SQL view
![Page 47: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/47.jpg)
47 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Which API to use?
![Page 48: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/48.jpg)
48 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Scalability) "
Performance) "
HA) "
Ease)of)use) "
SQL/Joins) "
ACID)Transac>ons) "
![Page 49: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/49.jpg)
49 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
MySQL Cluster 7.3: Node.js NoSQL API • Native JavaScript access to MySQL Cluster
– End-to-End JavaScript: browser to the app and database
– Storing and retrieving JavaScript objects directly in MySQL Cluster
– Eliminate SQL transformation
• Implemented as a module for node.js – Integrates full Cluster API library within the web
app • Couple high performance, distributed apps, with
high performance distributed database
V8 JavaScript Engine
MySQL Cluster Node.js Module
MySQL Cluster Data Nodes
Clients
![Page 50: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/50.jpg)
50 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
What does an asynchronous API mean?
do_stuff1(data, callback1)
callback1(results) do_stuff2(data, callback2)
callback2(results)
Get on with other stuff Get on with other stuff
![Page 51: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/51.jpg)
51 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
MySQL Cluster NoSQL API for Node.js
var nosql = require('mysql-js'); var annotations = new nosql.Annotations(); annotations.mapClass(lib.Tweet, {'table' : 'tweet'}); var dbProperties = nosql.ConnectionProperties('ndb'); nosql.openSession(dbProperties, annotations, onSession);
• Modular connector with various back-end adapters:
• ndb: low-level native access to MySQL Cluster
• mysql: access to any MySQL server (translates operations to SQL statements)
![Page 52: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/52.jpg)
52 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
MySQL Cluster NoSQL API for Node.js
var onSession = function(err, session) { if (err) {…} else { var data = new
lib.Tweet(user_args[0], user_args[1]);
session.persist(data, onInsert, data);
} };
![Page 53: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/53.jpg)
53 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
MySQL Cluster NoSQL API for Node.js
var onInsert = function(err, object) { console.log('onInsert.'); if (err) {…} else { console.log('Inserted: ' +
JSON.stringify(object)); } };
![Page 54: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/54.jpg)
54 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Try Node.js example for yourself • https://github.com/mysql/mysql-js/tree/master/samples
![Page 55: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/55.jpg)
55 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Who’s Using MySQL Cluster?
![Page 56: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/56.jpg)
56 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Summary
Today’s web workloads demand more from databases
Performance, scale-out, simples access patterns & APIs
MySQL meets these needs while still delivering benefits of an ACID RDBMS
![Page 57: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/57.jpg)
57 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Next Steps • Guide to MySQL and NoSQL - Delivering the Best of
Both Worlds – http://mysql.com/why-mysql/white-papers/mysql-wp-guide-to-
nosql.php
• Evaluate MySQL Cluster 7.3 – http://www.mysql.com/downloads/cluster/
• Bootstrap a Cluster – https://edelivery.oracle.com/
• Try Memcached API for InnoDB in 5.6 • http://www.mysql.com/downloads/
![Page 58: MySQL & NoSQL: The Best of Both Worldsnosqlroadshow.com/dl/NoSQL-London-2013/Slides/Mark_Swarbrick.… · NoSQL with Memcached (MySQL Cluster 7.2) • Memcached is a distributed memory](https://reader034.vdocuments.mx/reader034/viewer/2022042911/5f424e7093ee7079b337e81b/html5/thumbnails/58.jpg)
58 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Thank you!
Copyright 2012, Oracle and/or its affiliates. All rights reserved.