Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) |...

87
Operations, consistency and failover for multi DC clusters

Transcript of Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) |...

Page 1: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations, consistency and failover for multi DC clusters

Page 2: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

CASSANDRA SUMMIT - SEPTEMBER 2016

Alexander Dejanovski@alexanderdeja

Consultantwww.thelastpickle.com

Datastax MVP for Apache Cassandra

Licensed under a Creative Commons Attribution-NonCommercial 3.0 New Zealand License

Page 3: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

About The Last Pickle

We help people deliver and improve Apache Cassandra based solutions.

With staff in 5 countries and over 50 years combined experience in Apache Cassandra.

Page 4: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016
Page 5: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016
Page 6: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

DC = DataCenter

www.thelastpickle.com

Page 7: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Why multi DC ?ConsistencyOperations

Failover

www.thelastpickle.com

Page 8: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Multi DC use cases

Load Balancing&

Disaster recovery

www.thelastpickle.com

Page 9: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Multi DC use cases

www.thelastpickle.com

Page 10: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Multi DC use cases

Geographical colocationwith clients

www.thelastpickle.com

Page 11: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Multi DC use cases

www.thelastpickle.com

Page 12: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Multi DC use cases

www.thelastpickle.com

Page 13: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Multi DC use cases

Separate operationaland

analytical workloads

www.thelastpickle.com

Page 14: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Multi DC use cases

www.thelastpickle.com

Page 15: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Why multi DC ?ConsistencyOperations

Failover

www.thelastpickle.com

Page 16: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Clusters consistency

Strongly consistent clusters

Low latency between DCsand At least 3 DCsand No search/analytical DC

www.thelastpickle.com

Page 17: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Clusters consistency

Eventually consistent clusters High latency between DCsor exactly 2 DCsor at least 1 search/analytical DC

www.thelastpickle.com

Page 18: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Replication & consistency

Create a keyspace for a single DC cluster :CREATE KEYSPACE ks1 WITH replication =

{ 'class':'SimpleStrategy',

‘replication_factor' : 7

};www.thelastpickle.com

Page 19: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Replication & consistency SimpleStrategy on a multi DC cluster

www.thelastpickle.com

Page 20: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Replication & consistency

Create a keyspace for a multi DC cluster :CREATE KEYSPACE ks1 WITH replication =

{'class':'NetworkTopologyStrategy',

'dc1' : 3,

'dc2' : 3

};www.thelastpickle.com

Page 21: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Replication & consistency NetworkTopologyStrategy on a multi DC cluster

www.thelastpickle.com

Page 22: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Replication & consistency

Configuring DC on nodes

With GossipingPropertyFileSnitch : conf/cassandra-rackdc.propertiesdc=DC2

www.thelastpickle.com

Page 23: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Replication & consistency

Non DC-aware Consistency LevelsONE (default)(TWO, THREE)

QUORUMALL

www.thelastpickle.com

Page 24: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Replication & consistency

DC-aware Consistency LevelsLOCAL_ONE (default)

LOCAL_QUORUMEACH_QUORUM

www.thelastpickle.com

Page 25: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Read & write path

QUORUM WRITE on DC1

www.thelastpickle.com

Page 26: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Read & write path

LOCAL_QUORUM WRITE on DC1

www.thelastpickle.com

Page 27: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Read & write path

QUORUM READ on DC2

www.thelastpickle.com

Page 28: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Read & write path

LOCAL_QUORUM READ on DC1

www.thelastpickle.com

Page 29: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Read & write path

LOCAL_QUORUM READ on DC2

www.thelastpickle.com

Page 30: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Why multi DC ?ConsistencyOperations

Failover

www.thelastpickle.com

Page 31: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations & configuration

Specific configurationsfor multi DC clustersin conf/cassandra.yaml

www.thelastpickle.com

Page 32: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations & configuration

Specific throttling for inter DC streaming throughput :

inter_dc_stream_throughput_outbound_megabits_per_sec

Defaults to 200 Mbps ( 25 MB/s )

www.thelastpickle.com

Page 33: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations & configuration

Internode encryption can be activated for inter DC communications only

server_encryption_options: internode_encryption: dc

www.thelastpickle.com

Page 34: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations & configuration

Internode compression can be activated for inter DC communications only

internode_compression: dc

www.thelastpickle.com

Page 35: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations & configuration

Reduce the TCP overhead in async DCs by setting :

inter_dc_tcp_nodelay: true

Larger but fewer TCP packets

www.thelastpickle.com

Page 36: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations & configuration

Adding a new DC to an existing cluster

www.thelastpickle.com

Page 37: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

Migrate all your SimpleStrategy KS to

NetworkTopologyStrategy

www.thelastpickle.com

Page 38: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

ALTER KEYSPACE ks1 WITH replication =

{'class':'NetworkTopologyStrategy',

'dc1' : 3

};

www.thelastpickle.com

Page 39: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

Disable auto bootstrap on new nodes

www.thelastpickle.com

Page 40: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

Disable auto bootstrap on new nodes

(not mandatory, but safer…)

www.thelastpickle.com

Page 41: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

Add this in conf/cassandra.yaml :

auto_bootstrap: false

www.thelastpickle.com

Page 42: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

Start new nodes

www.thelastpickle.com

Page 43: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

At this point, Nodes in the new DC are :

• empty• not involved in reads nor writes

www.thelastpickle.com

Page 44: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

Change strategy params to add replicas on

the new DC

www.thelastpickle.com

Page 45: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

You might want to make suretraffic is restricted to DC1

before you move on…

(unless you’re using QUORUM)

www.thelastpickle.com

Page 46: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

ALTER KEYSPACE ks1 WITH replication =

{'class':'NetworkTopologyStrategy',

'dc1' : 3,

'dc2' : 3

};www.thelastpickle.com

Page 47: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

At this point, your new DC

accepts both reads and writes

www.thelastpickle.com

Page 48: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

But nodes on the new DCare still desperately empty

www.thelastpickle.com

Page 49: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

Routing traffic on a specific DC

is a dev task

www.thelastpickle.com

Page 50: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

1/ Pick a coordinator in a specific DC :

use DCAwareRoundRobinPolicy in your <paste your language> Datastax driver

www.thelastpickle.com

Page 51: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

www.thelastpickle.com

Page 52: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

2/ tell the coordinator to work with nodes

in its own DC only :

use a LOCAL_* CL

www.thelastpickle.com

Page 53: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

Consistency level can be modified on the fly through feature flips for example

Load balancing policy cannot…

www.thelastpickle.com

Page 54: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

Fill your new nodeswith data taken from dc1 :

Run a rolling « nodetool rebuild dc1 »

on all nodes in dc2

www.thelastpickle.com

Page 55: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - adding a new DC

Your new DC is nowfully ready to rock

www.thelastpickle.com

Page 56: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations & configuration

How to remove DC2 from the cluster

www.thelastpickle.com

Page 57: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations & configuration

Switch all traffic to DC1

www.thelastpickle.com

Page 58: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations & configuration

You may want to run repair

www.thelastpickle.com

Page 59: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations & configuration

You may want to run repair

(hopefully you’ve seen my talk yesterday)

www.thelastpickle.com

Page 60: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations - removing a DC

ALTER KEYSPACE ks1 WITH replication =

{'class':'NetworkTopologyStrategy',

'dc1' : 3,

'dc2' : 3

};www.thelastpickle.com

Page 61: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Operations & configuration

Decommission all nodes from dc2

Run « nodetool decommission »on all nodes in dc2

www.thelastpickle.com

Page 62: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Hints & repair

Anti-entropy repair

Merkle trees are requested from all replicas in all DCs by default

www.thelastpickle.com

Page 63: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Hints & repair

Specific switch to run repairin the local DC:

nodetool repair -local

www.thelastpickle.com

Page 64: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Hints & repair

Should you run repair on all DCs ?

www.thelastpickle.com

Page 65: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Hints & repair

Yes, if :SimpleStrategy KS

or

-local switchor

KS not replicated to all DCs

www.thelastpickle.com

Page 66: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Hints & repair

Otherwise no

www.thelastpickle.com

Page 67: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Hints & repair

Try to avoid « over-repairing »your cluster

Each token range needs a single pass…

www.thelastpickle.com

Page 68: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Hints & repair

Hints work between DCslike they do between nodes

in a single DC

www.thelastpickle.com

Page 69: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Hints & repair

Hints can be disabled on specific DCsin conf/cassandra.yaml :

hinted_handoff_disabled_datacenters: - DC1 - DC2

www.thelastpickle.com

Page 70: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Hints & repair

This means DC1 and DC2 won’t receive hints

(use this wisely)

www.thelastpickle.com

Page 71: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Hints & repair

Advice for hints in multi DC clusters :

raise max_hints_delivery_threads to 4

www.thelastpickle.com

Page 72: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Why multi DC ?ConsistencyOperations

Failover

www.thelastpickle.com

Page 73: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Failover

Failover in single DC clusters

Use CL ONE or QUORUM

www.thelastpickle.com

Page 74: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Failover

Failover in multi DC strongly consistent

clusters

Use CL ONE or QUORUM

www.thelastpickle.com

Page 75: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Failover

www.thelastpickle.com

Page 76: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Failover

www.thelastpickle.com

Page 77: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Failover

Failover in multi DC eventually consistent

clusters

What if my local DC loses QUORUM ?

www.thelastpickle.com

Page 78: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Failover

www.thelastpickle.com

Page 79: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Failover

Quorum at RF 6 is 4

www.thelastpickle.com

Page 80: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Failover

You have to build inter DC failover

www.thelastpickle.com

Page 81: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Failover

detect failure metrics, token range monitoring, …

www.thelastpickle.com

Page 82: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Failover

switch trafficnetwork, app or driver level

www.thelastpickle.com

Page 83: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Failover

prevent premature back switch inconsistencies

www.thelastpickle.com

Page 84: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Failover

Build your own load balancing policyon top of the DCAwareRoundRobinPolicy

www.thelastpickle.com

Page 85: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Failover

If you have an analytical DC

and want synchronous operational DCs

Use racks

www.thelastpickle.com

Page 86: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Failover

www.thelastpickle.com

Page 87: Operations, Consistency, Failover for Multi-DC Clusters (Alexander Dejanovski, The Last Pickle) | Cassandra Summit 2016

Thanks!@alexanderdeja