tarantool a nosql tarantool a nosql database with sql
play

Tarantool - a NoSQL Tarantool - a NoSQL database with SQL database - PowerPoint PPT Presentation

Tarantool - a NoSQL Tarantool - a NoSQL database with SQL database with SQL Pavel Lapaev, Kirill Yukhin, Product Manager@Mail.ru Engineering Manager @Mail.ru 1 Agenda Agenda What is Mail.ru Group? What is Tarantool? Performance Storage


  1. Tarantool - a NoSQL Tarantool - a NoSQL database with SQL database with SQL Pavel Lapaev, Kirill Yukhin, Product Manager@Mail.ru Engineering Manager @Mail.ru 1

  2. Agenda Agenda What is Mail.ru Group? What is Tarantool? Performance Storage engines Scaling Why SQL? Roadmap 2

  3. Mail.ru Group Mail.ru Group 20 years in business, leading IT company in Russia Social networks VK (97m monthly) and Odnoklassniki (45m monthly) Email (top 5 in the world, 100m active accounts) Portal and IM (35m monthly) Online Games (512m accounts) E-commerce, Search, Delivery, Marketplace, E- learning, Maps, etc. 3

  4. Tarantool in a Nutshell Tarantool in a Nutshell An in-memory database with an integrated application server Team of 70+ people 10 years of history Open-source and enterprise versions 4

  5. Tarantool Facts Tarantool Facts Here is a bunch of features: In-memory and disk storage engines Core written in C, app server exposes Lua Persistence (WAL and snapshots) Application server onboard ACID transactions Horizontal scalability: sharding and replication NoSQL... with SQL 5

  6. Tarantool Products Tarantool Products Tarantool itself Cartridge (cluster management framework) Kubernetes Operator Enterprise Edition Data Grid 6

  7. Enterprise Products Enterprise Products Enterprise Edition L2, L3 support Enterprise database connectivity Oracle replication modules Security audit log Data Grid System to develop distributed apps Flexible connectivity to external sources Versioned data storage Pre and post processing of data Lots of tools already in the box 7

  8. Tarantool Customers Tarantool Customers 8

  9. History History Created @ Mail.ru Group about 10 years ago Used to store sessions/profiles of millions of users 4 instances load web-page AJAX request profiles mobile API 8 instances Web servers > 1.000.000 requests per second 9

  10. Must-have and mustn't-have features Must-have and mustn't-have features No secondary keys, constraints etc. Schema-less Need a language. *QL is not must-have High-speed in any sense! Simple Extensible Transactions Persistency Once again: it must be fast , no excuses 10

  11. Tarantool: Bird's Eye View Tarantool: Bird's Eye View No need for cache: It is in-memory But still DBMS: persistency and transactions It regards ACID Single threaded: It is lock-free Easy: imperative language is on board: Lua It JIT s It's easy to program for business It scales: Replication and sharding 11

  12. DBMS + Application Server C, Lua, SQL, Python, PHP, Go, Java, C# ... Persistent in-memory and disk storage engines Stored procedures in C, Lua, SQL Process Queries WAL Network handling Threads 12

  13. Coöperative multitasking Multithreading Fibers Event-loop 13

  14. Coöperative multitasking Multithreading That is a stall Losses on caches coherency support Losses on locks Losses on long operations Fibers Event-loop 13

  15. Coöperative multitasking Multithreading That is a stall Losses on caches coherency support Losses on locks Losses on long operations Fibers Event-loop Thread is always busy Lock-free Single core - no coherency issues at all 13

  16. Vinyl Vinyl In-memory is OK, but not always enough Write-oriented: LSM tree Same API as memtx Transactions, secondary keys 14

  17. Scaling Scaling Why? 15

  18. Scaling Scaling Why? 15

  19. Scaling Scaling Vertical 15

  20. Scaling Scaling Horizontal 15

  21. Horizontal scaling Horizontal scaling Replication Sharding ABC ABC ABC A C B Scaling computation and fault Scaling computation and tolerance data 16

  22. Horizontal scaling Horizontal scaling Replication Sharding ABC ABC ABC A C B Scaling computation and fault Scaling computation and tolerance data Replication and sharding A B C A A B B C C Scaling computation, data and fault tolerance 16

  23. Replication Replication Asynchronous Synchronous begin commit begin commit prepare replicate replicate 17

  24. Replication Replication Asynchronous Synchronous begin commit begin commit prepare replicate replicate Commit is not waiting for replication to succeed 17

  25. Replication Replication Asynchronous Synchronous begin commit begin commit prepare replicate replicate Commit is not waiting for replication to Two phase commit. To succeed, need to succeed replicate to N nodes 17

  26. Replication Replication Asynchronous Synchronous begin commit begin commit prepare replicate replicate Commit is not waiting for replication to Two phase commit. To succeed, need to succeed replicate to N nodes Faster Replicas might lag, conflict 17

  27. Replication Replication Asynchronous Synchronous begin commit begin commit prepare replicate replicate Commit is not waiting for replication to Two phase commit. To succeed, need to succeed replicate to N nodes Faster More reliable Replicas might lag, conflict Slower, complicated protocols 17

  28. Sharding Sharding Decide where to store? Ranges hash min max Found range where the key belongs -> Calculated hash of the key -> found the node found the node 18

  29. Sharding Sharding Decide where to store? Ranges hash min max Found range where the key belongs -> Calculated hash of the key -> found the node found the node 18

  30. Sharding Sharding Decide where to store? Ranges hash min max Found range where the key belongs -> Calculated hash of the key -> found the node found the node Best Complicated Usually useless 18

  31. Sharding Sharding Decide where to store? Ranges hash min max Found range where the key belongs -> Calculated hash of the key -> found the node found the node Best Complicated Usually useless 18

  32. Sharding Sharding Decide where to store? Ranges hash min max Found range where the key belongs -> Calculated hash of the key -> found the node found the node Good enough Best ? Complex resharding Complicated Complex queries not fast Usually useless 18

  33. Resharding problem Resharding problem shard _ id ( key ) : key → { shard , shard , ..., shard } 1 2 N Change N leads to change of shard-function shard _ id ( key 1) =  new _ shard _ id ( key ) 19

  34. Resharding problem Resharding problem shard _ id ( key ) : key → { shard , shard , ..., shard } 1 2 N Change N leads to change of shard-function shard _ id ( key 1) =  new _ shard _ id ( key ) Useless data Need to re-calculate shard- moves functions for all data Some data might move on one of old nodes 19

  35. Resharding problem Resharding problem shard _ id ( key ) : key → { shard , shard , ..., shard } 1 2 N Change N leads to change of shard-function shard _ id ( key 1) =  new _ shard _ id ( key ) Useless data Need to re-calculate shard- moves functions for all data Some data might move on one of old nodes ... but not in Tarantool land 19

  36. Virtual sharding Virtual sharding Virtual Physical Data nodes nodes {tuple} {tuple} {tuple} {tuple} {tuple} {tuple} 20

  37. Virtual sharding Virtual sharding Virtual Physical Data nodes nodes {tuple} {tuple} {tuple} {tuple} {tuple} {tuple} shard _ id ( key ) = { bucket , bucket , ..., bucket } 1 2 N # = const >> # Shard-function is fixed 20

  38. Virtual sharding Virtual sharding Virtual Physical Data nodes nodes {tuple} {tuple} {tuple} {tuple} {tuple} {tuple} shard _ id ( key ) = { bucket , bucket , ..., bucket } 1 2 N # = const >> # Shard-function is fixed 20

  39. Sharding Sharding Ranges Hashes Virtual buckets Having a range or a bucket, how to find where it is stored physically? 21

  40. Sharding Sharding Ranges Hashes Virtual buckets Having a range or a bucket, how to find where it is stored physically? 1. Prohibit re-sharding 21

  41. Sharding Sharding Ranges Hashes Virtual buckets Having a range or a bucket, how to find where it is stored physically? 1. Prohibit re-sharding 2. Always visit all nodes 21

  42. Sharding Sharding Ranges Hashes Virtual buckets Having a range or a bucket, how to find where it is stored physically? 1. Prohibit re-sharding 2. Always visit all nodes 3. Implement proxy-router! 21

  43. Why SQL? Why SQL? CREATE TABLE t1 (id INTEGER PRIMARY KEY, a INTEGER, b INTEGER, c INTEGER) CREATE TABLE t2 (id INTEGER PRIMARY KEY, x INTEGER, y INTEGER, z INTEGER) SQL> SELECT DISTINCT(a) FROM t1, t2 WHERE t1.id = t2.id AND t2.y > 1; 22

  44. Why SQL? Why SQL? CREATE TABLE t1 (id INTEGER PRIMARY KEY, a INTEGER, b INTEGER, c INTEGER) CREATE TABLE t2 (id INTEGER PRIMARY KEY, x INTEGER, y INTEGER, z INTEGER) function query() local join = {} for _, v1 in box.space.t1:pairs({}, {iterator='ALL'}) do local v2 = box.space.t2:get(v1[1]) if v2[3] > 1 then table.insert(join, {t1=v1, t2=v2}) end end local dist = {} for _, v in pairs(join) do if dist[v['t1'][2]] == nil then dist[v['t1'][2]] = 1 end end local result = {} for k, _ in pairs(dist) do table.insert(result, k) end return result end 23

  45. SQL Features SQL Features Trying to be subset of ANSI Minimum overhead of query planner ACID transactions, SAVEPOINTs left/inner/natural JOIN, UNION/EXCEPT, subqueries HAVING, GROUP BY, ORDER BY WITH RECURSIVE Triggers Views Constraints Collations 24

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend