73
Hecuba2 Cassandra Operations Made Easy Radovan Zvoncek [email protected]

Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Embed Size (px)

Citation preview

Page 1: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Hecuba2Cassandra Operations Made Easy

Radovan [email protected]

Radovan Zvoncek
Maybe don't disclose the number.
Page 2: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Agenda

1 Two peace stories

2 Cassandra infrastructure at Spotify

3 What exactly is Hecuba2?

4 Wrap up

2© DataStax, All Rights Reserved.

Page 3: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

About Radovan

Likes pancakes

© DataStax, All Rights Reserved. 3

Page 4: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

About Radovan

Likes pancakes

Now knows where to get them

© DataStax, All Rights Reserved. 4

Page 5: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

About Radovan

Likes pancakes

Now knows where to get them

Works at Spotify

© DataStax, All Rights Reserved. 5

Page 6: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Spotify

Music streaming service● ~ 100 million active users● ~ 2 billion playlists

© DataStax, All Rights Reserved. 6

Page 7: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Spotify

Music streaming service● ~ 100 million active users● ~ 2 billion playlists

Happy Apache Cassandra user● ~ 100 Cassandra clusters● ~ 1000 nodes altogether

© DataStax, All Rights Reserved. 7

Page 8: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

The Playlist Cluster

The largest cluster we have● 2 x 45 nodes● ~ 1TB of data on each node

© DataStax, All Rights Reserved. 8

Page 9: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

The Playlist Cluster

The largest cluster we have● 2 x 45 nodes● ~ 1TB of data on each node

© DataStax, All Rights Reserved. 9

Page 10: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

The Playlist Cluster

The largest cluster we have● 2 x 45 nodes● ~ 1TB of data on each node

Had to expand by 50%

© DataStax, All Rights Reserved. 10

Page 11: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

The previous large cluster expansion went so wrong…

Peace Story #1: The Playlist Expansion

© DataStax, All Rights Reserved. 11

Page 12: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

The previous large cluster expansion went so wrong…

How exactly to do the expansion now?

Peace Story #1: The Playlist Expansion

© DataStax, All Rights Reserved. 12

Page 13: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

The previous large cluster expansion went so wrong…

How exactly to do the expansion now?

What tokens should the new nodes have?

Peace Story #1: The Playlist Expansion

© DataStax, All Rights Reserved. 13

Page 14: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Peace Story #1: The Playlist Expansion

The previous large cluster expansion went so wrong…

How exactly to do the expansion now?

What tokens should the new nodes have?

How to bootstrap the nodes?

© DataStax, All Rights Reserved. 14

Page 15: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Peace Story #1: The Playlist Expansion

Turns out, we needed just one command:

© DataStax, All Rights Reserved. 15

hecuba2-cli expand-cluster dc1-playlistcassandra-a{31..45}.foo.net

Page 16: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Peace Story #1: The Playlist Expansion

Turns out, we needed just one command:

And one peer review

© DataStax, All Rights Reserved. 16

hecuba2-cli expand-cluster dc1-playlistcassandra-a{31..45}.foo.net

Page 17: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Peace Story #1: The Playlist Expansion

Turns out, we needed just one command:

And one peer review

And then a week of waiting

© DataStax, All Rights Reserved. 17

hecuba2-cli expand-cluster dc1-playlistcassandra-a{31..45}.foo.net

Page 18: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Peace Story #1: The Playlist Expansion

18

Page 19: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Peace Story #2: The Slush Incident

© DataStax, All Rights Reserved. 19

Page 20: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Peace Story #2: The Slush Incident

© DataStax, All Rights Reserved. 20

Page 21: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Peace Story #2: The Slush Incident

Got paged with 2 out of 3 nodes being down

© DataStax, All Rights Reserved. 21

Datacenter: dc1==========Address Rack Status Load Owns Token

dc1-slush-1.foo.net rac1 Up Normal 797.27 GB 33.33% 0dc1-slush-2.foo.net rac1 Down Normal 798.58 GB 33.33% 56...dc1-slush-3.foo.net rac1 Down Normal 797.58 GB 33.33% 11...

Page 22: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Peace Story #2: The Slush Incident

Turns out, we needed just two commands

© DataStax, All Rights Reserved. 22

hecuba2-cli replace-nodes --old-host dc1-slush-2.foo.net --new-host dc1-slush-4.foo.net

hecuba2-cli replace-nodes --old-host dc1-slush-3.foo.net --new-host dc1-slush-5.foo.net

Page 23: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Peace Story #2: The Slush Incident

What gave us two peer reviews, such as:

© DataStax, All Rights Reserved. 23

Page 24: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Peace Story #2: The Slush Incident

After a while, we ended up with

© DataStax, All Rights Reserved. 24

Datacenter: dc1==========Address Rack Status Load Owns Token

dc1-slush-1.foo.net rac1 Up Normal 797.27 GB 33.33% 0dc1-slush-4.foo.net rac1 Up Normal 798.58 GB 33.33% 56...dc1-slush-5.foo.net rac1 Up Normal 797.58 GB 33.33% 11...

Page 25: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

The Peace Stories

Very pleasant experience operating Cassandra @ Spotify

All because our infrastructure

© DataStax, All Rights Reserved. 25

Page 26: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Agenda

1 Two peace stories

2 Cassandra infrastructure at Spotify

3 What exactly is Hecuba2?

4 Wrap up

26© DataStax, All Rights Reserved.

Page 27: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Cassandra Infrastructure @ Spotify

Let’s just create a Cassandra cluster like a Spotifier

© DataStax, All Rights Reserved. 27

Page 28: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Creating C* Cluster Like A Spotifier

Step 1: Get some machines

© DataStax, All Rights Reserved. 28

Page 29: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Creating C* Cluster Like A Spotifier

Step 1: Get some machines

© DataStax, All Rights Reserved. 29

Page 30: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Creating C* Cluster Like A Spotifier

Step 1: Get some machines

More info about System-Z

Modelling Microservices at Spotifyby Petter Måhlén

https://youtu.be/7XDA044tl8k

© DataStax, All Rights Reserved. 30

Page 31: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Creating C* Cluster Like A Spotifier

Step 1: Get some machines

Step 2: Install the operating system

© DataStax, All Rights Reserved. 31

Page 32: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Creating C* Cluster Like A Spotifier

Step 1: Get some machines

Step 2: Install the operating system

© DataStax, All Rights Reserved. 32

Page 33: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Creating C* Cluster Like A Spotifier

Step 1: Get some machines

Step 2: Setup the cluster

© DataStax, All Rights Reserved. 33

Page 34: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Creating C* Cluster Like A Spotifier

Step 1: Get some machines

Step 2: Setup the cluster

© DataStax, All Rights Reserved. 34

hecuba2-cli create-cluster --cluster-name "My new cluster"--owner mySquad dc1-userdatacass-{1..3}.foo.net

Page 35: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Creating C* Cluster Like A Spotifier

© DataStax, All Rights Reserved.

Step 1: Get some machines

Step 2: Setup the cluster

Step 3: Check PR

35

Page 36: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Creating C* Cluster Like A Spotifier

© DataStax, All Rights Reserved.

Step 1: Get some machines

Step 2: Setup the cluster

Step 3: Check PR

Step 4: Wait

36

Page 37: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Creating C* Cluster Like A Spotifier

© DataStax, All Rights Reserved.

Step 1: Get some machines

Step 2: Setup the cluster

Step 3: Check PR

Step 4: Wait

This will get picked up by our conf. management system and● Install software● Configure Cassandra

37

Page 38: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Configuring Cassandra

© DataStax, All Rights Reserved. 38

Page 39: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Configuring Cassandra

Is (almost) all about putting things into config files

© DataStax, All Rights Reserved. 39

Page 40: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Configuring Cassandra

Is (almost) all about putting things into config files

Mostly tokens and seeds● Tokens are clunky large strings● V-nodes would help, but...

© DataStax, All Rights Reserved. 40

Page 41: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Configuring Cassandra

Is (almost) all about putting things into config files

Mostly tokens and seeds● Tokens are clunky large strings● V-nodes would help, but...

Also node bootstrap● All nodes joining at once is not desired

© DataStax, All Rights Reserved. 41

Page 42: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Configuring Cassandra

Is (almost) all about putting things into config files

Mostly tokens and seeds● Tokens are clunky large strings● V-nodes would help, but...

Also node bootstrap● All nodes joining at once is not desired

Both are handled by Hecuba2

© DataStax, All Rights Reserved. 42

Page 43: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Agenda

1 Two peace stories

2 Cassandra infrastructure at Spotify

3 What exactly is Hecuba2?

4 Wrap up

43© DataStax, All Rights Reserved.

Page 44: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

What Exactly is Hecuba2

© DataStax, All Rights Reserved. 44

HecubaYAMLFile

Hecuba2Agent

Hecuba2jmx-proxy

Hecuba2SeedPro

vider

Hecuba2Agent

Hecuba2jmx-proxy

Hecuba2Seed

Provider

Cassandra NodeHecuba2ClientLibrary

C*Process

Page 45: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Hecuba YAML File

Represents the truth about the cluster

© DataStax, All Rights Reserved. 45

Page 46: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Hecuba YAML File

dc1-mytestcass-1.foo.net: cluster_name: mytestcass dc: dc1 seed: true token: 0dc1-mytestcass-2.foo.net: cluster_name: mytestcass dc: dc1 seed: false token: 56713727820156410577229101238628035242

© DataStax, All Rights Reserved. 46

Page 47: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Hecuba2 Client Library

Manipulates the Hecuba YAML file

© DataStax, All Rights Reserved. 47

Page 48: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Hecuba2 Client Library

Manipulates the Hecuba YAML file

Does this in a smart way

© DataStax, All Rights Reserved. 48

Page 49: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Hecuba2 Client Library

Manipulates the Hecuba YAML file

Does this in a smart way

Doubling the cluster

© DataStax, All Rights Reserved. 49

Double the size

New node

Existing node stayed in place

Page 50: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Manipulates the Hecuba YAML file

Does this in a smart way

Doubling the cluster

Expand by 50%

Hecuba2 Client Library

© DataStax, All Rights Reserved. 50

Add 2 nodes

New node

Existing node stayed in place

Existing node moved

Page 51: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Hecuba2 Server-Side Components

© DataStax, All Rights Reserved. 51

Hecuba2Agent

Hecuba2jmx-proxy

Hecuba2Seed

Provider

Cassandra Node

C*Process

Page 52: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Hecuba2 Server-Side Components

Again, three things:

● hecuba2-agent○ State machine managing the C* process

© DataStax, All Rights Reserved. 52

Page 53: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

hecuba2-agent

© DataStax, All Rights Reserved. 53

Page 54: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

hecuba2-agent

© DataStax, All Rights Reserved. 54

Page 55: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Hecuba2 Server-Side Components

Again, three things:

● hecuba2-agent○ State machine managing the C* process

● hecuba2-jmxproxy○ nodetool with JSON output

© DataStax, All Rights Reserved. 55

Page 56: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Hecuba2 Server-Side Components

Again, three things:

● hecuba2-agent○ State machine managing the C* process

● hecuba2-jmxproxy○ nodetool with JSON output

● hecuba2-seedprovider○ Picks seeds from Hecuba YAML

© DataStax, All Rights Reserved. 56

Page 57: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

How Does It All Work Together

© DataStax, All Rights Reserved. 57

Page 58: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

How Does It All Work Together

© DataStax, All Rights Reserved. 58

Hecuba2ClientLibrary

Page 59: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

How Does It All Work Together

© DataStax, All Rights Reserved. 59

HecubaYAMLFile

Hecuba2ClientLibrary

Cre

ates

Hecuba2

Not in scope

Page 60: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

How Does It All Work Together

© DataStax, All Rights Reserved. 60

HecubaYAMLFile

Hecuba2ClientLibrary

Text Editor

Hecuba2

Not in scope

Alternative

Cre

ates

Page 61: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

How Does It All Work Together

© DataStax, All Rights Reserved. 61

HecubaYAMLFile

HecubaYAMLFile

Cassandra NodeHecuba2ClientLibrary

Text Editor

Hecuba2

Not in scope

Alternative

Cre

ates

Distribution

C*Process

Hecuba2Agent

Hecuba2jmx-proxy

Hecuba2Seed

Provider

Page 62: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

How Does It All Work Together

© DataStax, All Rights Reserved. 62

HecubaYAMLFile

HecubaYAMLFile

Cassandra NodeHecuba2ClientLibrary

Text Editor

Hecuba2

Not in scope

Alternative

Cre

ates

Distribution

Manual

Puppet

C*Process

Hecuba2Agent

Hecuba2jmx-proxy

Hecuba2Seed

Provider

Page 63: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

How Does It All Work Together

© DataStax, All Rights Reserved. 63

HecubaYAMLFile

HecubaYAMLFile

Cassandra NodeHecuba2ClientLibrary

Text Editor

Hecuba2

Not in scope

Alternative

Cre

ates

Distribution

Manual

Puppet

Hecuba2Agent

Hecuba2jmx-proxy

Hecuba2Seed

Provider

Cron

exec

utes

C*Process

Page 64: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

How Does It All Work Together

© DataStax, All Rights Reserved. 64

HecubaYAMLFile

HecubaYAMLFile

Cassandra NodeHecuba2ClientLibrary

Text Editor

Hecuba2

Not in scope

Alternative

Cre

ates

Distribution

Manual

Puppet

Hecuba2Agent

Hecuba2jmx-proxy

Hecuba2Seed

Provider

Cron

exec

utes

callsreads

C*Process

Page 65: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

How Does It All Work Together

© DataStax, All Rights Reserved. 65

HecubaYAMLFile

HecubaYAMLFile

Cassandra NodeHecuba2ClientLibrary

Text Editor

Hecuba2

Not in scope

Alternative

Cre

ates

Distribution

Manual

Puppet

Hecuba2Agent

Hecuba2jmx-proxy

Hecuba2Seed

Provider

Cron

exec

utes

callsreads

man

ages

C*Process

Page 66: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

How Does It All Work Together

© DataStax, All Rights Reserved. 66

HecubaYAMLFile

Hecuba2Agent

man

ages

Cron

exec

utes

Hecuba2jmx-proxy

Hecuba2SeedPro

vider

HecubaYAMLFile

calls

callsreads

Hecuba2Agent

Hecuba2jmx-proxy

Hecuba2Seed

Provider

Cassandra NodeHecuba2ClientLibrary

Text Editor

Hecuba2

Not in scope

Alternative

Cre

ates

Distribution

Manual

Puppet

C*Process

Page 67: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

How Does It All Work Together

© DataStax, All Rights Reserved. 67

HecubaYAMLFile

Hecuba2Agent

man

ages

Cron

exec

utes

Hecuba2jmx-proxy

Hecuba2SeedPro

vider

HecubaYAMLFile

read

s

calls

callsreads

Hecuba2Agent

Hecuba2jmx-proxy

Hecuba2Seed

Provider

Cassandra NodeHecuba2ClientLibrary

Text Editor

Hecuba2

Not in scope

Alternative

Cre

ates

Distribution

Manual

Puppet

C*Process

Page 68: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

To Recap

Hecuba2 manages cluster topologies● create-cluster● expand-cluster● replace-node

Many things are out of scope

Missing features:● parallelism @ hecuba2-agent● cluster shrinking

© DataStax, All Rights Reserved. 68

Page 69: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Agenda

1 Two peace stories

2 Cassandra infrastructure at Spotify

3 What exactly is Hecuba2?

4 Wrap up

69© DataStax, All Rights Reserved.

Page 70: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Our Experience So Far

It’s been in use for a year

It hasn’t let us down yet

But it has surprised us by being more robust than we thought

State machine testable, visualisable, and easily extensible

Peer review for changes

© DataStax, All Rights Reserved. 70

Page 71: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

FAQ

Why is it called Hecuba2?

Does it support v-nodes?

Does it support Cassandra version X?

Can I use it on Y?

Is it FOSS?

© DataStax, All Rights Reserved. 71

Page 72: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Actual Q

© DataStax, All Rights Reserved. 72

Page 73: Hecuba2: Cassandra Operations Made Easy (Radovan Zvoncek, Spotify) | C* Summit 2016

Thank You!

[email protected]

[email protected]

Eventually https://github.com/spotify/hecuba2

© DataStax, All Rights Reserved. 73