+ All Categories
Home > Technology > Taming Pythons with ZooKeeper (Pyconfi edition)

Taming Pythons with ZooKeeper (Pyconfi edition)

Date post: 24-Apr-2015
Category:
Upload: jyrki-pulliainen
View: 1,149 times
Download: 0 times
Share this document with a friend
Description:
 
45
Taming Pythons with ZooKeeper PyCon Finland 2012
Transcript
Page 1: Taming Pythons with ZooKeeper (Pyconfi edition)

Taming Pythons with ZooKeeper

PyCon Finland 2012

Page 2: Taming Pythons with ZooKeeper (Pyconfi edition)

@nailor

Page 3: Taming Pythons with ZooKeeper (Pyconfi edition)

Content Squad

Page 4: Taming Pythons with ZooKeeper (Pyconfi edition)

• Consume boatloads of XML

• Build database out ofit

• Transcode audio

• Enrich data

• Build indexes

• Ship indexes

Day to day operations

Page 5: Taming Pythons with ZooKeeper (Pyconfi edition)

Shipping

Page 6: Taming Pythons with ZooKeeper (Pyconfi edition)

Pre-defined order

Page 7: Taming Pythons with ZooKeeper (Pyconfi edition)

• Central orchestrator

• Assume all machines are running

• Run remote commands

• We need to know all the quirks

• Fail fast

The naïve solution

Page 8: Taming Pythons with ZooKeeper (Pyconfi edition)

Guess what? It breaks

Page 9: Taming Pythons with ZooKeeper (Pyconfi edition)

...and replacing isn't simple

Page 10: Taming Pythons with ZooKeeper (Pyconfi edition)

• No central orchestrator

• Assume some machines are always down

• Run locally

• Shift responsibility to system owners

• Fail gracefully

New tool is needed

Page 11: Taming Pythons with ZooKeeper (Pyconfi edition)

CAP Theorem

Page 12: Taming Pythons with ZooKeeper (Pyconfi edition)

The CAP Theorem

1.Consistency

2.Availability

3.Partition tolerance

Page 13: Taming Pythons with ZooKeeper (Pyconfi edition)

Pick two. Any two will do.

Page 14: Taming Pythons with ZooKeeper (Pyconfi edition)

We went for CA

Page 15: Taming Pythons with ZooKeeper (Pyconfi edition)

• Users are mostly contained in single DC

• Inside a single DC connections are quite robust

• Remember the order? We need consistency

• Availability is everything

Why?

Page 16: Taming Pythons with ZooKeeper (Pyconfi edition)

How?

Page 17: Taming Pythons with ZooKeeper (Pyconfi edition)
Page 18: Taming Pythons with ZooKeeper (Pyconfi edition)

Apache ZooKeeper

Page 19: Taming Pythons with ZooKeeper (Pyconfi edition)

• A distributed tree-like data structure

• Simple primitives

• Automatic leader elections

• Guaranteed hard consistency

• Ephemeral nodes

What?

Page 20: Taming Pythons with ZooKeeper (Pyconfi edition)

Tree-like structure

/

/dir/

/

/subdir/

/dir2/

Page 21: Taming Pythons with ZooKeeper (Pyconfi edition)

Simple primitives

● Guaranteed atomic operations● Counters● Change notifications

Page 22: Taming Pythons with ZooKeeper (Pyconfi edition)

Automatic leader election

● Nodes know who is the most up to date● If no leader can be picked, ZooKeeper refuses to work

Page 23: Taming Pythons with ZooKeeper (Pyconfi edition)

Guaranteed hard consistency

● Every change is sent to every node!● Quorum for all operations is always required

Page 24: Taming Pythons with ZooKeeper (Pyconfi edition)

Ephemeral nodes

● Node is present only if the client is alive

Page 25: Taming Pythons with ZooKeeper (Pyconfi edition)

Library: zkPython

Page 26: Taming Pythons with ZooKeeper (Pyconfi edition)

The Good:

● Thin● Comes with ZooKeeper● Maintained by the Apache ZooKeeper project

Page 27: Taming Pythons with ZooKeeper (Pyconfi edition)

The bad:

● Thin● C bindings only, no PyPy for you

Page 28: Taming Pythons with ZooKeeper (Pyconfi edition)

The ugly:

● No documentation :(

Page 29: Taming Pythons with ZooKeeper (Pyconfi edition)

There are others: Kazoo

Page 30: Taming Pythons with ZooKeeper (Pyconfi edition)

The Good:

● Pure Python● Recipes implemented● Used by many (Quora, Mozilla, reddit, Zope)

Page 31: Taming Pythons with ZooKeeper (Pyconfi edition)

The bad:

● Not much recipes done● Not owned by the mainline

Page 32: Taming Pythons with ZooKeeper (Pyconfi edition)

The ugly:

● Own implementation of the protocol

Page 33: Taming Pythons with ZooKeeper (Pyconfi edition)

Dos and Don'ts

Page 34: Taming Pythons with ZooKeeper (Pyconfi edition)

Don't ship large chunks

Page 35: Taming Pythons with ZooKeeper (Pyconfi edition)

Monitor the ZooKeeper

Page 36: Taming Pythons with ZooKeeper (Pyconfi edition)

Don't write there all the time

Page 37: Taming Pythons with ZooKeeper (Pyconfi edition)

Stay in one DC

Page 38: Taming Pythons with ZooKeeper (Pyconfi edition)

Spotify & ZooKeeper

Page 39: Taming Pythons with ZooKeeper (Pyconfi edition)

Summary time!

Page 40: Taming Pythons with ZooKeeper (Pyconfi edition)

Concurrency == hard

Page 41: Taming Pythons with ZooKeeper (Pyconfi edition)

Distributed consistency == hard

Page 42: Taming Pythons with ZooKeeper (Pyconfi edition)

No partitions? Go ZooKeeper!

Page 43: Taming Pythons with ZooKeeper (Pyconfi edition)

Pick your weapon library

Page 44: Taming Pythons with ZooKeeper (Pyconfi edition)

Remember tradeoffs

Page 45: Taming Pythons with ZooKeeper (Pyconfi edition)

Thank you


Recommended