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.

FOSDEM 2015 - NoSQL and SQL the best of both worlds

7,158 views

Published on

There’s 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.

Published in: Software
  • Be the first to comment

FOSDEM 2015 - NoSQL and SQL the best of both worlds

  1. 1. NoSQL and SQL: The Best of Both Worlds Andrew Morgan @andrewmorgan clusterdb.com 1st February 2015 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
  2. 2. 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2
  3. 3. 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3
  4. 4. 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4
  5. 5. Graph Database 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5
  6. 6. NoSQL Simple access patterns Compromise on consistency for performance Ad-hoc data format Simple operation SQL Complex queries with joins ACID transactions Well defined schemas Rich set of tools Still a role for SQL (RDBMS)? Scalability Performance HA Ease of use SQL/Joins ACID Transactions 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6
  7. 7. The Temptation to Jettison Relational Model • Relational Model: – Data stored in multiple tables – Many lookups to retrieve a user’s timeline – Is it worth the effort in setting up this complex data model? • Simpler just to store as one document? The allure of document stores Examples borrowed from @sarahmei https://speakerdeck.com/sarahmei/switching-data-stores-a-postmodern-comedy user friend post comment like liker commenter many many many one one many 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 7
  8. 8. The Temptation to Jettison Relational Model • Document Model: – Entire timeline in a single document (row) – Single lookup to retrieve the user’s timeline – Brilliantly efficient model when the document truly contains self- contained information • 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’] }, {…},{…},… ] }, {…},{…},… } 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 8
  9. 9. 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 9
  10. 10. The Temptation to Jettison Relational 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 relational model But when the data isn’t self contained… user friend post comment like liker commenter many many many one one many 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 10
  11. 11. The Temptation to Jettison Relational 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 transactions 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’] }, {…},{…},… ] }, {…},{…},… } 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 11
  12. 12. 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 12
  13. 13. The Temptation to Jettison Relational Model • The reality is that the developer will store the user-ids instead • Developer is responsible for implementing ‘joins’ in the application – e.g. scanning all timelines for where a user made a comment or liked a post • No transactions 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] }, {…},{…},… ] }, {…},{…},… } 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 13
  14. 14. The Temptation to Jettison Relational Model • Each attribute’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] }, {…},{…},… ] }, {…},{…},… } 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 14
  15. 15. 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 15
  16. 16. MySQL Cluster Overview • In-Memory Optimization + Disk-Data • Predictable Low-Latency, Bounded Access Time REAL-TIME • Auto-Sharding, Multi-Master • ACID Compliant, OLTP + Real-Time Analytics HIGH SCALE, READS + WRITES • Shared nothing, no Single Point of Failure • Self Healing + On-Line Operations 99.999% AVAILABILITY • Key/Value + Complex, Relational Queries • SQL + Memcached + JavaScript + Java + HTTP/REST & C++ SQL + NoSQL • Open Source + Commercial Editions • Commodity hardware + Management, Monitoring Tools LOW TCO 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 16
  17. 17. MySQL Cluster Architecture MySQL Cluster Data Nodes Clients Application Layer Data Layer 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 17
  18. 18. MySQL Cluster Scaling MySQL Cluster Data Nodes Clients Application Layer Data Layer 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 18
  19. 19. MySQL Cluster HA MySQL Cluster Data Nodes Clients Application Layer Data Layer 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 19
  20. 20. 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 20
  21. 21. 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 21
  22. 22. 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 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 22 Scalability a Performance a HA a Ease of use SQL/Joins a ACID Transactions a
  23. 23. 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 23
  24. 24. Scalability a Performance a HA a Ease of use a SQL/Joins a ACID Transactions a 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 24
  25. 25. 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 25
  26. 26. 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 26
  27. 27. 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 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 27
  28. 28. 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 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 28
  29. 29. 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 Application view SQL view 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 29
  30. 30. 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 } } 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 30
  31. 31. Next Steps Learn More • www.mysql.com/cluster • Authentic MySQL Curriculum: http://oracle.com/education/mysql Try it Out • dev.mysql.com/downloads/cluster/ Let us know what you think • clusterdb.com • @clusterdb • forums.mysql.com/list.php?25 1/2/2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 31

×