Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

No sql from the web’s favourite relational database MySQL

176 views

Published on

No sql from the web’s favourite relational database MySQL

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No sql from the web’s favourite relational database MySQL

  1. 1. NoSQL From The Web’s Favourite Rela8onal Database Andrew Morgan Director MySQL Product Management @andrewmorgan clusterdb.com 22nd June 2015 15/12/16 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  2. 2. Safe Harbor Statement The following is intended to outline our general product direc8on. It is intended for informa8on purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or func8onality, and should not be relied upon in making purchasing decisions. The development, release, and 8ming of any features or func8onality described for Oracle’s products remains at the sole discre8on of Oracle. 15/12/16 2 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  3. 3. 3 15/12/16 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  4. 4. Key-Value Store 15/12/16 4 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  5. 5. 5 15/12/16 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  6. 6. Graph Database 6 15/12/16 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  7. 7. NoSQL Simple access paerns Compromise on consistency for performance Scale-Out Ad-hoc data format Simple opera8on SQL Complex queries with joins ACID transac8ons Scale-Out & Scale-Up Well defined schemas Rich set of tools S8ll a role for SQL (RDBMS)? Scalability Performance HA Ease of use SQL/Joins ACID Transac>ons 15/12/16 7 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  8. 8. MySQL Cluster Overview • In-Memory Op8miza8on + Disk-Data • Predictable Low-Latency, Bounded Access Time REAL-TIME •  Auto-Sharding, Mul8-Master •  ACID Compliant, OLTP + Real-Time Analy8cs HIGH SCALE, READS + WRITES •  Shared nothing, no Single Point of Failure •  Self Healing + On-Line Opera8ons 99.999% AVAILABILITY •  Key/Value + Complex, Rela8onal Queries •  SQL + Memcached + JavaScript + Java + HTTP/REST & C++ SQL + NoSQL •  Open Source + Commercial Edi8ons •  Commodity hardware + Management, Monitoring Tools LOW TCO 15/12/16 8 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  9. 9. MySQL Cluster Architecture MySQL Cluster Data Nodes Clients Applica8on Layer Data Layer 15/12/16 9 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  10. 10. Node Group Data Node 1 Data Par88oning •  Data transparently sharded between Node Groups •  Each fragment ac8ve in one Data Node with synchronous replica8on to 2nd Data Node in same Node Group 15/12/16 10 Fragment 1 Fragment 2’ Data Node 2 Fragment 1’ Fragment 2 Node Group Data Node 3 Fragment 3 Fragment 4’ Data Node 4 Fragment 3’ Fragment 4 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  11. 11. Data Par88oning •  DBA chooses which part of Primary Key to use as shard key •  Fragment for each row decided by hashing the sharding key 15/12/16 11 User-id (PK) Service (PK) Data 1773467253 chat xxx 6257346892 chat xxx 1773467253 photos xxx 7234782739 photos xxx 8235602099 reminders xxx 8437829249 loca>on xxx Shard Key Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  12. 12. MySQL Cluster Architecture MySQL Cluster Data Nodes Clients Applica8on Layer Data Layer 15/12/16 12 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  13. 13. MySQL Cluster Scaling MySQL Cluster Data Nodes Clients Applica8on Layer Data Layer 15/12/16 13 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  14. 14. MySQL Cluster HA MySQL Cluster Data Nodes Clients Applica8on Layer Data Layer 15/12/16 14 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  15. 15. 15/12/16 15 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  16. 16. 15/12/16 16 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  17. 17. 1.2 Billion UPDATEs per Minute •  Distributed Joins also possible 0 5 10 15 20 25 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 MillionsofUPDATEsperSecond MySQL Cluster Data Nodes 15/12/16 17 Scalability !" Performance !" HA !" Ease of use SQL/Joins !" ACID Transac>ons !" Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  18. 18. 15/12/16 18 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  19. 19. Scalability !" Performance !" HA !" Ease of use !" SQL/Joins !" ACID Transac>ons !" 15/12/16 19 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  20. 20. 15/12/16 20 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  21. 21. 15/12/16 21 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  22. 22. 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 15/12/16 22 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  23. 23. Cluster & Memcached – Schema-Free <town:maidenhead,SL6> key value <town:maidenhead,SL6> key value Key Value town:maidenhead SL6 generic table Applica8on view SQL view 15/12/16 23 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  24. 24. 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 Applica8on view SQL view 15/12/16 24 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  25. 25. Node.js NoSQL API •  Na8ve 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 transforma8on •  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 •  Op8onally routes through MySQL Server – Use with InnoDB V8 JavaScript Engine MySQL Cluster Node.js Module MySQL Cluster Data Nodes Clients 15/12/16 25 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  26. 26. 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 } } 15/12/16 26 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  27. 27. MySQL Cluster 7.4 GA 15/12/16 27 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  28. 28. MySQL Cluster 7.4 GA •  200 Million NoSQL Reads/Sec •  2.5M SQL Ops/Sec •  50% Faster Reads •  40% Faster Mixed Performance •  Ac8ve-Ac8ve Geographic Redundancy •  Conflict Detec8on/ Resolu8on Ac8ve-Ac8ve •  5X Faster Maintenance Ops •  Detailed Repor8ng Management 15/12/16 28 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  29. 29. •  Memory op8mized tables – Durable – Mix with disk-based tables •  Massively concurrent OLTP •  Distributed Joins for analy8cs •  Parallel table scans for non-indexed searches •  MySQL Cluster 7.4 FlexAsych – 200M NoSQL Reads/Second 15/12/16 29 MySQL Cluster 7.4 NoSQL Performance 200 Million NoSQL Reads/Second !"!!!! !50,000,000!! !100,000,000!! !150,000,000!! !200,000,000!! !250,000,000!! 2! 4! 6! 8! 10! 12! 14! 16! 18! 20! 22! 24! 26! 28! 30! 32! Reads&per&second& Data&Nodes& FlexAsync&Reads& Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  30. 30. Performance Enhancements MySQL Cluster 7.4 50% Read-Only Increase 15/12/16 30 0" 1000" 2000" 3000" 4000" 5000" 6000" 7000" 8000" 9000" 64" 128" 192" 256" 320" 384" 448" 512" Transac'ons)per)second) Threads) Sysbench)R/W) 7.4" 7.3" 7.2" 0" 1000" 2000" 3000" 4000" 5000" 6000" 7000" 8000" 9000" 10000" 64" 128" 192" 256" 320" 384" 448" 512" Transac'on)per)second) Threads) Sysbench)RO) 7.4" 7.3" 7.2" 40% Read/Write Increase Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  31. 31. •  Asynchronous replica8on between MySQL Clusters •  Ac8ve-Ac8ve – Update anywhere – Conflict detec8on •  Applica8on no8fied through excep8on tables •  Can opt to have conflicts resolved automa8cally – Auto-conflict-resolu8on •  Conflic8ng transac8on and dependent ones are rolled-back •  No changes to applica8on schema Ac8ve-Ac8ve Geo-Replica8on 15/12/16 31 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  32. 32. 15/12/16 32 But what if I want to s8ck with InnoDB? Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  33. 33. 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 (op8onal) Handler API InnoDB API InnoDB Storage Engine mysqld process SQL Memcached Protocol Up to 9x Higher “SET / INSERT” Throughput 15/12/16 33 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  34. 34. HTTP Plugin for MySQL •  Server Plugin adds HTTP(S) endpoints to MySQL •  Results are serialized to JSON format encoded as UTF8 •  Provides 3 choices of User Endpoint Types – SQL – CRUD - Key-Value – JSON - Document 34 labs.mysql.com 15/12/16 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  35. 35. 15/12/16 35 But what about Documents? Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  36. 36. MySQL 5.7: JSON •  Na8ve JSON data types – Na8ve internal binary format for efficient processing & storage •  Built-in JSON func8ons – Allowing you to efficiently store, search, update, and manipulate Documents •  JSON Comparator – Allows for easy integra8on of Document data within your SQL queries •  Indexing of Documents using Generated Columns – InnoDB supports indexes on both stored and virtual Generated Columns – New expression analyzer automa8cally uses the best “func8onal” index available 36 labs.mysql.com 15/12/16 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  37. 37. •  jsn_array() –  Build a JSON array from list of expressions •  jsn_object() –  Builds JSON objects from a variable length list of key/value pairs •  jsn_insert() –  Adds 'missing' data to JSON documents •  jsn_remove() –  Removes aributes from exis8ng JSON documents •  jsn_set() –  Sets aributes within JSON documents •  jsn_replace() –  Replaces (but doesn't add) aributes within JSON documents •  jsn_append() –  Adds a value to the end of an array •  jsn_merge() –  Merges two arrays •  jsn_extract() –  Returns a value nested inside of a JSON document 15/12/16 37 JSON Func8ons for Crea8ng & Manipula8ng JSON Documents Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  38. 38. •  jsn_search() –  Search for values within JSON documents and return their loca8ons •  jsn_contains() –  Checks for a specific element and value •  jsn_contains_path() –  Determine if a specific element is present in a document in a specific posi8on •  jsn_valid() –  Check if document is a valid JSON document •  jsn_type() –  Find the type of a value within a document •  jsn_keys() –  Returns arrays of the key names for the JSON documents •  jsn_length() –  Number of elements in JSON document •  jsn_depth() –  Level of nes8ng in JSON document •  jsn_unquote() –  Helps move from JSON to other MySQL types •  jsn_quote() –  Helps move from other MySQL types to JSON 15/12/16 38 Query and Search JSON Func8ons Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  39. 39. Generated Columns •  Virtual Generated Column – Generated on the fly when the column is read – Can be indexed •  Stored Generated Column – Generated when the referenced column is wrien to – Can be indexed mysql> ALTER TABLE employees ADD name VARCHAR(100) GENERATED ALWAYS AS(jsn_extract(info, '$.name')) VIRTUAL; mysql> ALTER TABLE employees ADD INDEX(name); hp://mysqlserverteam.com/ 39 Digging into your Documents labs.mysql.com 15/12/16 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  40. 40. •  Save memory/storage and simplify applica8on – Joins between Documents •  Normalize data where it makes sense – Foreign Keys between Documents – Update mul8ple Documents in a single atomic transac8on •  Leverage all of your data – Read/write Document and rela8onal data in a single query/transac8on •  20 years of product maturity 15/12/16 40 So Just Another Document Store? Copyright © 2015, Oracle and/or its affiliates. All rights reserved
  41. 41. Next Steps Learn More •  www.mysql.com/cluster •  Authen8c MySQL Curriculum: hp://oracle.com/educa8on/mysql Try it Out •  dev.mysql.com/downloads/cluster/ •  labs.mysql.com Let us know what you think •  clusterdb.com •  @clusterdb •  forums.mysql.com/list.php?25 15/12/16 41 Copyright © 2015, Oracle and/or its affiliates. All rights reserved

×