cassandra, web scale no sql data platform
DESCRIPTION
WebCamp Zagreb 2014, Cassandra, web scale no sql data platform presentation by Marko Švaljek.TRANSCRIPT
CASSANDRAWEB-SCALE NOSQL DATA PLATFORM
/ Marko Švaljek @msvaljek
0
ABOUT MESoftware Developer at KapschZagreb Cassandra Meetup
NUMBERS25% of the Fortune 100 use itApple - 75 000 nodes, 10 PB of dataNetflix - 2500 nodes, 1 trillion req/dayDataStax - professional Cassandra supportMeetup - 167 Groups, 114 Cities, 41 Countries
FUN PART
Android TV Box
Arduino
FUN PART
Android TV Box
Arduino
BREWER'S CAP THEOREMAvailability
Partition ToleranceConsistency
CA AP
CP
nodes can fail
same data for all network fails
RDBMS Cassandra
MongoDB
CONSISTENT HASHING - 1hash_function: row_key -> [0 .. 99]
A
BC
D0
25
50
75
CONSISTENT HASHING - 2Murmur3: row_key -> -263 to 263-1
A
B C
D
hash(C")
hash(A")
hash(D")
hash(B")
CONSISTENT HASHING - 3num_tokens: 256
virtual nodes
GOSSIPA
C
D
H B
F
E is down
G is down
12
3
CLIENT REQUESTSA
C
BDClient
CoordinatorNode
quorum =replication_factor
2+ 1
WRITE PATH
Memory
Disk
Commit log
memtable
Data
SSTable
memtableFlush
Inde
x
COMPACTION
Removetombstones
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
Merge
Uncompacted data
- - - - -
- - - - -
- - - - -
Latest data entries
- - - - -
- - - - -
- - - - -
Compacted data
Consolidate
BLOOM FILTER
1 1 1 0 1 1 0 0 0 1 0 1
A B C
D
✓ ✓ ✗
READING FROM SSTABLEData?
Memory
Disk
Read Bloom Filter
Key Cache
DataSSTable
Data not in filter Data is in filter
DATA ORGANIZATIONKeyspace
Column family (table)
Row ...Column Column
Timpestamp Timpestamp
Value Value
KEYSPACECREATE KEYSPACE used_cars WITH replication = { 'class': 'SimpleStrategy', 'replication_factor' : 1};
CREATE KEYSPACE used_cars WITH replication = { 'class': 'NetworkTopologyStrategy', 'DC1' : 1, 'DC2' : 3};
TABLESCREATE TABLE users ( username text PRIMARY KEY, password text, first_name text, last_name text, state text);
INSERTINGINSERT INTO offers (username, date, price, brand, model, year, mileage, color) VALUES ('jsmith', '2014-09-19 11:35:20', 6000, 'BMW', '120i', 2010, 40000, 'Black');
UPDATEUPDATE offers SET brand = 'Ford', model = 'Mustang' WHERE username = 'jdoe' AND date = '2014-08-11 17:12:32+0200';
Use upsert (insert same data) when possibleNO updating of primary key fields
DELETEDELETE FROM offers WHERE username = 'jdoe' AND date = '2014-08-11 17:12:32+0200';
tombstones
SELECTSELECT username, date, brand, model FROM offers WHERE username = 'jsmith';
username | date | brand | model----------+--------------------------+-------+------- jsmith | 2014-05-11 01:22:11+0200 | Ford | Orion jsmith | 2014-09-09 11:35:20+0200 | BMW | 118d jsmith | 2014-09-19 11:35:20+0200 | BMW | 120i jsmith | 2014-09-20 17:12:32+0200 | Audi | A6
APPS15+ languages supported
var cql = require('node-cassandra-cql');
var client = new cql.Client({ hosts: ['127.0.0.1:9042'], keyspace: 'test'});
client.execute('SELECT * FROM test_table', [], function(err, result) { for (var i = 0; i < result.rows.length; i++) { console.log(result.rows[i].get('id')); console.log(result.rows[i].get('test_value')); } });
THANK YOU!
Q & A
@msvaljek