Introduction to Apache Cassandra
展开查看详情
1. Introduction to Apache Cassandra™ Patrick McFadin VP Developer Relations, DataStax @PatrickMcFadin 1
2. Cloud Applications 2
3. You may consider one of these …or one of these 3
4. “The definition of bad insanity engineering is doing the same thing over and over and expecting a different result” –Who knows 4
5. Sharding shard 1 shard 2 shard 3 shard 4 App Server client 5
6. Sharding Customer Name A-F G-M N-T U-Z App Server client 6
7. 2005 - It's broke! 7
8. June 29, 2007 8
9. Dynamo Paper(2007) • How do we build a data store that is: – Reliable – Performant – “Always On” • Nothing new and shiny • 24 papers cited Evolutionary. Real. Computer Science Also the basis for Riak and Voldemort 9
10. BigTable(2006) • Richer data model • 1 key. Lots of values • Fast sequential access • 38 Papers cited 10
11. Cassandra(2008) • Distributed features of Dynamo • Data Model and storage from BigTable • February 17, 2010 it graduated to a top-level Apache project 11
12. Basic Architecture 12
13. Node Server 13
14. Token Server •Each partition is a 64 bit value •Consistent hash between -263 to +263-1 •Each node owns a range of those Token Range values 0 … •The token is the beginning of that range to the next node’s token value Data •Virtual Nodes break these down further 14
15. Server The cluster Token Range 0-100 0 0-100 15
16. Server The cluster Token Range 0-50 0 0-50 51 51-100 Server 51-100 16
17. Server The cluster Token Range 0-25 0 0-25 Server Server 26 26-50 51 51-75 76 76-100 51-75 26-50 Server 76-100 17
18. Replication DC1 10.0.0.1 10.0.0.1 00-25 10.0.0.4 10.0.0.2 76-100 26-50 10.0.0.3 DC1: RF=1 51-75 Node Primary 10.0.0.1 00-25 10.0.0.2 26-50 10.0.0.3 51-75 10.0.0.4 76-100 18
19. Replication DC1 10.0.0.1 00-25 76-100 10.0.0.4 10.0.0.2 76-100 26-50 51-75 00-25 10.0.0.3 DC1: RF=2 51-75 26-50 Node Primary Replica 10.0.0.1 00-25 76-100 10.0.0.2 26-50 00-25 10.0.0.3 51-75 26-50 10.0.0.4 76-100 51-75 19
20. Replication DC1 10.0.0.1 00-25 76-100 51-75 10.0.0.4 10.0.0.2 76-100 26-50 51-75 00-25 26-50 76-100 10.0.0.3 DC1: RF=3 51-75 26-50 00-25 Node Primary Replica Replica 10.0.0.1 00-25 76-100 51-75 10.0.0.2 26-50 00-25 76-100 10.0.0.3 51-75 26-50 00-25 10.0.0.4 76-100 51-75 26-50 20
21. Consistency DC1 Client 10.0.0.1 00-25 76-100 51-75 Write to partition 15 10.0.0.4 10.0.0.2 76-100 26-50 51-75 00-25 26-50 76-100 10.0.0.3 DC1: RF=3 51-75 26-50 00-25 Node Primary Replica Replica 10.0.0.1 00-25 76-100 51-75 10.0.0.2 26-50 00-25 76-100 10.0.0.3 51-75 26-50 00-25 10.0.0.4 76-100 51-75 26-50 21
22. Consistency level Consistency Level Number of Nodes Acknowledged One One replica acknowledges read One replica commits write Quorum 51% nodes agree on read or commit write Local Quorum 51% in local DC 22
23. Consistency DC1 Client 10.0.0.1 00-25 76-100 51-75 Write to partition 15 CL= One 10.0.0.4 10.0.0.2 76-100 26-50 51-75 00-25 26-50 76-100 10.0.0.3 DC1: RF=3 51-75 26-50 00-25 Node Primary Replica Replica 10.0.0.1 00-25 76-100 51-75 10.0.0.2 26-50 00-25 76-100 10.0.0.3 51-75 26-50 00-25 10.0.0.4 76-100 51-75 26-50 23
24. Consistency DC1 Client 10.0.0.1 00-25 76-100 51-75 Write to partition 15 CL= One 10.0.0.4 10.0.0.2 76-100 26-50 51-75 00-25 26-50 76-100 10.0.0.3 DC1: RF=3 51-75 26-50 00-25 Node Primary Replica Replica 10.0.0.1 00-25 76-100 51-75 10.0.0.2 26-50 00-25 76-100 10.0.0.3 51-75 26-50 00-25 10.0.0.4 76-100 51-75 26-50 24
25. Consistency DC1 Client 10.0.0.1 00-25 76-100 51-75 Write to partition 15 CL= Quorum 10.0.0.4 10.0.0.2 76-100 26-50 51-75 00-25 26-50 76-100 10.0.0.3 DC1: RF=3 51-75 26-50 00-25 Node Primary Replica Replica 10.0.0.1 00-25 76-100 51-75 10.0.0.2 26-50 00-25 76-100 10.0.0.3 51-75 26-50 00-25 10.0.0.4 76-100 51-75 26-50 25
26. Multi-datacenter AWS GCP Client 10.0.0.1 10.1.0.1 00-25 00-25 76-100 76-100 51-75 51-75 Write to partition 15 10.0.0.4 10.0.0.2 10.1.0.4 10.1.0.2 76-100 26-50 76-100 26-50 51-75 00-25 51-75 00-25 26-50 76-100 26-50 76-100 10.0.0.3 10.1.0.3 51-75 51-75 26-50 26-50 00-25 00-25 DC1: RF=3 DC2: RF=3 26
27. Multi-datacenter AWS GCP Client 10.0.0.1 10.1.0.1 00-25 00-25 76-100 76-100 51-75 51-75 Write to partition 15 10.0.0.4 10.0.0.2 10.1.0.4 10.1.0.2 76-100 26-50 76-100 26-50 51-75 00-25 51-75 00-25 26-50 76-100 26-50 76-100 10.0.0.3 10.1.0.3 51-75 51-75 26-50 26-50 00-25 00-25 DC1: RF=3 DC2: RF=3 27
28. Multi-datacenter AWS GCP Client 10.0.0.1 10.1.0.1 00-25 00-25 76-100 76-100 51-75 51-75 Write to partition 15 10.0.0.4 10.0.0.2 10.1.0.4 10.1.0.2 76-100 26-50 76-100 26-50 51-75 00-25 51-75 00-25 26-50 76-100 26-50 76-100 10.0.0.3 10.1.0.3 51-75 51-75 26-50 26-50 00-25 00-25 DC1: RF=3 DC2: RF=3 28
29. Data Modeling 29