MySQL as a Document Store - Meetupfiles.meetup.com/2855062/MySQL as a Document Store.pdfcommitment to deliver any material, code, ... –Implemented by X Plugin to Extend MySQL Server

Post on 10-Apr-2019

215 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

Transcript

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

MySQL as a Document Store

Ted Wennmark ted.wennmark@oracle.com

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Safe Harbor Statement

The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Program Agenda

MySQL Document Store

MySQL Future

1

2

3

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Program Agenda

MySQL Document Store

MySQL Future

1

2

4

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Today’s Challenges

• Developers want to move faster

• Time to market has a premium value

• Rapid prototyping, iterate fast…

5

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Today’s Challenges (cont.)

• Relational databases ask for schema up front – Potentially saving you time in the future

– Less variations; less code to handle edge cases

– Added cost with each schema change

• NoSQL databases do not ask for schema – Saving you time up front

– But potentially adding operational costs over time

–No cost per schema change

6

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Why can you not…

• Have both schema-less and schema in the same technology stack?

• One that checks all the boxes of all stakeholders:

7

Developers: [ x ] Schemaless [ x ] Rapid Prototyping/Simpler APIs [ x ] Document Model

Operations: [ x ] Performance Management/Visibility [ x ] Robust Replication, Backup, Restore [ x ] Comprehensive Tooling Ecosystem

Business Owner: [ x ] Don’t lose my data = ACID transactions [ x ] Capture all my data = Extensible/Schemaless [ x ] Products On Schedule/Time to Market = Rapid Development

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

NEW! MySQL Document Store

• Native JSON Documents in MySQL 5.7 – Schema-less Document Storage

• X Protocol (MySQL 5.7.12 DMR) – Implemented by X Plugin to Extend MySQL Server as a Document Store

• X Dev API

– SQL and Document CRUD Operations

– Implemented in Connector/Node.js, Connector/J, Connector/Net

• MySQL Shell – Javascript, Python, SQL modes

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Architecture

9

MySQL

Plugins

X Protocol Plugin Memcached Plugin Core

X Protocol Std Protocol

X Protocol 33060

Std Protocol 3306

SQL API CRUD API

X and Std Protocols

MySQL Shell

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

New! MySQL X DevAPI

• Modern: fluent API, method chaining

• Stateless sessions enable transparent scaling to multi-server environments

• SQL support

• CRUD for Collections of Documents and Tables

–Documents as simple basic domain objects

– Search expressions match SQL SELECT expressions

• Implemented in MySQL Shell & MySQL Connectors – NEW! MySQL Connector/node.js

– MySQL Connector/J

– MySQL Connector/Net

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

New! MySQL Shell

• Integrated Development and Administration Shell

• Exposes New X DevAPI

• Multi-Language scripting

– JavaScript, Python, and SQL

• Configurable results formats

– Traditional Table, JSON, Tab Separated

11

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 12

tomas@localhost $ mysqlsh --uri root@localhost/test

Creating an X Session to root@localhost:33060/test

Enter password:

Default schema ̀ test` accessible through db.

Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries.

mysql-js> db.createCollection("posts");

<Collection:posts>

mysql-js> db.posts.add({"title":"Hello World", "text":"First post!"})

Query OK, 1 item affected (0.03 sec)

mysql-js> db.posts.find("title = 'Hello World'").sort(["title"]);

[

{

"_id": "8202bda28206e611140b3229389b6526",

"text": "First post!",

"title": "Hello World"

}

]

1 document in set (0.01 sec)

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 13

Under the Hood

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 14

Collections are tables

Tables with: - JSON column - Generated Column

Create a Collection

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Under The Hood II

15

• X-Plugin translates CRUD -> SQL

• No code changes in core parts of MYSQL

Create Document (CRUD)

Look inside general-log

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Under The Hood III

16

Read Document (CRUD)

Look inside general-log

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

CRUD Operations – NoSQL/Document and SQL/Relational

Operation Document Relational

Create Collection.add() Table.insert()

Read Collection.find() Table.select()

Update Collection.modify() Table.update()

Delete Collection.remove() Table.delete()

17

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

CRUD Operations NoSQL/Document Javascript Java

C# NodeJS

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

CRUD Operations SQL/Relational

19

Javascript Java

C# NodeJS

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

MySQL Document Store

✔ Built on Proven SQL/InnoDB/Replication

✔ Schema-less/Relational/Hybrid

✔ ACID/Transactions

✔ CRUD/JSON/Documents

✔ Modern Dev API

✔ Modern/Efficient Protocol

✔ SQL Queries/Analytics over JSON Documents

✔ Transparent and Easy HA/Scaling/Sharding

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

New! Documentation

• Developer Guides

• Lots of examples

New Style - Developer Focused

21

http://dev.mysql.com/doc/dev/mysqlsh-api-javascript/

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Program Agenda

MySQL Document Store

MySQL Future

1

2

22

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Vision

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

“Be the most popular open source database for scale-out”

24

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

3 MySQL will focus on three things.

25

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 26

Scale-Out

Ease-of-Use

Out-of-Box Solution

MySQL

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 27

Ease-of-Use

• Download, Install, HA & Scale-Out in 15 minutes

• Single Interface for Everything MySQL

• Easy to Setup, Scale-Out, Manage & Monitor

• Excellent Quality

MySQL

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 28

Out-of-Box Solution

• Integrated Solution vs. Individual Components

• Designed & Developed Together

• Tested & Delivered Together

• Managed & Monitored Together

MySQL

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 29

Scale-Out

• Maintain World-Class Performance

• Rock Solid, Server-Side HA With Auto-Failover

• Read Scale-Out With Replication

• Write Scale-Out With Sharding

MySQL

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

4 Rollout will happen in four steps.

30

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 31

Read Scale-Out

Async Replication + Auto Failover

Write Scale-Out

Sharding

S1

S2

S3

S4

MySQL Vision – 4 Steps

Timeline

MySQL Document Store

Relational & Document Model

MySQL HA

Out-Of-Box HA

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Introducing …

32

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 33

Scale-Out High Performance

Ease-of-Use Built-in HA

Out-of-Box Solution Everything Integrated

MySQL InnoDB

cluster

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 34

A single product: MySQL • All components created together

• Tested together

• Packaged together

Flexible and Modern • C++ 11

• Protocol Buffers

• Developer friendly

MySQL InnoDB Cluster – Goals

Easy to use • A single client: MySQL Shell

• Easy packaging

• Homogenous servers

Scale-out • Sharded clusters

• Federated system of N replica sets

• Each replica set manages a shard

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

MySQL

InnoDB cluster

MySQL InnoDB Cluster – Architecture - S2

M

M M

MySQL Connector

Application

MySQL Router

MySQL Connector

Application

MySQL Router

MySQL Shell

HA

Group Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

S1 S2 S3 S4 S…

M

M M

MySQL Connector

Application

MySQL Router

MySQL Connector

Application

MySQL Router

MySQL Shell

HA

MySQL InnoDB Cluster – Architecture - S3 MySQL

InnoDB cluster

Read-Only Slaves

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

S1 S2 S3 S4 S…

M

M M

MySQL Connector

Application

MySQL Router

MySQL Connector

Application

MySQL Router

MySQL Shell

HA

Rep

licaS

et (S

har

d 1

)

S1 S2 S3 S4 S…

M

M M

MySQL Connector

Application

MySQL Router

HA

Rep

licaS

et (S

har

d 2

)

S1 S2 S3 S4

M

M M

HA

Rep

licaS

et (S

har

d 3

)

MySQL Connector

Application

MySQL Router

MySQL InnoDB Cluster – Architecture - S4 MySQL

InnoDB cluster

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

MySQL Connector

Application MySQL Connector

Application

MySQL Shell

MySQL Connector

Application MySQL Connector

Application

MySQL InnoDB Cluster – Architecture

MySQL InnoDB

cluster MySQL Enterprise Monitor

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

MySQL

InnoDB cluster

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Demo

MySQL

InnoDB cluster

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

MySQL

InnoDB cluster

MySQL InnoDB Cluster – DEMO

M

M M

Application

MySQL Router

MySQL Connector

Applicaion

MySQL Shell

HA

Group Replication

3310

3320 3330

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 42

The Demo Showed…

• MySQL HA in 4 minutes

• Very easy, even for somebody new to MySQL

• Everything managed through MySQL Shell

• Convenient, easy-to-use AdminAPI

MySQL

InnoDB cluster

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

1 One seamless solution for HA: Easy-to-Use, Out-of-Box, Scale-Out.

43

MySQL

InnoDB cluster

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

What’s next?

44

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 45

Read Scale-Out

Async Replication + Auto Failover

Write Scale-Out

Sharding

S1

S2

S3

S4

MySQL Vision – 4 Steps

Timeline

Download Preview Release from labs.mysql.com

MySQL Document Store

Relational & Document Model

MySQL HA

Out-Of-Box HA

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Resources

Topic Link(s)

MySQL as a Document Database http://dev.mysql.com/doc/refman/5.7/en/document-database.html

MySQL Shell http://dev.mysql.com/doc/refman/5.7/en/mysql-shell.html http://dev.mysql.com/doc/refman/5.7/en/mysqlx-shell-tutorial-javascript.html http://dev.mysql.com/doc/refman/5.7/en/mysqlx-shell-tutorial-python.html

X Dev API http://dev.mysql.com/doc/x-devapi-userguide/en/

X Plugin http://dev.mysql.com/doc/refman/5.7/en/x-plugin.html

MySQL JSON http://mysqlserverteam.com/tag/json/ https://dev.mysql.com/doc/refman/5.7/en/json.html https://dev.mysql.com/doc/refman/5.7/en/json-functions.html

46

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Thank you!

top related