Zookeeper In Simple Words

20
ZOOKEEPER IN MY WORDS fujohnwang@Pluto 2011.01.11 Wednesday, January 12, 2011

description

overview things on zookeeper, no too much details inside

Transcript of Zookeeper In Simple Words

Page 1: Zookeeper In Simple Words

ZOOKEEPER IN MY WORDS

[email protected]

Wednesday, January 12, 2011

Page 2: Zookeeper In Simple Words

WHAT’S ZK?

“ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. All of these kinds of services are used in some form or another by distributed applications. Each time they are implemented there is a lot of work that goes into fixing the bugs and race conditions that are inevitable. Because of the difficulty of implementing these kinds of services, applications initially usually skimp on them ,which make them brittle in the presence of change and difficult to manage. Even when done correctly, different implementations of these services lead to management complexity when the applications are deployed.”

Wednesday, January 12, 2011

Page 3: Zookeeper In Simple Words

WHAT THE FUCK DOES THAT MEAN?

Simply Put: Coordination Service For Distributed Systems

Wednesday, January 12, 2011

Page 4: Zookeeper In Simple Words

WHAT ZK CAN DO?

Name Service

Configuration

Group Membership

Distributed Synchronization

Wednesday, January 12, 2011

Page 5: Zookeeper In Simple Words

WHAT ZK LOOKS LIKE?

File System ModelHierarchical Namespace

each node can have both data and children

Wednesday, January 12, 2011

Page 6: Zookeeper In Simple Words

HOW ZK WORKS?

Wednesday, January 12, 2011

Page 7: Zookeeper In Simple Words

HOW ZK WORKS?

Zab

Wednesday, January 12, 2011

Page 8: Zookeeper In Simple Words

HOW TO DEPLOY ZK?

single server quorum clustermajority algorithm(2n + 1)

Wednesday, January 12, 2011

Page 9: Zookeeper In Simple Words

ZK DEPLOYMENT IN DETAILS

configuration

data location

transaction log location (optional but necessary)

cluster members

myid file (under data location directory)

Wednesday, January 12, 2011

Page 10: Zookeeper In Simple Words

CONFIGURATION FILE SAMPLE

# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# The number of ticks that can pass between # sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.dataDir=/Users/fujohnwang/Downloads/zookeeper-3.3.2/data# the port at which the clients will connectclientPort=2181

server.1=10.16.200.14:2888:3888server.2=10.20.135.206:2888:3888server.3=10.20.130.233:2888:3888

Wednesday, January 12, 2011

Page 11: Zookeeper In Simple Words

HOW TO INTERACTIVE WITH ZK?

Command Line Tool

Zookeeper API Bindings

Java Bindings

C Bindings

Wednesday, January 12, 2011

Page 12: Zookeeper In Simple Words

ZOOKEEPER CLI

bin/zkCli.sh -server 127.0.0.1:2181[zk: 10.20.130.233:2181(CONNECTED) 0] help ZooKeeper -server host:port cmd args printwatches on|off ls2 path [watch] listquota path close get path [watch] sync path delete path [version] quit addauth scheme auth getAcl path setAcl path acl setquota -n|-b val path redo cmdno create [-s] [-e] path data acl set path data [version] stat path [watch] connect host:port ls path [watch] history delquota [-n|-b] path

Wednesday, January 12, 2011

Page 13: Zookeeper In Simple Words

ZK API = SIMPLE API

create

delete

exists

set data

get data

get children

sync

Wednesday, January 12, 2011

Page 14: Zookeeper In Simple Words

WHAT THE FEATURES OF ZK?

Notification

Ordering

Atomicity

Versioned Write

Ephemeral Nodes

Sequential Nodes

High Availability

Wednesday, January 12, 2011

Page 15: Zookeeper In Simple Words

WATCH - NOTIFICATION

Concept

Usecase

dynamic configuration push

other (semi)real-time information notification

Wednesday, January 12, 2011

Page 16: Zookeeper In Simple Words

EPHEMERAL NODES

Concept

lifecycle-dependent

no children

Usecase

group membership

leader election

Wednesday, January 12, 2011

Page 17: Zookeeper In Simple Words

SEQUENTIAL NODES

Concept

Usecase

queue

Wednesday, January 12, 2011

Page 18: Zookeeper In Simple Words

GUARANTEES OF ZK

Sequential Consistency - Updates from a client will be applied in the order that they were sent.

Atomicity - Updates either succeed or fail. No partial results.

Single System Image - A client will see the same view of the service regardless of the server that it connects to.

Reliability - Once an update has been applied, it will persist from that time forward until a client overwrites the update.

Timeliness - The clients view of the system is guaranteed to be up-to-date within a certain time bound.

Wednesday, January 12, 2011

Page 19: Zookeeper In Simple Words

CAUTIONS TO TAKE

prefer small data size for each node(less than 1M)

one time trigger (add again and again if u need)

dataset in all must fit in memory

Wednesday, January 12, 2011

Page 20: Zookeeper In Simple Words

nicholsong

QUESTIONS?

Wednesday, January 12, 2011