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.

Cassandra : To be or not to be

678 views

Published on

All popular NoSQL solutions are popular because they are well promoted. And this is a reason why many people use them without deep understanding of what it exactly is and if it satisfies their business requirements. During this talk Andriy will describe what Apache Cassandra is and how it actually processes your requests. This might make you think about if Cassandra is the right solution for your business cases, scenarios and queries or not.

Published in: Software
  • Be the first to comment

  • Be the first to like this

Cassandra : To be or not to be

  1. 1. CASSANDRA To be or not to be?
  2. 2. ABOUT ME Andriy Rymar Software Engineer @ Lohika Morning@Lohika Program Committee Member JUG Lviv Active Member 2
  3. 3. AGENDA 3
  4. 4. AGENDA Cluster Ring 3 Node 4 Node 1 Node 2 Node 3
  5. 5. AGENDA Cluster Ring Data Model 3 Row1 Row2 Row3
  6. 6. AGENDA Cluster Ring Data Model Read & Write 3 Read Write
  7. 7. AGENDA Cluster Ring Data Model Read & Write Update & Delete 3 Update Delete
  8. 8. AGENDA Cluster Ring Data Model Read & Write Update & Delete 3 To be or not to be?
  9. 9. HASHTAG #jeeconf_cassandra 4
  10. 10. HASHTAG #jeeconf_cassandra 4 #jeeconf_cassandra
  11. 11. PREFACE 5 #jeeconf_cassandra
  12. 12. TRENDS 6 #jeeconf_cassandra
  13. 13. TRENDS 6 #jeeconf_cassandra
  14. 14. TRENDS 7 #jeeconf_cassandra
  15. 15. TRENDS 7 #jeeconf_cassandra
  16. 16. 7 #jeeconf_cassandra
  17. 17. CASSANDRA To be or not to be? #jeeconf_cassandra
  18. 18. 9 CLUSTER #jeeconf_cassandra
  19. 19. DISCOVERY Node1 Node3 Node4 Node2 10 #jeeconf_cassandra
  20. 20. DISCOVERY Node3 Node4 Node2 Node1 10 #jeeconf_cassandra
  21. 21. DISCOVERY Node3 Node4 Node2 Hi, I’m node 2 Node1 10 #jeeconf_cassandra
  22. 22. DISCOVERY Node3 Node4 Node2 OK, here are you and me Hi, I’m node 2 Node1 10 #jeeconf_cassandra
  23. 23. DISCOVERY Node3 Node4 Node2 Hi, I’m node 3 OK, here are you and me Hi, I’m node 2 Node1 10 #jeeconf_cassandra
  24. 24. DISCOVERY Node3 Node4 Node2 Hi, I’m node 3 OK, here are you and me Hi, I’m node 2 Well, here are you, me and node2 Node1 10 #jeeconf_cassandra
  25. 25. DISCOVERY Node3 Node4 Node2 Hi, I’m node 4 Hi, I’m node 3 OK, here are you and me Hi, I’m node 2 Well, here are you, me and node2 Node1 10 #jeeconf_cassandra
  26. 26. DISCOVERY Node3 Node4 Node2 Cool, here are you, me, node2 and node3 Hi, I’m node 4 Hi, I’m node 3 OK, here are you and me Hi, I’m node 2 Well, here are you, me and node2 Node1 10 #jeeconf_cassandra
  27. 27. DISCOVERY Node3 Node4 Node2 Cool, here are you, me, node2 and node3 Hi, I’m node 4 Hi, I’m node 3 OK, here are you and me Hi, I’m node 2 Well, here are you, me and node2 Node1 10 #jeeconf_cassandra
  28. 28. DISCOVERY Node3 Node4 Node2 Cool, here are you, me, node2 and node3 Hi, I’m node 4 Hi, I’m node 3 OK, here are you and me Hi, I’m node 2 Well, here are you, me and node2 Node1 10 #jeeconf_cassandra
  29. 29. DISCOVERY Node3 Node4 Node2 Cool, here are you, me, node2 and node3 Hi, I’m node 4 Hi, I’m node 3 OK, here are you and me Hi, I’m node 2 Well, here are you, me and node2 Node1 10 #jeeconf_cassandra
  30. 30. RING Node1 Node3 Node4 Node2 11 #jeeconf_cassandra
  31. 31. DATA RANGE Long.min Long.max 12 #jeeconf_cassandra
  32. 32. DATA RANGE Long.min Long.max 12 #jeeconf_cassandra
  33. 33. RING CLUSTER Node1 Node3 Node4 Node2 Long.minLong.max 13 #jeeconf_cassandra
  34. 34. TOKEN 14 #jeeconf_cassandra
  35. 35. TOKEN 12343214 14 #jeeconf_cassandra
  36. 36. TOKEN 12343214 Long.min Long.max 14 #jeeconf_cassandra
  37. 37. INITIALTOKENS Node1 Node2 12343214 21144543 15 #jeeconf_cassandra
  38. 38. 16 TOKENS #jeeconf_cassandra
  39. 39. Issues 16 TOKENS #jeeconf_cassandra
  40. 40. REPLICATION 17 #jeeconf_cassandra
  41. 41. REPLICATION RF 17 #jeeconf_cassandra
  42. 42. = 2 REPLICATION RF 17 #jeeconf_cassandra
  43. 43. = 2 REPLICATION RF 17 «Hello, JeeConf» Node 1: «Hello, JeeConf» Node 2: «Hello, JeeConf» #jeeconf_cassandra
  44. 44. REPLICATION &TOKENS Node1 Node 2Node 3 18 #jeeconf_cassandra
  45. 45. REPLICATION &TOKENS Node1 RF = 2 Node 2Node 3 18 #jeeconf_cassandra
  46. 46. REPLICATION &TOKENS RF = 2 Node 2Node 3 Node1 18 #jeeconf_cassandra
  47. 47. REPLICATION &TOKENS RF = 2 Node 2Node 3 Node1 18 #jeeconf_cassandra
  48. 48. REPLICATION &TOKENS RF = 2 Node 3 Node1 Node 2 node1 Node1 18 #jeeconf_cassandra
  49. 49. REPLICATION &TOKENS RF = 2 Node 3 Node1 Node 2 node1 Node1 18 #jeeconf_cassandra
  50. 50. REPLICATION &TOKENS RF = 2 Node 3 Node1 Node 2 node1 Node1 18 #jeeconf_cassandra
  51. 51. REPLICATION &TOKENS Node1 RF = 2 Node 3 Node 2 node1 18 #jeeconf_cassandra
  52. 52. REPLICATION &TOKENS Node1 RF = 2 Node 3 Node 2 node1 18 #jeeconf_cassandra
  53. 53. REPLICATION &TOKENS Node1 RF = 2 Node 3 Node 2 node1 Node 2 node1 18 #jeeconf_cassandra
  54. 54. VNODE 19 #jeeconf_cassandra
  55. 55. VNODE 19 #jeeconf_cassandra
  56. 56. VNODE 255 19 #jeeconf_cassandra
  57. 57. VNODE 255 From To 19 #jeeconf_cassandra
  58. 58. REPLICATION &V-NODE Node1 Node 2Node 3 20 #jeeconf_cassandra
  59. 59. REPLICATION &V-NODE Node1 RF = 2 Node 2Node 3 20 #jeeconf_cassandra
  60. 60. REPLICATION &V-NODE Node1 RF = 2 Node 2Node 3 v-node = 2 20 #jeeconf_cassandra
  61. 61. Node1 REPLICATION &V-NODE RF = 2 Node 2Node 3 v-node = 2 20 #jeeconf_cassandra
  62. 62. Node1 REPLICATION &V-NODE RF = 2 Node 2Node 3 v-node = 2 20 #jeeconf_cassandra
  63. 63. Node1 REPLICATION &V-NODE RF = 2 Node 2Node 3 v-node = 2 20 #jeeconf_cassandra
  64. 64. Node1 REPLICATION &V-NODE RF = 2 Node 2Node 3 v-node = 2 20 #jeeconf_cassandra
  65. 65. Node1 REPLICATION &V-NODE RF = 2 Node 2Node 3 v-node = 2 20 #jeeconf_cassandra
  66. 66. REPLICATION &V-NODE Node1 RF = 2 Node 2Node 3 v-node = 2 20 #jeeconf_cassandra
  67. 67. REPLICATION &V-NODE Node1 RF = 2 Node 2Node 3 v-node = 2 20 #jeeconf_cassandra
  68. 68. NODE RANGE Node1 Node3 Node4 Node2 21 #jeeconf_cassandra
  69. 69. NODE RANGE 22 Node1 Node3 Node4 Node2 #jeeconf_cassandra
  70. 70. CASSANDRA To be or not to be? #jeeconf_cassandra
  71. 71. 24 DATA MODEL #jeeconf_cassandra
  72. 72. KEYSPACE 25 #jeeconf_cassandra
  73. 73. KEYSPACE 25 #jeeconf_cassandra
  74. 74. KEYSPACE Table1 Table2 25 #jeeconf_cassandra
  75. 75. KEYSPACE 25 #jeeconf_cassandra Column Family 1 Column Family 2
  76. 76. KEYSPACE Row 1 Row 2 Row 1 Row 2 25 #jeeconf_cassandra Column Family 1 Column Family 2
  77. 77. KEYSPACE value value value value value value key key key key key key value value value key key key Row 1 Row 2 Row 1 Row 2 25 #jeeconf_cassandra Column Family 1 Column Family 2
  78. 78. DATA DISTRIBUTION 26 #jeeconf_cassandra
  79. 79. DATA DISTRIBUTION murmur3(partition_key) 26 #jeeconf_cassandra
  80. 80. 27 KEYS #jeeconf_cassandra
  81. 81. 27 KEYS Primary #jeeconf_cassandra
  82. 82. 27 KEYS Primary http://www.pngall.com/man-png #jeeconf_cassandra
  83. 83. 27 KEYS Primary Partition http://www.pngall.com/man-png #jeeconf_cassandra
  84. 84. 27 KEYS Primary Partition http://www.pngall.com/man-png http://www.pngmart.com/image/31069 #jeeconf_cassandra
  85. 85. 27 KEYS Primary Partition Composite http://www.pngall.com/man-png http://www.pngmart.com/image/31069 #jeeconf_cassandra
  86. 86. 27 KEYS Primary Partition Composite http://www.pngall.com/man-png http://www.pngmart.com/image/31069 http://www.pngmart.com/image/21342 #jeeconf_cassandra
  87. 87. 27 KEYS Primary Partition Composite Clustering http://www.pngall.com/man-png http://www.pngmart.com/image/31069 http://www.pngmart.com/image/21342 #jeeconf_cassandra
  88. 88. 27 KEYS Primary Partition Composite Clustering http://www.pngall.com/man-png http://www.pngmart.com/image/31069 http://www.pngmart.com/image/21342 http://ujceastside.org/home-health-aides/ #jeeconf_cassandra
  89. 89. 28 PRIMARY CREATE TABLE album ( id uuid, name text, PRIMARY KEY (id) ) #jeeconf_cassandra
  90. 90. 28 PRIMARY CREATE TABLE album ( id uuid, name text, PRIMARY KEY (id) ) Primary & Partition & Clustering #jeeconf_cassandra
  91. 91. 29 PARTITION CREATE TABLE author_book ( author text, book text, population int, PRIMARY KEY (author, book) ) #jeeconf_cassandra
  92. 92. 29 PARTITION CREATE TABLE author_book ( author text, book text, population int, PRIMARY KEY (author, book) ) Partition Clustering #jeeconf_cassandra
  93. 93. 30 COMPOSITE & CLUESTERING CREATE TABLE teacher_lesson ( teacher text, lesson text, topic text, duration int, PRIMARY KEY ((teacher, lesson), topic, duration) ) #jeeconf_cassandra
  94. 94. 30 COMPOSITE & CLUESTERING CREATE TABLE teacher_lesson ( teacher text, lesson text, topic text, duration int, PRIMARY KEY ((teacher, lesson), topic, duration) ) Composite Clustering #jeeconf_cassandra
  95. 95. 31 IMPORTANT #jeeconf_cassandra
  96. 96. 31 IMPORTANT Natural ordering #jeeconf_cassandra
  97. 97. 31 IMPORTANT Natural ordering No relations #jeeconf_cassandra
  98. 98. 31 IMPORTANT Natural ordering No relations No ACID transactions #jeeconf_cassandra
  99. 99. CASSANDRA to be or not to be? #jeeconf_cassandra
  100. 100. 33 READ & WRITE #jeeconf_cassandra
  101. 101. ARCHITECTURE Node 34 #jeeconf_cassandra
  102. 102. ARCHITECTURE Memory Permanent storage Node 34 #jeeconf_cassandra
  103. 103. ARCHITECTURE Memory MemTable Permanent storage Node 34 #jeeconf_cassandra
  104. 104. ARCHITECTURE Memory MemTable CommitLog Permanent storage Node 34 #jeeconf_cassandra
  105. 105. ARCHITECTURE Memory MemTable CommitLog Permanent storage SSTable 1 SSTable 2 SSTable 3 Node 34 #jeeconf_cassandra
  106. 106. ARCHITECTURE Memory MemTable CommitLog Permanent storage SSTable 1 SSTable 2 SSTable 3 Newer Older Node 34 #jeeconf_cassandra
  107. 107. Memory MemTable CommitLog Permanent storage SSTable 1 SSTable 2 SSTable 3 Newer Older Node 34 #jeeconf_cassandra WRITE
  108. 108. Request Memory MemTable CommitLog Permanent storage SSTable 1 SSTable 2 SSTable 3 Newer Older Node 34 #jeeconf_cassandra WRITE
  109. 109. Request Memory MemTable CommitLog Permanent storage SSTable 1 SSTable 2 SSTable 3 Newer Older Node 1 34 #jeeconf_cassandra WRITE
  110. 110. Request Memory MemTable CommitLog Permanent storage SSTable 1 SSTable 2 SSTable 3 Newer Older Node 1 2 34 #jeeconf_cassandra WRITE
  111. 111. Request Memory MemTable CommitLog Permanent storage SSTable 1 SSTable 2 SSTable 3 Newer Older Node 1 3 4 2 34 #jeeconf_cassandra WRITE
  112. 112. Request Memory MemTable CommitLog Permanent storage SSTable 5 SSTable 4 SSTable 1 SSTable 2 SSTable 3 Newer Older Node 1 3 4 5 2 34 #jeeconf_cassandra WRITE
  113. 113. WRITE Node 1 Node 2 Node 3 35 #jeeconf_cassandra
  114. 114. WRITE Node 1 Node 2 Node 3 RF = 3 35 #jeeconf_cassandra
  115. 115. WRITE Node 1 Node 2 Node 3 RF = 3 35 Client #jeeconf_cassandra
  116. 116. WRITE Node 1 Node 2 Node 3 RF = 3 35 Client #jeeconf_cassandra
  117. 117. CONSISTENCY LEVEL 36 #jeeconf_cassandra
  118. 118. CONSISTENCY LEVEL 36 CL #jeeconf_cassandra
  119. 119. WRITE Node 1 Node 2 Node 3 RF = 3 37 Client #jeeconf_cassandra
  120. 120. WRITE Node 1 Node 2 Node 3 RF = 3 37 Client #jeeconf_cassandra CL = 2
  121. 121. WRITE Node 3 RF = 3 Node 2Node 1 37 Client #jeeconf_cassandra successsuccess CL = 2
  122. 122. WRITE Node 3 RF = 3 Node 2Node 1 37 Client #jeeconf_cassandra successsuccess CL = 2
  123. 123. READ Memory MemTable Permanent storage Node 38 #jeeconf_cassandra
  124. 124. Request READ Memory MemTable Permanent storage Node 38 #jeeconf_cassandra
  125. 125. Request READ Memory MemTable Permanent storage Node 1 38 #jeeconf_cassandra
  126. 126. Request READ Memory MemTable Permanent storage Node SSTable 1 SSTable 2 1 38 #jeeconf_cassandra
  127. 127. Request READ Memory MemTable Permanent storage Node SSTable 1BF IF SSTable 2BF IF 1 38 #jeeconf_cassandra
  128. 128. Request READ Memory MemTable Permanent storage Node SSTable 1BF IF SSTable 2BF IF 1 2 38 #jeeconf_cassandra
  129. 129. Request READ Memory MemTable Permanent storage Node SSTable 1BF IF SSTable 2BF IF 1 2 3 38 #jeeconf_cassandra
  130. 130. Request READ Memory MemTable Permanent storage Node SSTable 1BF IF SSTable 2BF IF 1 2 3 4 38 #jeeconf_cassandra
  131. 131. Request READ Memory MemTable Permanent storage Node SSTable 1BF IF SSTable 2BF IF 1 2 3 4 5 38 #jeeconf_cassandra
  132. 132. Request READ Memory MemTable Permanent storage Node SSTable 1BF IF SSTable 2BF IF 1 2 3 4 5 6 38 #jeeconf_cassandra
  133. 133. READ Node 1 Node 2 Node 3 39 #jeeconf_cassandra
  134. 134. READ Node 1 Node 2 Node 3 RF = 3 39 #jeeconf_cassandra
  135. 135. READ Node 1 Node 2 Node 3 CL = 2 RF = 3 39 #jeeconf_cassandra
  136. 136. READ Node 1 Node 2 Node 3 CL = 2 RF = 3 39 Client #jeeconf_cassandra
  137. 137. READ Node 1 Node 2 Node 3 CL = 2 RF = 3 get digest 39 Client #jeeconf_cassandra
  138. 138. READ Node 1 Node 2 Node 3 CL = 2 RF = 3 get digest 123453 39 Client #jeeconf_cassandra
  139. 139. READ Node 1 Node 2 Node 3 CL = 2 RF = 3 get digest 123453 39 Client #jeeconf_cassandra
  140. 140. CASSANDRA To be or not to be? #jeeconf_cassandra
  141. 141. 41 UPDATE & DELETE #jeeconf_cassandra
  142. 142. UPDATE 42 #jeeconf_cassandra
  143. 143. UPDATE Upsert 42 #jeeconf_cassandra
  144. 144. UPDATE Memory MemTable Permanent storage SSTable 1 SSTable 2 SSTable 3 Newer Older Node CommitLog 43 #jeeconf_cassandra
  145. 145. UPDATE Request Memory MemTable Permanent storage SSTable 1 SSTable 2 SSTable 3 Newer Older Node CommitLog 43 #jeeconf_cassandra
  146. 146. UPDATE Request Memory MemTable Permanent storage SSTable 1 SSTable 2 SSTable 3 Newer Older Node CommitLog 1 43 #jeeconf_cassandra
  147. 147. UPDATE Request Memory MemTable Permanent storage SSTable 1 SSTable 2 SSTable 3 Newer Older Node CommitLog 1 2 43 #jeeconf_cassandra
  148. 148. UPDATE Request Memory MemTable Permanent storage SSTable 1 SSTable 2 SSTable 3 Newer Older Node CommitLog 1 2 3 43 #jeeconf_cassandra
  149. 149. UPDATE Request Memory MemTable Permanent storage SSTable 1 SSTable 2 SSTable 3 Newer Older Node CommitLog 1 2 3 4 43 #jeeconf_cassandra
  150. 150. UPDATE Request Memory MemTable Permanent storage SSTable 1 SSTable 2 SSTable 3 Newer Older Node CommitLog 1 2 3 4 5 43 #jeeconf_cassandra
  151. 151. DELETE 44 #jeeconf_cassandra
  152. 152. DELETE https://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlDelete.html 44 #jeeconf_cassandra
  153. 153. DELETE 45 #jeeconf_cassandra
  154. 154. DELETE 45 #jeeconf_cassandra Update flow *
  155. 155. TOMBSTONES 46 #jeeconf_cassandra http://shipoffools.wikia.com/wiki/File:Tombstone.png
  156. 156. TOMBSTONES Overhead 46 #jeeconf_cassandra http://shipoffools.wikia.com/wiki/File:Tombstone.png
  157. 157. TOMBSTONES 47 #jeeconf_cassandra
  158. 158. TOMBSTONES Remove 47 #jeeconf_cassandra
  159. 159. TOMBSTONES Remove Null 47 #jeeconf_cassandra
  160. 160. TOMBSTONES Remove Null TTL 47 #jeeconf_cassandra
  161. 161. CASSANDRA To be or not to be? #jeeconf_cassandra
  162. 162. 49 SUMMARY #jeeconf_cassandra
  163. 163. RECOMMENDATIONS https://youtu.be/pAGESQo5IjI Cassandra UnderThe Hood by Andriy Rymar 50 #jeeconf_cassandra
  164. 164. THANKYOU My contacts : Email : andriyrav@gmail.com Q / A 51 Twitter : @AndriyRymar #jeeconf_cassandra

×