71
HDB++: HIGH AVAILABILITY WITH l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg Page 1

HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

HDB++: HIGH

AVAILABILITY WITH

l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg Page 1

Page 2: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

OVERVIEW

• What is Cassandra (C*)?

• Who is using C*?

• CQL

• C* architecture

• Request Coordination

• Consistency

• Monitoring tool

• HDB++

Page 2 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Page 3: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

OVERVIEW

• What is Cassandra (C*)?

• Who is using C*?

• CQL

• C* architecture

• Request Coordination

• Consistency

• Monitoring tool

• HDB++

Page 3 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Page 4: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

WHAT IS CASSANDRA?

• Mythology: an excellent

Oracle not believed.

• A massively scalable open

source NoSQL (Not Only

SQL) database

• Created by Facebook

• Open Source since 2008

• Apache license, 2.0,

compatible with GPLV3

Page 4 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Page 5: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

WHAT IS CASSANDRA?

• Peer to peer architecture

• No Single Point of Failure

• Replication

• Continuous Availability

• Multi Data Centers support

• 100s to 1000s nodes

• Java

• High Write Throughput

• Read efficiency

Page 5 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Page 7: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

OVERVIEW

• What is Cassandra (C*)?

• Who is using C*?

• CQL

• C* architecture

• Request Coordination

• Consistency

• Monitoring tool

• HDB++

Page 7 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Page 8: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

WHO IS USING CASSANDRA?

Page 8 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Page 9: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

OVERVIEW

• What is Cassandra (C*)?

• Who is using C*?

• CQL

• C* architecture

• Request Coordination

• Consistency

• Monitoring tool

• HDB++

Page 9 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Page 10: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CASSANDRA QUERY LANGUAGE

• CQL: Cassandra Query Language

• Very similar to SQL

• But restrictions and limitations • JOIN requests are forbidden • No subqueries • String comparisons are limited (when not using SOLR)

select * from my_table where mystring like ‘%tango%’;

• No OR operator • Can only apply a WHERE condition on an indexed column

(or primary key)

Page 10 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Page 11: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CASSANDRA QUERY LANGUAGE

• Collections (64K Limitation): • list • set • map

• TTL

• INSERT = UPDATE (UPSERT)

• Doc: http://www.datastax.com/documentation/cql/3.1/cql/cql_intro_c.html

• cqlsh

Page 11 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Page 12: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CASSANDRA QUERY LANGUAGE

CREATE TABLE IF NOT EXISTS att_scalar_devdouble_ro (

att_conf_id timeuuid,

period text,

data_time timestamp,

data_time_us int,

value_r double,

quality int,

error_desc text,

PRIMARY KEY ((att_conf_id ,period),data_time,data_time_us)

)

WITH comment='Scalar DevDouble ReadOnly Values Table‘;

Page 12 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Page 13: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CASSANDRA QUERY LANGUAGE

CREATE TABLE IF NOT EXISTS att_scalar_devdouble_ro (

att_conf_id timeuuid,

period text,

data_time timestamp,

data_time_us int,

value_r double,

quality int,

error_desc text,

PRIMARY KEY ((att_conf_id ,period),data_time,data_time_us)

);

Page 13 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Partition key Clustering columns

Page 14: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

OVERVIEW

• What is Cassandra (C*)?

• Who is using C*?

• CQL

• C* architecture

• Request Coordination

• Consistency

• Monitoring tool

• HDB++

Page 14 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Page 15: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CASSANDRA ARCHITECTURE

• Node: one Cassandra instance (Java process)

Page 15 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1 Node 2

Node 5 Node 6

Node 3 Node 4

Node 7 Node 8

Token Range +263-1 -263

Page 16: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CASSANDRA ARCHITECTURE

• Partition: ordered and replicable unit of data on a

node identified by a token

• Partitioner (based on mumur3 algorithm by default)

will distribute the data across the nodes.

Page 16 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1 Node 2

Node 5 Node 6

Node 3 Node 4

Node 7 Node 8

Token Range +263-1 -263

Page 17: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CASSANDRA ARCHITECTURE

Page 17 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

• Rack: logical set of nodes

Rack 1

Rack 2 Rack 4

Rack 3 Node 1

Node 5 Node 7

Node 3 Node 2

Node 6

Node 4

Node 8

Token Range -263 +263-1

Page 18: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CASSANDRA ARCHITECTURE

Page 18 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

• Data Center: logical set of racks

Rack 1

Rack 2 Rack 4

Rack 3 Node 1

Node 5 Node 7

Node 3 Node 2

Node 6

Node 4

Node 7

Data Center 1 Data Center 2 Token Range +263-1 -263

Page 19: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

REQUEST COORDINATION

Page 19 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

• Cluster: full set of nodes which maps to a single

complete token ring

Rack 1

Rack 2 Rack 4

Rack 3 Node 1

Node 5 Node 7

Node 3 Node 2

Node 6

Node 4

Node 7

Data Center 1 Data Center 2

Cassandra Cluster

Token Range +263-1 -263

Page 20: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

OVERVIEW

• What is Cassandra (C*)?

• Who is using C*?

• CQL

• C* architecture

• Request Coordination

• Consistency

• Monitoring tool

• HDB++

Page 20 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Page 21: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

REQUEST COORDINATION

Page 21 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

• Coordinator: the node chosen by the client to

receive a particular read or write request to its

cluster

Data Center 1 Node 1

Node 2 Node 4

Node 3

Client

Page 22: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

REQUEST COORDINATION

Page 22 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

• Coordinator: the node chosen by the client to

receive a particular read or write request to its

cluster

Data Center 1 Node 1

Node 2 Node 4

Node 3

Client

Coordinator

Page 23: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

REQUEST COORDINATION

Page 23 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

• Coordinator: the node chosen by the client to

receive a particular read or write request to its

cluster

Data Center 1 Node 1

Node 2 Node 4

Node 3

Client

Read/Write

Coordinator

Page 24: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

REQUEST COORDINATION

Page 24 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

• Any node can coordinate any request

• Each client request may be coordinated by a

different node

Data Center 1 Node 1

Node 2 Node 4

Node 3

Client

Acknowledge

Coordinator

No Single Point of

Failure

Page 25: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

REQUEST COORDINATION

Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

• The Cassandra driver chooses the coordinator node

• Round-Robin pattern, token-aware pattern

• Client library to manage requests

• Many open source drivers for many programming languages

Node 1

Node 2 Node 4

Node 3

Client Coordinator Driver

Java Python C++

C# Node.js

PHP

Perl

Go Clojure

Haskell

R (GNU S) Ruby Scala

Erlang ODBC

Rust

Page 26: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

REQUEST COORDINATION

Page 26 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

• The coordinator manages the

replication process

• Replication Factor (RF): onto

how many nodes should a

write be copied

• The write will occur on the

nodes responsible for that

partition

• 1 ≤ RF ≤ (#nodes in cluster)

• Every write is time-stamped

Node 1

Node 2 Node 4

Node 3

Coordinator

Client Driver

RF=3

Page 27: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

REQUEST COORDINATION

Page 27 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2 Node 4

Node 3

Coordinator

Client Driver

RF=3

• The coordinator manages the

replication process

• Replication Factor (RF): onto

how many nodes should a

write be copied

• The write will occur on the

nodes responsible for that

partition

• 1 ≤ RF ≤ (#nodes in cluster)

• Every write is time-stamped

Page 28: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

OVERVIEW

• What is Cassandra (C*)?

• Who is using C*?

• CQL

• C* architecture

• Request Coordination

• Consistency

• Monitoring tool

• HDB++

Page 28 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Page 29: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY

Page 29 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 4

• The coordinator applies the Consistency Level (CL)

• Consistency Level (CL): Number of nodes which must

acknowledge a request

• Examples of CL: • ONE • TWO • THREE • ANY • ALL (Not recommended) • QUORUM (= RF/2 + 1) • EACH_QUORUM • LOCAL_QUORUM

• CL may vary for each request

• On success, the coordinator notifies the client (with most

recent partition data in case of read request)

Page 30: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY ONE - READ - SINGLE DC

Page 30 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

Direct Read Request

Digest Read Request (Hash) +

eventual read repair

Page 31: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY ONE - READ - SINGLE DC

Page 31 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

Direct Read Request

Digest Read Request (Hash) +

eventual read repair

Page 32: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY ONE – READ - SINGLE DC

Page 32 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

Direct Read Request

Digest Read Request (Hash) +

eventual read repair

Page 33: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY ONE - READ - SINGLE DC

Page 33 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

Direct Read Request

Digest Read Request (Hash) +

eventual read repair

Page 34: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY QUORUM – READ - SINGLE DC

Page 34 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

Direct Read Request

Digest Read Request (Hash)

Page 35: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY QUORUM – READ - SINGLE DC

Page 35 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

Direct Read Request

Digest Read Request (Hash)

Page 36: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY QUORUM – READ - SINGLE DC

Page 36 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

Direct Read Request

Digest Read Request (Hash)

Page 37: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY QUORUM – READ - SINGLE DC

Page 37 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

Direct Read Request

Digest Read Request (Hash)

In case of inconsistency: the

most recent data is returned

Page 38: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY QUORUM – READ - SINGLE DC

Page 38 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

Direct Read Request

Digest Read Request (Hash)

Read repair if needed

Page 39: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY ONE – WRITE - SINGLE DC

Page 39 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

Write Request

Page 40: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY ONE – WRITE - SINGLE DC

Page 40 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

ACK

ACK

Page 41: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY ONE – WRITE - SINGLE DC

Page 41 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

Write Request

Page 42: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY ONE – WRITE - SINGLE DC

Page 42 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

ACK

ACK

SUCCESS

Page 43: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY ONE – WRITE - SINGLE DC

Page 43 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

ACK

ACK

hint max_hint_window_in_ms

property in

cassandra.yaml file

Hinted handoff mechanism

SUCCESS

Page 44: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY ONE – WRITE - SINGLE DC

Page 44 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

Write Request

hint max_hint_window_in_ms

property in

cassandra.yaml file

Hinted handoff mechanism

Page 45: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY ONE – WRITE - SINGLE DC

Page 45 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

Write Request

hint max_hint_window_in_ms

property in

cassandra.yaml file

Hinted handoff mechanism

Page 46: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY ONE – WRITE - SINGLE DC

Page 46 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

Hinted handoff mechanism

Page 47: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY

Page 47 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 4

if node downtime > max_hint_window_in_ms

Anti-entropy node repair

Page 48: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY QUORUM – WRITE - SINGLE DC

Page 48 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

Write Request

Page 49: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY QUORUM – WRITE - SINGLE DC

Page 49 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

ACK

ACK

Page 50: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY QUORUM – WRITE - SINGLE DC

Page 50 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

ACK

ACK

SUCCESS

Page 51: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY QUORUM – WRITE - SINGLE DC

Page 51 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

Write Request

Page 52: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY QUORUM – WRITE - SINGLE DC

Page 52 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

ACK

ACK

SUCCESS

Page 53: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY QUORUM – WRITE - SINGLE DC

Page 53 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

Write Request

Page 54: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY QUORUM – WRITE - SINGLE DC

Page 54 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Node 1

Node 2

Node 4

Node 3

Coordinator

Client Driver

RF=3

Node 5

Node 6

ACK

ACK

FAILURE

Page 55: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY LOCAL QUORUM – WRITE - MULTI DC

Page 55 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Client Driver

Node 5

Write Request

Node 1

Node 2

Node 4

Node 3

RF=3

Node 6

Node 1

Node 2

Node 4

Node 3

RF=2

Node 5

DC1 DC2

Coordinator

Page 56: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONSISTENCY LOCAL QUORUM – WRITE - MULTI DC

Page 56 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Coordinator

Client Driver

Node 5

Node 1

Node 2

Node 4

Node 3

RF=3 Node 6

Node 1

Node 2

Node 4

Node 3

RF=2

Node 5

DC1 DC2

ACK

ACK

SUCCESS

ACK

Page 57: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

OVERVIEW

• What is Cassandra (C*)?

• Who is using C*?

• CQL

• C* architecture

• Request Coordination

• Consistency

• Monitoring tool

• HDB++

Page 57 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Page 58: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

MONITORING TOOL: OPSCENTER

Page 58 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

http://cassandra2:8888

Page 59: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

OVERVIEW

• What is Cassandra (C*)?

• Who is using C*?

• CQL

• C* architecture

• Request Coordination

• Consistency

• Monitoring tool

• HDB++

Page 59 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Page 60: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

HDB++

Page 60 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

hdb++es-srv hdb++cm-srv

libhdb++

libhdb++cassandra

<<implements>>

libhdb++mysql

<<implements>>

hdb++es-srv hdb++es-srv

hdb++es-srv

hdb++es-srv hdb++cm-srv hdb++es-srv

hdb++es-srv hdb++es-srv

<<use>> <<use>>

MySQL Cassandra Cassandra Cassandra

Page 61: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONCLUSION: C* PROS

Page 61 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

• High Availability

• SW upgrade with no downtime

• HW failure

• Linear Scalability

• Need more performances? => Add nodes

• Big community with industrial support

Page 62: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONCLUSION: C* PROS

Page 62 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

• Can use Apache Spark for analytics (distributed

processing)

• List, Set, Map data types (tuples and user defined

types soon)

• Tries not to let you do actions which do not perform

well

• Backups = snapshot = hard links => very fast

(+Replication)

• Difficult to lose data

• Good fit for time series data

Page 63: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONCLUSION: C* CONS

Page 63 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

• Requires more total disk space and machines

• sstable (C* data files) format can change from one

version to another

• No easy way to come back to a previous version

once the sstables have been converted to a newer

version

• Cannot rename keyspaces or tables easily (not

foreseen in CQL)

• Tedious to modify existing partitions (Needs to

duplicate the data at some point in the process)

Page 64: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CONCLUSION: C* CONS

Page 64 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

• Different way of modeling

• Not designed for huge read requests

• Can be tricky to tune to avoid long GC pauses

• Maintenance: Need to run nodetool repair regularly

if some data are deleted to avoid resurrections

(CPU intensive operation)

• Can take quite some time to redeem disk space

after deletion in some specific cases.

Page 65: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

THE END

Page 66: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

USEFUL LINKS

Page 66 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

• http://cassandra.apache.org

• Planet Cassandra (http://planetcassandra.org)

• Datastax academy (https://academy.datastax.com)

• Cassandra Java Driver getting started

(https://academy.datastax.com/demos/cassandra-java-driver-getting-

started)

• Cassandra C++ Driver: https://github.com/datastax/cpp-driver

• Datastax documentation (http://www.datastax.com/docs)

• Users mailing list: [email protected]

• #Cassandra channel on IRC

(http://webchat.freenode.net/?channels=#Cassandra)

Page 67: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CASSANDRA FUTURE DEPLOYMENT

Page 67 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

DC Prod 1 partition/hour

Keyspace prod RF:3

(write LOCAL_QUORUM)

7200 RPM Disks

Big CPU - 64GB RAM

DC Analytics 1 Keyspace prod RF:3

(read LOCAL_QUORUM)

Keyspace analytics RF:3

(write LOCAL_QUORUM)

SSD Disks

Big CPU – 128 GB RAM

DC Analytics 2 Keyspace analytics RF:5

(read LOCAL_QUORUM)

7200 RPM Disks

Tiny CPU – 32 GB RAM

Page 68: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CASSANDRA FUTURE DEPLOYMENT

Page 68 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

DC Prod 1 partition/hour

Keyspace prod RF:3

(write LOCAL_QUORUM)

7200 RPM Disks

Big CPU - 64GB RAM

DC Analytics 1 Keyspace prod RF:3

(read LOCAL_QUORUM)

Keyspace analytics RF:3

(write LOCAL_QUORUM)

SSD Disks

Big CPU – 128 GB RAM

Page 69: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

CASSANDRA’S NODE-BASED ARCHITECTURE

Page 69 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Page 70: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

BASIC WRITE PATH CONCEPT Page 70

l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Page 71: HDB++: HIGH AVAILABILITY WITHftp.esrf.eu/.../2015_may_solaris/...with_Cassandra.pdf · REQUEST COORDINATION Page 25 l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg • The Cassandra

BASIC READ PATH CONCEPT Page 71

l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg