Upload
andrew-morgan
View
2.064
Download
0
Embed Size (px)
DESCRIPTION
Theres a lot of excitement around NoSQL Data Stores with the promise of simple access patterns, flexible schemas, scalability and High Availability. The downside comes in the form of losing ACID transactions, consistency, flexible queries and data integrity checks. What if you could have the best of both worlds? This session shows how MySQL Cluster provides simultaneous SQL and native NoSQL access to your data whether a simple key-value API (Memcached), REST, JavaScript, Java or C++. You will hear how the MySQL Cluster architecture delivers in-memory real-time performance, 99.999% availability, on-line maintenance and linear, horizontal scalability through transparent auto-sharding.
Citation preview
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
NoSQL and SQL: The Best of Both Worlds
Andrew Morgan @andrewmorgan clusterdb.com 18th November 2014
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement The following is intended to outline our general product direcPon. It is intended for informaPon purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or funcPonality, and should not be relied upon in making purchasing decisions. The development, release, and Pming of any features or funcPonality described for Oracle’s products remains at the sole discrePon of Oracle.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Session Agenda • NoSQL – What are people looking for? • RDBMS – What advantages do they sPll have? • How MySQL Delivers the Best of Both Worlds
– MySQL Cluster • NoSQL aXributes: Scale-‐out, performance, ease-‐of-‐use, schema flexibility, on-‐line operaPons • NoSQL APIs
– Key-‐Value store access to InnoDB (Memcached)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Types of NoSQL stores
Key-‐Value
• Cassandra • Memcached • BigTable • Hadoop • Voldermort
Document
• MongoDB • CouchDB
Graph
• Neo4J • FlockDB
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Key-‐Value Store
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Graph Database
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
• Massive scalability – No applicaPon-‐level sharding
• Performance • High Availability/Fault Tolerance • Ease of use
– Simple operaPons/administraPon – Simple APIs – Quickly evolve applicaPon & schema
Scalability
Performance
HA
Ease of use
What NoSQL must deliver
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
NoSQL
Simple access paXerns
Compromise on consistency for performance
Ad-‐hoc data format
Simple operaPon
SQL
Complex queries with joins
ACID transacPons
Well defined schemas
Rich set of tools
• No best single soluPon fits all • Mix and match
SPll a role for SQL (RDBMS)?
Scalability
Performance
HA
Ease of use
SQL/Joins
ACID Transac>ons
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
The TemptaPon to Jejson RelaPonal Model
• RelaPonal Model: – Data stored in mulPple tables – Many lookups to retrieve a user’s Pmeline
– Is it worth the effort in sejng up this complex data model?
• Simpler just to store as one document?
The allure of document stores
Examples borrowed from @sarahmei hXps://speakerdeck.com/sarahmei/switching-‐data-‐stores-‐a-‐postmodern-‐comedy
user
friend
post
comment
like
liker
commenter
many
many
many
one
one
many
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
The TemptaPon to Jejson RelaPonal Model
• Document Model: – EnPre Pmeline in a single document (row)
– Single lookup to retrieve the user’s Pmeline
– Brilliantly efficient model when the document truly contains self-‐contained informaPon
• Like a real-‐world document!
The allure of document stores {name: ‘Joe’, url: ‘http://clusterdb.com’, stream:[ {friend:{ name: ‘Jane’, posts:[{content: ‘…’, comments:[ {comment: ‘…’, commenter: ‘Joe’}, {…} ], likes: [‘Joe’, ‘Fred’, ‘Billy’] }, {…},{…},… ] }, {…},{…},…}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
The TemptaPon to Jejson RelaPonal Model
• These are all people who have their own data that users will want to view or click through: – Name – url – Timeline
• Easy to represent with FKs in a relaPonal model
But when the data isn’t self contained…
user
friend
post
comment
like
liker
commenter
many
many
many
one
one
many
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
The TemptaPon to Jejson RelaPonal Model
• Do I store all data for all friends and likers again at every point they appear in the document?
• Massive amount of repeated data – Wasted space – Needs to be kept in sync (and you don’t have transacPons to provide consistency)
The allure of document stores {name: ‘Joe’, url: ‘http://clusterdb.com’, stream:[ {friend:{ name: ‘Jane’, posts:[{content: ‘…’, comments:[ {comment: ‘…’, commenter: ‘Joe’}, {…} ], likes: [‘Joe’, ‘Fred’, ‘Billy’] }, {…},{…},… ] }, {…},{…},…}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
The TemptaPon to Jejson RelaPonal Model
• The reality is that the developer will store the user-‐ids instead
• Developer is responsible for implemenPng ‘joins’ in the applicaPon – e.g. scanning all Pmelines for where a user made a comment or liked a post
• No transacPons to ensure consistency between documents
The allure of document stores {name: 83746251, url: ‘…’ stream:[ {friend:{ name: 9384726153, posts:[{content: ‘…’, comments:[ {comment: ‘…’, commenter: 83746251}, {…} ], likes: [83746251, 750730283, 2938493820] }, {…},{…},… ] }, {…},{…},…}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
The TemptaPon to Jejson RelaPonal Model
• Each aXribute’s labels are stored in every document – More wasted space – Developers compensate by replacing with short names
The allure of document stores {n5: 83746251, u2: ‘…’ s1:[ {f2:{ n5: 9384726153, p4:[{c4: ‘…’, c3:[ {c2: ‘…’, c8: 83746251}, {…} ], l5: [83746251, 750730283, 2938493820] }, {…},{…},… ] }, {…},{…},…}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
MySQL Cluster Overview • Auto-‐Sharding, MulP-‐Master • ACID Compliant, OLTP + Real-‐Time AnalyPcs
HIGH SCALE, READS + WRITES
• Shared nothing, no Single Point of Failure • Self Healing + On-‐Line OperaPons 99.999% AVAILABILITY
• In-‐Memory OpPmizaPon + Disk-‐Data • Predictable Low-‐Latency, Bounded Access Time REAL-‐TIME
• Key/Value + Complex, RelaPonal Queries • SQL + Memcached + JavaScript + Java + HTTP/REST & C++ SQL + NoSQL
• Open Source + Commercial EdiPons • Commodity hardware + Management, Monitoring Tools LOW TCO
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Who’s Using MySQL Cluster?
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
MySQL Cluster Architecture
MySQL Cluster Data Nodes
Clients
ApplicaPon Layer
Data Layer
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
MySQL Cluster Scaling
MySQL Cluster Data Nodes
Clients
ApplicaPon Layer
Data Layer
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
MySQL Cluster HA
MySQL Cluster Data Nodes
Clients
ApplicaPon Layer
Data Layer
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
On-‐line OperaPons • Scale the cluster (add & remove nodes on-‐line) • ReparPPon tables • Upgrade / patch servers & OS • Upgrade / patch MySQL Cluster • Back-‐Up • Evolve the schema on-‐line, in real-‐Pme
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
1.2 Billion UPDATEs per Minute
• NoSQL C++ API, flexaSynch benchmark
• 30 x Intel E5-‐2600 Intel Servers, 2 socket, 64GB
• ACID TransacPons, with Synchronous ReplicaPon
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 S
econ
d
MySQL Cluster Data Nodes
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Join Performance
• Web-‐Based Content Management System – JOINs 11-‐tables, 33.5k rows – Returns 2k rows, 19 columns per row
0
10
20
30
40
50
60
70
80
90
100
MySQL Cluster 7.1 MySQL Cluster 7.2
Query Execution Time Seconds
87.23 seconds
1.26 seconds
70x Faster
Scalability !"
Performance !"
HA !"
Ease of use
SQL/Joins !"
ACID Transac>ons !"
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Better performance and operational simplicity MySQL Cluster 7.4.1 DMR
• Performance gain over 7.3 – 47% (Read-‐Only) – 38% (Read-‐Write)
0"
1000"
2000"
3000"
4000"
5000"
6000"
7000"
8000"
9000"
10000"
64" 128" 256" 512"
Tran
sac'on
)per)se
cond
)
Threads)
Sysbench)RO)
7.4.0"
7.3.5"
7.2.16"
0"
1000"
2000"
3000"
4000"
5000"
6000"
7000"
8000"
9000"
64" 128" 256" 512"
Tran
sac'on
s)per)se
cond
)
Threads)
Sysbench)R/W)
7.4.0"
7.3.5"
7.2.16"
• Faster node restarts
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
CreaPng & running your first Cluster
Download & Extract • edelivery.oracle.com • www.mysql.com • dev.mysql.com
Configure • Cluster-‐wide “config.ini”
• Per-‐mysqld “my.cnf”
Start processes • Management Nodes • Data Nodes • MySQL Servers
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Scalability !"
Performance !"
HA !"
Ease of use !"
SQL/Joins !"
ACID Transac>ons !"
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
MySQL Cluster Auto-‐Installer
• Fast configuraPon • Auto-‐discovery • Workload opPmized • Repeatable best pracPces
Specify Workload
Auto-‐Discover
Define Topology Deploy
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
MySQL Cluster Manager 1. Download MCM/Cluster package from edelivery.oracle.com: 2. Unzip 3. Run agent, define, create & start Cluster! $> bin\mcmd --bootstrap MySQL Cluster Manager 1.1.2 started
Connect to MySQL Cluster Manager by running "D:\Andrew\Documents\MySQL\mcm\bin\mcm" -a NOVA:1862
Configuring default cluster 'mycluster'...
Starting default cluster 'mycluster'...
Cluster 'mycluster' started successfully
ndb_mgmd NOVA:1186
ndbd NOVA
ndbd NOVA
mysqld NOVA:3306
mysqld NOVA:3307
ndbapi *
Connect to the database by running "D:\Andrew\Documents\MySQL\mcm\cluster\bin\mysql" -h NOVA -P 3306 -u root
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
MCM: Upgrade Cluster
mysql> upgrade cluster --package=7.3 mycluster;
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Scalability !"
Performance !"
HA !"
Ease of use !"
SQL/Joins !"
ACID Transac>ons !"
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
NoSQL Access to MySQL Cluster data
Apps Apps Apps Apps Apps Apps Apps Apps Apps Apps Apps Apps
JPA
Cluster JPA
PHP Perl Python Ruby JDBC Cluster J JS Apache Memcached
MySQL JNI Node.JS mod_ndb ndb_eng
NDB API (C++)
MySQL Cluster Data Nodes
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Schema-‐Free apps
• Rapid applicaPon evoluPon – New types of data constantly added
– No Pme to get schema extended – Missing skills to extend schema – IniPally roll out to just a few users – Constantly adding to live system
Copyright © 2014, 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
ApplicaPon view
SQL view
Copyright © 2014, 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 Key-‐col Val-‐col policy
town: map.zip town code cluster
Config tables
town ... code ...
maidenhead ... SL6 ...
map.zip
ApplicaPon view
SQL view
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
MySQL 5.6 Memcached with InnoDB
0
10000
20000
30000
40000
50000
60000
70000
80000
8 32 128 512
TPS
Client Connections
Memcached API
SQL
Clients and Applica>ons
MySQL Server Memcached Plug-‐in
innodb_ memcached
local cache (opPonal)
Handler API InnoDB API
InnoDB Storage Engine
mysqld process
SQL Memcached Protocol
Up to 9x Higher “SET / INSERT” Throughput
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Node.js NoSQL API • NaPve JavaScript access to MySQL Cluster – End-‐to-‐End JavaScript: browser to the app & DB
– Storing and retrieving JavaScript objects directly in MySQL Cluster
– Eliminate SQL transformaPon
• Implemented as a module for node.js – Integrates Cluster API library within the web app
• Couple high performance, distributed apps, with high performance distributed database
• OpPonally routes through MySQL Server – Use with InnoDB
V8 JavaScript Engine
MySQL Cluster Node.js Module
MySQL Cluster Data Nodes
Clients
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
NoSQL API for Node.js & FKs
FKs enforced on all APIs: { message: 'Error', sqlstate: '23000', ndb_error: null, cause: {message: 'Foreign key constraint violated: No parent row found [255]', sqlstate: '23000', ndb_error: { message: 'Foreign key constraint violated: No parent row found', code: 255, classification: 'ConstraintViolation', handler_error_code: 151, status: 'PermanentError' }, cause: null } }
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Oracle University MySQL Training Services Prepare Your Organization to Enable Reliable and High-Performance Web-Based Database Applications
“Training and team skill have the most significant impact on overall performance of technology and success of technology projects.” - IDC, 2013
Premier Support customers eligible to save 20% on learning credits.
Benefits § Expert-led training to support your MySQL learning needs § Flexibility to train in the classroom or online § Hands-on experience to gain real world experience § Key skills needed for database administrators and developers
• MySQL for Beginners § MySQL for Database Administrators § MySQL Performance Tuning § MySQL Cluster – NEW - Register Your Interest! § MySQL and PHP - Developing Dynamic Web Applications § MySQL for Developers § MySQL Developer Techniques § MySQL 5.6 Database Administrator § MySQL 5.6 Developer To find out more about available MySQL Training & Certification
offerings, go to: education.oracle.com/mysql
Top Courses for Administrators and Developers
Top Certifications
RECENTLY RELEASED !!ALL NEW!! MySQL Cluster Training To Register your interest to influence the
schedule on this newly released course – go to educaPon.oracle.com/mysql and click on the
MySQL Cluster Course
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
• Tomas Ulin – Vice President of the MySQL Engineering Team
• Oracle DBAs, Make the Most of MySQL
• Wednesday 11:00-‐11:45
MySQL Keynote @ DOAG2014
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Next Steps Learn More • www.mysql.com/cluster • AuthenPc MySQL Curriculum: hXp://oracle.com/educaPon/mysql
Try it Out • dev.mysql.com/downloads/cluster/
Let us know what you think • clusterdb.com • @clusterdb • forums.mysql.com/list.php?25