The document discusses different NoSQL databases and how Cassandra compares to them. It notes that Cassandra uses a Dynamo-inspired architecture with Bigtable-style columns. Cassandra provides better write performance than MySQL through its use of consistent hashing and replication across multiple data centers for high availability. It also offers better read performance than MySQL for large datasets through its use of column-oriented storage.
32. +
Key
• Memtable value
• SSTable value
I/O
disk memory
<k1,obj>
Memtable
disk mem disk
<k1,obj+obj1~3>
Commit Log
client merge
<k1,obj1>
SSTable 1
I/O <k1,obj2>
SSTable 2
<k1,obj3>
SSTable 3
33. +
( / 99.9%)
1/9
Better
read write
avg. 6.16 ms
Number of queries
read
Latency (ms)
write write: 2.0 ms
avg. 0.69 ms read: 86.9 ms
99.9 percentile
Latency (ms)
34. Max. QPS for 40 Clients Bigtable
MySQL
40000
Redis
35000
30000
25000
20000
15000
10000
5000 Better
0
(qps) Write Only Write Heavy Read Heavy Read Only
38.
• put (key, cf)
OK
• get (key)
• getRangeSlice (startWith, engWith, maxResults)
• truncate/dropTable/dropDB
• secondaryIndex
• expire
• counter (Cassandra-0.8 )
39. Cassandra
• : keyspace – columnfamily – column
• key/value( )
•
ColumnFamily SSTable <key, value>
value: columnFamily
Keyspace
ColumnFamily A ColumnFamily B
key col gender age region key col visits plan
sato male 17 [null] sato 18 Gold
suzuki female 21 Tokyo suzuki 214 Bronze
Bigtable (Cassandra)
41. Cassandra MySQL Redis
keyspace database db
column family table record
column field
42. database db
table A table B key values
key values key values
A:sato …
sato gender;male;age;17 sato visits;18;plan;Gold
B:ito …
suzuki gender;female;age; suzuki visits;
A:suzuki …
21;region;Tokyo 214;plan;Bronze
B:tanaka …
RDB (MySQL)
KVS (Redis)
keyspace
columnfamily A columnfamily B
key col gender age region key col visits plan
sato male 17 [null] sato 18 Gold
suzuki female 21 Tokyo suzuki 214 Bronze
Bigtable (Cassandra)
43.
• MySQL database = keyspace :=>
MyCassandra (MySQL)
• MySQL table = keyspace :=>
Cassandra Bigtable (Cassandra)
keyspace
columnfamily A columnfamily B
key col gender age region key col visits plan
sato male 17 [null] sato 18 Gold
suzuki female 21 Tokyo suzuki 214 Bronze
MySQL
gender age region visits plan
sato male 17 [null] 18 Gold
Table
suzuki female 21 Tokyo 214 Bronze
44.
1
secondary index
rowKey CF counter secondary token
index
Serialized
Object
Key Value
Key-Value KVS …
45.
•
•
•
write query read query
sync async async sync
W R W R
Bigtable MySQL Bigtable MySQL
46. • W:
• R:
• RW:
write query
sync async
W R
Quorum Protocol: ( )+ ( )> ( )
•
write read
W RW R
47. • :
• R:
• RW:
=3, =2
Client
W:RW:R = 1:1:1 Proxy
1)
2) W, RW
ACK
ACK
3a)
W RW R
3b) R
ACK
: max (W, RW)
48. • :
• R:
• RW:
=3, =2
W:RW:R = 1:1:1 Client
Proxy
1)
2) R, RW
3a)
3b) or
W
W RW R
4)
.
(Cassandra read repair )
: max (R, RW)
53. • /
• hash/B+tree
•
class persistence algorithm lock unit
ProtoHashDB volatile hash whole (rwlock)
ProtoTreeDB red black tree whole (rwlock)
StashDB hash record (rwlock)
CacheDB hash record (mutex)
GrassDB B+ tree page (rwlock)
HashDB persistent hash record (rwlock)
TreeDB B+ tree page (rwlock)
DirDB undefined record (rwlock)
ForestDB B+ tree page (rwlock)
54. MyCassandra-0.2.2
• secondaryIndex
MySQL MongoDB
MyCassandra-0.3.0
• Based on Cassandra-0.8
• Atomic counter
• Brisk (Hadoop + Cassandra)…