52
A tunably consistent, highly- available, Distributed Database Tom Wilkie @tom_wilkie Founder & VP Engineering, Acunu 1

Progressive NOSQL: Cassandra

  • Upload
    acunu

  • View
    1.219

  • Download
    2

Embed Size (px)

DESCRIPTION

Tom Wilkie's talk at Progressive NOSQL conference in London on 11/05/12.

Citation preview

Page 1: Progressive NOSQL: Cassandra

A tunably consistent, highly-available, Distributed Database

Tom Wilkie @tom_wilkieFounder & VP Engineering, Acunu

1

Page 2: Progressive NOSQL: Cassandra

• Overview

• Distribution

• Storage

• Datamodel

• Usecases

2

Page 3: Progressive NOSQL: Cassandra

• Overview

• Distribution

• Storage

• Datamodel

• Usecases

3

Page 4: Progressive NOSQL: Cassandra

• A distributed database for Big Data

• Scale out on commodity servers

• Best of bread performance

• Multi-master architecture, no SPOF

• Powerful multi data centre support

4

4

Page 5: Progressive NOSQL: Cassandra

5

5

Page 6: Progressive NOSQL: Cassandra

BigTable, 2006 Dynamo, 2007

Open sourced, 2008

Incubator, 2009TLP, 2010v1.0 2011

6

Page 7: Progressive NOSQL: Cassandra

BigTable: ...

• Simple but powerful datamodel

• Write-optimised storage system

• Consistent, available but not partition tolerant

• Master-slave distribution system, SPOF

http://goo.gl/7T1Ej

7

7

Page 8: Progressive NOSQL: Cassandra

Dynamo: ...

• Sophisticated distribution system with tradable consistency and availability

• Over-simple datamodel

http://goo.gl/Q80b4

8

8

Page 9: Progressive NOSQL: Cassandra

• Overview

• Distribution

• Storage

• Datamodel

• Usecases

9

Page 10: Progressive NOSQL: Cassandra

Distribution: Consistent Hashing

10

r1, c1 → v1r2, c2 → v2r3, c3 → v3

10

Page 11: Progressive NOSQL: Cassandra

Distribution: Scaling

11

11

Page 12: Progressive NOSQL: Cassandra

Distribution: Scaling

12

12

Page 13: Progressive NOSQL: Cassandra

Distribution: Scaling

• .

13

13

Page 14: Progressive NOSQL: Cassandra

Distribution: Scaling

14

14

Page 15: Progressive NOSQL: Cassandra

Distribution: Scaling

15

15

Page 16: Progressive NOSQL: Cassandra

Distribution: Replication

16

r1, c1 → v1

16

Page 17: Progressive NOSQL: Cassandra

Distribution: Replication

17

17

Page 18: Progressive NOSQL: Cassandra

Distribution: ConsistencyTuneable, per-operation consistency

Timestamped values, N > R + W

18

RW

18

Page 19: Progressive NOSQL: Cassandra

Distribution: Read Repair

19

19

Page 20: Progressive NOSQL: Cassandra

Distribution: Read Repair

20

20

Page 21: Progressive NOSQL: Cassandra

Distribution: Read Repair

21

21

Page 22: Progressive NOSQL: Cassandra

Distribution: Read Repair

22

22

Page 23: Progressive NOSQL: Cassandra

• Overview

• Distribution

• Storage

• Datamodel

• Usecases

23

Page 24: Progressive NOSQL: Cassandra

Writing to Cassandra

Row Key Column Column Column Column

24

24

Page 25: Progressive NOSQL: Cassandra

Memtable

In the JVM

On disk Commit log

Writing to Cassandra

25

Row Colu Colu Colu Colu

25

Page 26: Progressive NOSQL: Cassandra

Writing to Cassandra

Full Memtable

26

Commit log

In the JVM

On disk

26

Page 27: Progressive NOSQL: Cassandra

New Memtable

SSTable

27

Writing to CassandraIn the JVM

On disk Commit log

27

Page 28: Progressive NOSQL: Cassandra

Writing to Cassandra

28

SSTableOn disk Commit log SSTable

SSTableSSTableSSTableSSTable

28

Page 29: Progressive NOSQL: Cassandra

Writing to Cassandra

29

SSTable

On disk Commit log

29

Page 30: Progressive NOSQL: Cassandra

Reading from Cassandra

30

Page 31: Progressive NOSQL: Cassandra

MemtableIn the JVM

On disk SSTableCommit log

SSTableindex

Bloom filter

Row cacheOff-heap (no GC)

Key cache

1

2

3 4 5

6

31

31

Page 32: Progressive NOSQL: Cassandra

• Overview

• Distribution

• Storage

• Datamodel

• Usecases

32

Page 33: Progressive NOSQL: Cassandra

SQL Cassandra

Keyspace

Column Family

Database

Tablerow/ col_1 col_1

row/key col_1 col_1row/key col_1 col_2

33

33

Page 34: Progressive NOSQL: Cassandra

col1 col2 col3 col4 col5 col6 col7row1 x x xrow2 x x x x xrow3 x x x x xrow4 x x x xrow5 x x x xrow6 xrow7 x x x

34

34

Page 35: Progressive NOSQL: Cassandra

alice: { m2: { Sender: bob, Subject: ‘paper!’, ... }}

bob: { m1: { Sender: alice, Subject: ‘rock?’, ... }}

charlie: { m1: { Sender: alice, Subject: ‘rock?’, ... }, m2: { Sender: bob, Subject: ‘paper!’, ... }}

35

35

Page 36: Progressive NOSQL: Cassandra

• Overview

• Distribution

• Storage

• Datamodelling

• Usecases

36

Page 37: Progressive NOSQL: Cassandra

37Confidential 6

Location ServicesWeb, SCM, Retail

Fraud Detection

Cloud Monitoring

Oil/Gas Sensors

Social MediaSocial Gaming Ad Marketplaces

Smart Metering

Perfect for high velocity data

Wednesday, 25 April 1237

Page 38: Progressive NOSQL: Cassandra

Not Covered...

• Distribution: Hinted Handoff, Anti-entropy repair, Counter distribution

• Storage: Counter storage, different compaction strategies, partitioning etc

• Datamodel: de-normalisation, TTLs, secondary indexes, CQL, super-columns, schema optional

• Operations: backup, nodetool, performance tuning

• Integration: Hadoop, Client Libraries etc

38

38

Page 39: Progressive NOSQL: Cassandra

• Distributed, scalable database

• Opensource, widely used

• Tunably consistent

• Highly-available

• Partition tolerant

• Write-optimised

• Schema-optional

39

Page 40: Progressive NOSQL: Cassandra

Data Platform

40

Page 41: Progressive NOSQL: Cassandra

Commodity Hardware

Apache Cassandra

Acunu Storage Engine

Control Center

Data driven applications Web UI

Configured and tuned OS

Acunu Analytics

Data Platform

41

Page 42: Progressive NOSQL: Cassandra

Control Center

“I've had the EC2 instance running for a little while and I have to say, I'm impressed. You guys have done well with

this product.”- Lloyd, JustDevelopIt

42

Page 43: Progressive NOSQL: Cassandra

Control Center

“The new UI has been critical in helping us work out what is wrong in our code”

- Matt, TellyBug

43

Page 44: Progressive NOSQL: Cassandra

Castle: Built for Big Data

• Storage engine optimized for large slow disks, many cores, Big Data workloads

• Enterprise density on commodity hardware

• Lightning disk rebuilds:10x faster than RAID

Acunu Kernel

Userspace

Doubling Arrays

arrays range

querieskey

insert

insertqueues

Bloom filters

x

user

spac

ein

terfa

ceke

rnel

spac

ein

terfa

cedo

ublin

g a

rray

map

ping

laye

rm

odlis

t btre

em

appi

ng la

yer

bloc

k m

appi

ng &

cach

eing

laye

r

"Extent" layerextent

allocatorfreespacemanager

btreerange

queries

key get

key insert

Version tree

Streaming interfacekey

insertkey get

bufferedvalue get

bufferedvalue insert

range queries

Cache

flusher

extent blockcache

prefetcher

In-kernel workloads

shared buffersasync, sharedmemory ring

Shared memory interfacekeys

values

Arrays

value arrays

btree

key get

arraysmanagement

merges

• Opensource (GPLv2, MIT for user libraries)

• http://bitbucket.org/acunu

• Loadable Kernel Module, targeting CentOS’s 2.6.18

• http://www.acunu.com/blogs/andy-twigg/why-

Castle

http://goo.gl/gzihe

44

44

Page 45: Progressive NOSQL: Cassandra

45

Page 46: Progressive NOSQL: Cassandra

0

1

2

3

4

5

RAID10, 8 Disks RAID5, 8 Disks RDA, 8 Disks RDA, 15 Disks

Re

bu

ild

Tim

e (

Ho

urs

)

Rebuild time

46

46

Page 47: Progressive NOSQL: Cassandra

Analytics

• Simple, real-time, incremental analytics

• Push processing into ingest phase

events

counterupdates

Acunu Analytics

Click streamSensor data

etc

47

Page 49: Progressive NOSQL: Cassandra

Introduction

49

Live & historicalaggregates...

49

Page 50: Progressive NOSQL: Cassandra

50

Realtime trends...

50

Page 51: Progressive NOSQL: Cassandra

51

Drill downsand roll ups

51

Page 52: Progressive NOSQL: Cassandra

52

Solution Con

Scalability$$$

Not realtimeInefficient Recomputation

Spartan query semantics => complex, DIY solutions

52