SlideShare a Scribd company logo
1 of 36
Download to read offline
Apache ZooKeeper
An Introduction and Practical Use Cases
Who am I
●   David Arthur
●   Engineer at Lucid Imagination
●   Hadoop user
●   Python enthusiast
●   Father
●   Gardener
Play along!
Grab the source for this presentation at GitHub

github.com/mumrah/trihug-zookeeper-demo

You'll need Java, Ant, and bash.
Apache ZooKeeper
● Formerly a Hadoop sub-project
● ASF TLP (top level project) since Nov 2010
● 7 PMC members, 8 committers - most from
  Yahoo! and Cloudera
● Ugly logo
One liner
"ZooKeeper allows distributed processes to
coordinate with each other through a shared
hierarchical name space of data registers"

- ZooKeeper wiki
Who uses it?
Everyone*

●   Yahoo!
●   HBase
●   Solr
●   LinkedIn (Kafka, Hedwig)
●   Many more




* https://cwiki.apache.org/confluence/display/ZOOKEEPER/PoweredBy
What is it good for?
● Configuration management - machines
  bootstrap config from a centralized source,
  facilitates simpler deployment/provisioning
● Naming service - like DNS, mappings of names
  to addresses
● Distributed synchronization - locks, barriers,
  queues
● Leader election - a common problem in
  distributed coordination
● Centralized and highly reliable (simple) data
  registry
Namespace (ZNodes)
parent : "foo"
|-- child1 : "bar"
|-- child2 : "spam"
`-- child3 : "eggs"
    `-- grandchild1 : "42"

Every znode has data (given as byte[]) and can
optionally have children.
Sequential znode
Nodes created in "sequential" mode will
append a 10 digit zero padded monotonically
increasing number to the name.

create("/demo/seq-", ..., ..., PERSISTENT_SEQUENTIAL) x4

/demo
|-- seq-0000000000
|-- seq-0000000001
|-- seq-0000000002
`-- seq-0000000003
Ephemeral znode
Nodes created in "ephemeral" mode will be
deleted when the originating client goes away.
create("/demo/foo", ..., ..., PERSISTENT);
create("/demo/bar", ..., ..., EPHEMERAL);

          Connected              Disconnected
          /demo                  /demo
            |-- foo                `-- foo
            `-- bar
Simple API
Pretty much everything lives under the
ZooKeeper class

●   create
●   exists
●   delete
●   getData
●   setData
●   getChildren
Synchronicity
sync and async version of API methods
exists("/demo", null);
exists("/demo", null, new StatCallback() {
  @Override
  public processResult(int rc,
                  String path,
                  Object ctx,
                  Stat stat) {
      ...
  }
}, null);
Watches
Watches are a one-shot callback mechanism
for changes on connection and znode state

● Client connects/disconnects
● ZNode data changes
● ZNode children change
Demo time!
For those playing along, you'll need to get
ZooKeeper running. Using the default port
(2181), run:
                    ant zk

Or specify a port like:

          ant zk -Dzk.port=2181
Things to "watch" out for
● Watches are one-shot - if you want continuous
  monitoring of a znode, you have to reset the
  watch after each event
● Too many clients watches on a single znode
  creates a "herd effect" - lots of clients get
  notifications at the same time and cause spikes
  in load
● Potential for missing changes
● All watches are executed in a single, separate
  thread (be careful about synchronization)
Building blocks
● Hierarchical nodes
● Parent and leaf nodes can have data
● Two special types of nodes - ephemeral and
  sequential
● Watch mechanism
● Consistency guarantees
  ○   Order of updates is maintained
  ○   Updates are atomic
  ○   Znodes are versioned for MVCC
  ○   Many more
The Fun Stuff
Recipes:
● Lock
● Barrier
● Queue
● Two-phase commit
● Leader election
● Group membership
Demo Time!
Group membership (i.e., the easy one)

Recipe:
● Members register a sequential ephemeral
  node under the group node
● Everyone keeps a watch on the group node
  for new children
Lots of boilerplate
● Synchronize the asynchronous connection
  (using a latch or something)
● Handling disconnects/reconnects
● Exception handling
● Ensuring paths exist (nothing like mkdir -p)
● Resetting watches
● Cleaning up
What happens?
● Everyone writes their own high level
  wrapper/connection manager
  ○ ZooKeeperWrapper
  ○ ZooKeeperSession
  ○ (w+)ZooKeeper
  ○ ZooKeeper(w+)
Open Source, FTW!
Luckily, some smart people have open sourced
their ZooKeeper utilities/wrappers

● Netflix Curator - Netflix/curator
● Linkedin - linkedin/linkedin-zookeeper
● Many others
Netflix Curator
● Handles the connection management
● Implements many recipes
  ○ leader election
  ○ locks, queues, and barriers
  ○ counters
  ○ path cache
● Bonus: service discovery implementation
  (we use this)
Demo Time!
Group membership refactored with Curator

● EnsurePath is nice
● Robust connection management is
  awesome
● Exceptions are more sane
Thoughts on Curator
i.e., my non-expert subjective opinions


● Good level of abstraction - doesn't do
  anything "magical"
● Doesn't hide ZooKeeper
● Weird API design (builder soup)
● Extensive, well tested recipe support
● It works!
ZooKeeper in the wild
Some use cases
Use case: Solr 4.0
Used in "Solr cloud" mode for:
● Cluster management - what machines are
  available and where are they located
● Leader election - used for picking a shard as
  the "leader"
● Consolidated config storage
● Watches allow for very non-chatty steady-
  state
● Herd effect not really an issue
Use case: Kafka
● Linkedin's distributed pub/sub system
● Queues are persistent
● Clients request a slice of a queue (offset,
  length)
● Brokers are registered in ZooKeeper, clients
  load balance requests among live brokers
● Client state (last consumed offset) is stored
  in ZooKeeper
● Client rebalancing algorithm, similar to
  leader election
Use case:
 LucidWorks Big Data
● We use Curator's service discovery to
  register REST services
● Nice for SOA
● Took 1 dev (me) 1 day to get something
  functional (mostly reading Curator docs)
● So far, so good!
Review of "gotchas"
● Watch execution is single threaded and synchronized
● Can't reliably get every change for a znode
● Excessive watchers on the same znode (herd effect)

                     Some new ones
● GC pauses: if your application is prone to long GC
  pauses, make sure your session timeout is sufficiently
  long
● Catch-all watches: if you use one Watcher for
  everything, it can be tedious to infer exactly what
  happened
Four letter words
The ZooKeeper server responds to a few "four
letter word" commands via TCP or Telnet*

    > echo ruok | nc localhost 2181
    imok

I'm glad you're OK, ZooKeeper - really I am.

* http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_zkCommands
Quorums
In a multi-node deployment (aka, ZooKeeper
Quorum), it is best to use an odd number of
machines.

ZooKeeper uses majority voting, so it can
tolerate ceil(N/2)-1 machine failures and
still function properly.
Multi-tenancy
ZooKeeper supports "chroot" at the session level. You can
add a path to the connection string that will be implicitly
prefixed to everything you do:

   new ZooKeeper("localhost:2181/my/app");


Curator also supports this, but at the application level:
   CuratorFrameworkFactory.builder()
       .namespace("/my/app");
Python client
Dumb wrapper around C client, not very
Pythonic

import zookeeper
zk_handle = zookeeper.init("localhost:2181")
zookeeper.exists(zk_handle, "/demo")
zookeeper.get_children(zk_handle, "/demo")

Stuff in contrib didn't work for me, I used a
statically linked version: zc-zookeeper-static
Other clients
Included in ZooKeeper under src/contrib:
● C (this is what the Python client uses)
● Perl (again, using the C client)
● REST (JAX-RS via Jersey)
● FUSE? (strange)

3rd-party client implementations:
● Scala, courtesy of Twitter
● Several others
Overview
● Basics of ZooKeeper (znode types, watches)
● High-level recipes (group membership, et
  al.)
● Lots of boilerplate for basic functionality
● 3rd party helpers (Curator, et al.)
● Gotchas and other miscellany
Questions?
David Arthur
mumrah@gmail.com
github.com/mumrah/trihug-zookeeper-demo

More Related Content

What's hot

Apache zookeeper seminar_trinh_viet_dung_03_2016
Apache zookeeper seminar_trinh_viet_dung_03_2016Apache zookeeper seminar_trinh_viet_dung_03_2016
Apache zookeeper seminar_trinh_viet_dung_03_2016Viet-Dung TRINH
 
zookeeperProgrammers
zookeeperProgrammerszookeeperProgrammers
zookeeperProgrammersHiroshi Ono
 
Docker and Maestro for fun, development and profit
Docker and Maestro for fun, development and profitDocker and Maestro for fun, development and profit
Docker and Maestro for fun, development and profitMaxime Petazzoni
 
Distributed Coordination with Python
Distributed Coordination with PythonDistributed Coordination with Python
Distributed Coordination with PythonOSCON Byrum
 
[오픈소스컨설팅] EFK Stack 소개와 설치 방법
[오픈소스컨설팅] EFK Stack 소개와 설치 방법[오픈소스컨설팅] EFK Stack 소개와 설치 방법
[오픈소스컨설팅] EFK Stack 소개와 설치 방법Open Source Consulting
 
Supercharging Content Delivery with Varnish
Supercharging Content Delivery with VarnishSupercharging Content Delivery with Varnish
Supercharging Content Delivery with VarnishSamantha Quiñones
 
Introduction openstack-meetup-nov-28
Introduction openstack-meetup-nov-28Introduction openstack-meetup-nov-28
Introduction openstack-meetup-nov-28Sadique Puthen
 
RENCI User Group Meeting 2017 - I Upgraded iRODS and I still have all my hair
RENCI User Group Meeting 2017 - I Upgraded iRODS and I still have all my hairRENCI User Group Meeting 2017 - I Upgraded iRODS and I still have all my hair
RENCI User Group Meeting 2017 - I Upgraded iRODS and I still have all my hairJohn Constable
 
[오픈소스컨설팅] Linux Network Troubleshooting
[오픈소스컨설팅] Linux Network Troubleshooting[오픈소스컨설팅] Linux Network Troubleshooting
[오픈소스컨설팅] Linux Network TroubleshootingOpen Source Consulting
 
Distributed Tests on Pulsar with Fallout - Pulsar Summit NA 2021
Distributed Tests on Pulsar with Fallout - Pulsar Summit NA 2021Distributed Tests on Pulsar with Fallout - Pulsar Summit NA 2021
Distributed Tests on Pulsar with Fallout - Pulsar Summit NA 2021StreamNative
 
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...Atlassian
 
Sanger OpenStack presentation March 2017
Sanger OpenStack presentation March 2017Sanger OpenStack presentation March 2017
Sanger OpenStack presentation March 2017Dave Holland
 
Setup 3 Node Kafka Cluster on AWS - Hands On
Setup 3 Node Kafka Cluster on AWS - Hands OnSetup 3 Node Kafka Cluster on AWS - Hands On
Setup 3 Node Kafka Cluster on AWS - Hands Onhkbhadraa
 
Introduction to Apache Mesos
Introduction to Apache MesosIntroduction to Apache Mesos
Introduction to Apache MesosJoe Stein
 
Openstack study-nova-02
Openstack study-nova-02Openstack study-nova-02
Openstack study-nova-02Jinho Shin
 
Running High Performance & Fault-tolerant Elasticsearch Clusters on Docker
Running High Performance & Fault-tolerant Elasticsearch Clusters on DockerRunning High Performance & Fault-tolerant Elasticsearch Clusters on Docker
Running High Performance & Fault-tolerant Elasticsearch Clusters on DockerSematext Group, Inc.
 
Docker 1.5
Docker 1.5Docker 1.5
Docker 1.5rajdeep
 
[NYC Meetup] Docker at Nuxeo
[NYC Meetup] Docker at Nuxeo[NYC Meetup] Docker at Nuxeo
[NYC Meetup] Docker at NuxeoNuxeo
 
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법Open Source Consulting
 

What's hot (20)

Apache zookeeper seminar_trinh_viet_dung_03_2016
Apache zookeeper seminar_trinh_viet_dung_03_2016Apache zookeeper seminar_trinh_viet_dung_03_2016
Apache zookeeper seminar_trinh_viet_dung_03_2016
 
zookeeperProgrammers
zookeeperProgrammerszookeeperProgrammers
zookeeperProgrammers
 
Docker and Maestro for fun, development and profit
Docker and Maestro for fun, development and profitDocker and Maestro for fun, development and profit
Docker and Maestro for fun, development and profit
 
Distributed Coordination with Python
Distributed Coordination with PythonDistributed Coordination with Python
Distributed Coordination with Python
 
[오픈소스컨설팅] EFK Stack 소개와 설치 방법
[오픈소스컨설팅] EFK Stack 소개와 설치 방법[오픈소스컨설팅] EFK Stack 소개와 설치 방법
[오픈소스컨설팅] EFK Stack 소개와 설치 방법
 
Exhibitor Introduction
Exhibitor IntroductionExhibitor Introduction
Exhibitor Introduction
 
Supercharging Content Delivery with Varnish
Supercharging Content Delivery with VarnishSupercharging Content Delivery with Varnish
Supercharging Content Delivery with Varnish
 
Introduction openstack-meetup-nov-28
Introduction openstack-meetup-nov-28Introduction openstack-meetup-nov-28
Introduction openstack-meetup-nov-28
 
RENCI User Group Meeting 2017 - I Upgraded iRODS and I still have all my hair
RENCI User Group Meeting 2017 - I Upgraded iRODS and I still have all my hairRENCI User Group Meeting 2017 - I Upgraded iRODS and I still have all my hair
RENCI User Group Meeting 2017 - I Upgraded iRODS and I still have all my hair
 
[오픈소스컨설팅] Linux Network Troubleshooting
[오픈소스컨설팅] Linux Network Troubleshooting[오픈소스컨설팅] Linux Network Troubleshooting
[오픈소스컨설팅] Linux Network Troubleshooting
 
Distributed Tests on Pulsar with Fallout - Pulsar Summit NA 2021
Distributed Tests on Pulsar with Fallout - Pulsar Summit NA 2021Distributed Tests on Pulsar with Fallout - Pulsar Summit NA 2021
Distributed Tests on Pulsar with Fallout - Pulsar Summit NA 2021
 
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
 
Sanger OpenStack presentation March 2017
Sanger OpenStack presentation March 2017Sanger OpenStack presentation March 2017
Sanger OpenStack presentation March 2017
 
Setup 3 Node Kafka Cluster on AWS - Hands On
Setup 3 Node Kafka Cluster on AWS - Hands OnSetup 3 Node Kafka Cluster on AWS - Hands On
Setup 3 Node Kafka Cluster on AWS - Hands On
 
Introduction to Apache Mesos
Introduction to Apache MesosIntroduction to Apache Mesos
Introduction to Apache Mesos
 
Openstack study-nova-02
Openstack study-nova-02Openstack study-nova-02
Openstack study-nova-02
 
Running High Performance & Fault-tolerant Elasticsearch Clusters on Docker
Running High Performance & Fault-tolerant Elasticsearch Clusters on DockerRunning High Performance & Fault-tolerant Elasticsearch Clusters on Docker
Running High Performance & Fault-tolerant Elasticsearch Clusters on Docker
 
Docker 1.5
Docker 1.5Docker 1.5
Docker 1.5
 
[NYC Meetup] Docker at Nuxeo
[NYC Meetup] Docker at Nuxeo[NYC Meetup] Docker at Nuxeo
[NYC Meetup] Docker at Nuxeo
 
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
 

Viewers also liked

Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeperSaurav Haloi
 
Apache Zookeeper Explained: Tutorial, Use Cases and Zookeeper Java API Examples
Apache Zookeeper Explained: Tutorial, Use Cases and Zookeeper Java API ExamplesApache Zookeeper Explained: Tutorial, Use Cases and Zookeeper Java API Examples
Apache Zookeeper Explained: Tutorial, Use Cases and Zookeeper Java API ExamplesBinu George
 
Distributed system coordination by zookeeper and introduction to kazoo python...
Distributed system coordination by zookeeper and introduction to kazoo python...Distributed system coordination by zookeeper and introduction to kazoo python...
Distributed system coordination by zookeeper and introduction to kazoo python...Jimmy Lai
 
Dynamic Reconfiguration of Apache ZooKeeper
Dynamic Reconfiguration of Apache ZooKeeperDynamic Reconfiguration of Apache ZooKeeper
Dynamic Reconfiguration of Apache ZooKeeperDataWorks Summit
 
Winter is coming? Not if ZooKeeper is there!
Winter is coming? Not if ZooKeeper is there!Winter is coming? Not if ZooKeeper is there!
Winter is coming? Not if ZooKeeper is there!Joydeep Banik Roy
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeperknowbigdata
 
Zookeeper
ZookeeperZookeeper
Zookeeperltsllc
 
Zookeeper In Action
Zookeeper In ActionZookeeper In Action
Zookeeper In Actionjuvenxu
 
Zookeeper In Simple Words
Zookeeper In Simple WordsZookeeper In Simple Words
Zookeeper In Simple WordsFuqiang Wang
 
Apache Zookeeper 分布式服务框架
Apache Zookeeper 分布式服务框架Apache Zookeeper 分布式服务框架
Apache Zookeeper 分布式服务框架Cabin WJ
 
Introduction to Kafka and Zookeeper
Introduction to Kafka and ZookeeperIntroduction to Kafka and Zookeeper
Introduction to Kafka and ZookeeperRahul Jain
 
Introduction to apache zoo keeper
Introduction to apache zoo keeper Introduction to apache zoo keeper
Introduction to apache zoo keeper Omid Vahdaty
 
Taming Pythons with ZooKeeper
Taming Pythons with ZooKeeperTaming Pythons with ZooKeeper
Taming Pythons with ZooKeeperJyrki Pulliainen
 
Taming Pythons with ZooKeeper (Pyconfi edition)
Taming Pythons with ZooKeeper (Pyconfi edition)Taming Pythons with ZooKeeper (Pyconfi edition)
Taming Pythons with ZooKeeper (Pyconfi edition)Jyrki Pulliainen
 
ZooKeeper and Embedded ZooKeeper Support for IBM InfoSphere Streams V4.0
ZooKeeper and Embedded ZooKeeper Support for IBM InfoSphere Streams V4.0ZooKeeper and Embedded ZooKeeper Support for IBM InfoSphere Streams V4.0
ZooKeeper and Embedded ZooKeeper Support for IBM InfoSphere Streams V4.0lisanl
 
Overview of Zookeeper, Helix and Kafka (Oakjug)
Overview of Zookeeper, Helix and Kafka (Oakjug)Overview of Zookeeper, Helix and Kafka (Oakjug)
Overview of Zookeeper, Helix and Kafka (Oakjug)Chris Richardson
 

Viewers also liked (20)

Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeper
 
Apache ZooKeeper
Apache ZooKeeperApache ZooKeeper
Apache ZooKeeper
 
Apache Zookeeper Explained: Tutorial, Use Cases and Zookeeper Java API Examples
Apache Zookeeper Explained: Tutorial, Use Cases and Zookeeper Java API ExamplesApache Zookeeper Explained: Tutorial, Use Cases and Zookeeper Java API Examples
Apache Zookeeper Explained: Tutorial, Use Cases and Zookeeper Java API Examples
 
Distributed system coordination by zookeeper and introduction to kazoo python...
Distributed system coordination by zookeeper and introduction to kazoo python...Distributed system coordination by zookeeper and introduction to kazoo python...
Distributed system coordination by zookeeper and introduction to kazoo python...
 
Dynamic Reconfiguration of Apache ZooKeeper
Dynamic Reconfiguration of Apache ZooKeeperDynamic Reconfiguration of Apache ZooKeeper
Dynamic Reconfiguration of Apache ZooKeeper
 
Winter is coming? Not if ZooKeeper is there!
Winter is coming? Not if ZooKeeper is there!Winter is coming? Not if ZooKeeper is there!
Winter is coming? Not if ZooKeeper is there!
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeper
 
Zookeeper
ZookeeperZookeeper
Zookeeper
 
Zookeeper In Action
Zookeeper In ActionZookeeper In Action
Zookeeper In Action
 
Zookeeper In Simple Words
Zookeeper In Simple WordsZookeeper In Simple Words
Zookeeper In Simple Words
 
Apache Zookeeper 分布式服务框架
Apache Zookeeper 分布式服务框架Apache Zookeeper 分布式服务框架
Apache Zookeeper 分布式服务框架
 
Introduction to Kafka and Zookeeper
Introduction to Kafka and ZookeeperIntroduction to Kafka and Zookeeper
Introduction to Kafka and Zookeeper
 
Groovy to gradle
Groovy to gradleGroovy to gradle
Groovy to gradle
 
Introduction to apache zoo keeper
Introduction to apache zoo keeper Introduction to apache zoo keeper
Introduction to apache zoo keeper
 
Taming Pythons with ZooKeeper
Taming Pythons with ZooKeeperTaming Pythons with ZooKeeper
Taming Pythons with ZooKeeper
 
ZooKeeper Futures
ZooKeeper FuturesZooKeeper Futures
ZooKeeper Futures
 
ZooKeeper (and other things)
ZooKeeper (and other things)ZooKeeper (and other things)
ZooKeeper (and other things)
 
Taming Pythons with ZooKeeper (Pyconfi edition)
Taming Pythons with ZooKeeper (Pyconfi edition)Taming Pythons with ZooKeeper (Pyconfi edition)
Taming Pythons with ZooKeeper (Pyconfi edition)
 
ZooKeeper and Embedded ZooKeeper Support for IBM InfoSphere Streams V4.0
ZooKeeper and Embedded ZooKeeper Support for IBM InfoSphere Streams V4.0ZooKeeper and Embedded ZooKeeper Support for IBM InfoSphere Streams V4.0
ZooKeeper and Embedded ZooKeeper Support for IBM InfoSphere Streams V4.0
 
Overview of Zookeeper, Helix and Kafka (Oakjug)
Overview of Zookeeper, Helix and Kafka (Oakjug)Overview of Zookeeper, Helix and Kafka (Oakjug)
Overview of Zookeeper, Helix and Kafka (Oakjug)
 

Similar to ZooKeeper Intro and Use Cases

NetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talksNetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talksRuslan Meshenberg
 
A Python Petting Zoo
A Python Petting ZooA Python Petting Zoo
A Python Petting Zoodevondjones
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Tomcat from a cluster to the cloud on RP3
Tomcat from a cluster to the cloud on RP3Tomcat from a cluster to the cloud on RP3
Tomcat from a cluster to the cloud on RP3Jean-Frederic Clere
 
Comparison between zookeeper, etcd 3 and other distributed coordination systems
Comparison between zookeeper, etcd 3 and other distributed coordination systemsComparison between zookeeper, etcd 3 and other distributed coordination systems
Comparison between zookeeper, etcd 3 and other distributed coordination systemsImesha Sudasingha
 
Things You MUST Know Before Deploying OpenStack: Bruno Lago, Catalyst IT
Things You MUST Know Before Deploying OpenStack: Bruno Lago, Catalyst ITThings You MUST Know Before Deploying OpenStack: Bruno Lago, Catalyst IT
Things You MUST Know Before Deploying OpenStack: Bruno Lago, Catalyst ITOpenStack
 
Streaming Processing with a Distributed Commit Log
Streaming Processing with a Distributed Commit LogStreaming Processing with a Distributed Commit Log
Streaming Processing with a Distributed Commit LogJoe Stein
 
Load testing in Zonky with Gatling
Load testing in Zonky with GatlingLoad testing in Zonky with Gatling
Load testing in Zonky with GatlingPetr Vlček
 
Scaling Up Logging and Metrics
Scaling Up Logging and MetricsScaling Up Logging and Metrics
Scaling Up Logging and MetricsRicardo Lourenço
 
Ippevent : openshift Introduction
Ippevent : openshift IntroductionIppevent : openshift Introduction
Ippevent : openshift Introductionkanedafromparis
 
Node.js Presentation
Node.js PresentationNode.js Presentation
Node.js PresentationExist
 
Experiences building a distributed shared log on RADOS - Noah Watkins
Experiences building a distributed shared log on RADOS - Noah WatkinsExperiences building a distributed shared log on RADOS - Noah Watkins
Experiences building a distributed shared log on RADOS - Noah WatkinsCeph Community
 
MySQL HA Orchestrator Proxysql Consul.pdf
MySQL HA Orchestrator Proxysql Consul.pdfMySQL HA Orchestrator Proxysql Consul.pdf
MySQL HA Orchestrator Proxysql Consul.pdfYunusShaikh49
 
Crikeycon 2019 Velociraptor Workshop
Crikeycon 2019 Velociraptor WorkshopCrikeycon 2019 Velociraptor Workshop
Crikeycon 2019 Velociraptor WorkshopVelocidex Enterprises
 
Tornado Web Server Internals
Tornado Web Server InternalsTornado Web Server Internals
Tornado Web Server InternalsPraveen Gollakota
 
Ob1k presentation at Java.IL
Ob1k presentation at Java.ILOb1k presentation at Java.IL
Ob1k presentation at Java.ILEran Harel
 

Similar to ZooKeeper Intro and Use Cases (20)

NetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talksNetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talks
 
A Python Petting Zoo
A Python Petting ZooA Python Petting Zoo
A Python Petting Zoo
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Netty training
Netty trainingNetty training
Netty training
 
Tomcat from a cluster to the cloud on RP3
Tomcat from a cluster to the cloud on RP3Tomcat from a cluster to the cloud on RP3
Tomcat from a cluster to the cloud on RP3
 
Netty training
Netty trainingNetty training
Netty training
 
Comparison between zookeeper, etcd 3 and other distributed coordination systems
Comparison between zookeeper, etcd 3 and other distributed coordination systemsComparison between zookeeper, etcd 3 and other distributed coordination systems
Comparison between zookeeper, etcd 3 and other distributed coordination systems
 
Things You MUST Know Before Deploying OpenStack: Bruno Lago, Catalyst IT
Things You MUST Know Before Deploying OpenStack: Bruno Lago, Catalyst ITThings You MUST Know Before Deploying OpenStack: Bruno Lago, Catalyst IT
Things You MUST Know Before Deploying OpenStack: Bruno Lago, Catalyst IT
 
Streaming Processing with a Distributed Commit Log
Streaming Processing with a Distributed Commit LogStreaming Processing with a Distributed Commit Log
Streaming Processing with a Distributed Commit Log
 
Load testing in Zonky with Gatling
Load testing in Zonky with GatlingLoad testing in Zonky with Gatling
Load testing in Zonky with Gatling
 
Scaling Up Logging and Metrics
Scaling Up Logging and MetricsScaling Up Logging and Metrics
Scaling Up Logging and Metrics
 
Ippevent : openshift Introduction
Ippevent : openshift IntroductionIppevent : openshift Introduction
Ippevent : openshift Introduction
 
Node.js Presentation
Node.js PresentationNode.js Presentation
Node.js Presentation
 
Java concurrency
Java concurrencyJava concurrency
Java concurrency
 
Experiences building a distributed shared log on RADOS - Noah Watkins
Experiences building a distributed shared log on RADOS - Noah WatkinsExperiences building a distributed shared log on RADOS - Noah Watkins
Experiences building a distributed shared log on RADOS - Noah Watkins
 
MySQL HA Orchestrator Proxysql Consul.pdf
MySQL HA Orchestrator Proxysql Consul.pdfMySQL HA Orchestrator Proxysql Consul.pdf
MySQL HA Orchestrator Proxysql Consul.pdf
 
Crikeycon 2019 Velociraptor Workshop
Crikeycon 2019 Velociraptor WorkshopCrikeycon 2019 Velociraptor Workshop
Crikeycon 2019 Velociraptor Workshop
 
Tornado Web Server Internals
Tornado Web Server InternalsTornado Web Server Internals
Tornado Web Server Internals
 
reBuy on Kubernetes
reBuy on KubernetesreBuy on Kubernetes
reBuy on Kubernetes
 
Ob1k presentation at Java.IL
Ob1k presentation at Java.ILOb1k presentation at Java.IL
Ob1k presentation at Java.IL
 

Recently uploaded

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

ZooKeeper Intro and Use Cases

  • 1. Apache ZooKeeper An Introduction and Practical Use Cases
  • 2. Who am I ● David Arthur ● Engineer at Lucid Imagination ● Hadoop user ● Python enthusiast ● Father ● Gardener
  • 3. Play along! Grab the source for this presentation at GitHub github.com/mumrah/trihug-zookeeper-demo You'll need Java, Ant, and bash.
  • 4. Apache ZooKeeper ● Formerly a Hadoop sub-project ● ASF TLP (top level project) since Nov 2010 ● 7 PMC members, 8 committers - most from Yahoo! and Cloudera ● Ugly logo
  • 5. One liner "ZooKeeper allows distributed processes to coordinate with each other through a shared hierarchical name space of data registers" - ZooKeeper wiki
  • 6. Who uses it? Everyone* ● Yahoo! ● HBase ● Solr ● LinkedIn (Kafka, Hedwig) ● Many more * https://cwiki.apache.org/confluence/display/ZOOKEEPER/PoweredBy
  • 7. What is it good for? ● Configuration management - machines bootstrap config from a centralized source, facilitates simpler deployment/provisioning ● Naming service - like DNS, mappings of names to addresses ● Distributed synchronization - locks, barriers, queues ● Leader election - a common problem in distributed coordination ● Centralized and highly reliable (simple) data registry
  • 8. Namespace (ZNodes) parent : "foo" |-- child1 : "bar" |-- child2 : "spam" `-- child3 : "eggs" `-- grandchild1 : "42" Every znode has data (given as byte[]) and can optionally have children.
  • 9. Sequential znode Nodes created in "sequential" mode will append a 10 digit zero padded monotonically increasing number to the name. create("/demo/seq-", ..., ..., PERSISTENT_SEQUENTIAL) x4 /demo |-- seq-0000000000 |-- seq-0000000001 |-- seq-0000000002 `-- seq-0000000003
  • 10. Ephemeral znode Nodes created in "ephemeral" mode will be deleted when the originating client goes away. create("/demo/foo", ..., ..., PERSISTENT); create("/demo/bar", ..., ..., EPHEMERAL); Connected Disconnected /demo /demo |-- foo `-- foo `-- bar
  • 11. Simple API Pretty much everything lives under the ZooKeeper class ● create ● exists ● delete ● getData ● setData ● getChildren
  • 12. Synchronicity sync and async version of API methods exists("/demo", null); exists("/demo", null, new StatCallback() { @Override public processResult(int rc, String path, Object ctx, Stat stat) { ... } }, null);
  • 13. Watches Watches are a one-shot callback mechanism for changes on connection and znode state ● Client connects/disconnects ● ZNode data changes ● ZNode children change
  • 14. Demo time! For those playing along, you'll need to get ZooKeeper running. Using the default port (2181), run: ant zk Or specify a port like: ant zk -Dzk.port=2181
  • 15. Things to "watch" out for ● Watches are one-shot - if you want continuous monitoring of a znode, you have to reset the watch after each event ● Too many clients watches on a single znode creates a "herd effect" - lots of clients get notifications at the same time and cause spikes in load ● Potential for missing changes ● All watches are executed in a single, separate thread (be careful about synchronization)
  • 16. Building blocks ● Hierarchical nodes ● Parent and leaf nodes can have data ● Two special types of nodes - ephemeral and sequential ● Watch mechanism ● Consistency guarantees ○ Order of updates is maintained ○ Updates are atomic ○ Znodes are versioned for MVCC ○ Many more
  • 17. The Fun Stuff Recipes: ● Lock ● Barrier ● Queue ● Two-phase commit ● Leader election ● Group membership
  • 18. Demo Time! Group membership (i.e., the easy one) Recipe: ● Members register a sequential ephemeral node under the group node ● Everyone keeps a watch on the group node for new children
  • 19. Lots of boilerplate ● Synchronize the asynchronous connection (using a latch or something) ● Handling disconnects/reconnects ● Exception handling ● Ensuring paths exist (nothing like mkdir -p) ● Resetting watches ● Cleaning up
  • 20. What happens? ● Everyone writes their own high level wrapper/connection manager ○ ZooKeeperWrapper ○ ZooKeeperSession ○ (w+)ZooKeeper ○ ZooKeeper(w+)
  • 21. Open Source, FTW! Luckily, some smart people have open sourced their ZooKeeper utilities/wrappers ● Netflix Curator - Netflix/curator ● Linkedin - linkedin/linkedin-zookeeper ● Many others
  • 22. Netflix Curator ● Handles the connection management ● Implements many recipes ○ leader election ○ locks, queues, and barriers ○ counters ○ path cache ● Bonus: service discovery implementation (we use this)
  • 23. Demo Time! Group membership refactored with Curator ● EnsurePath is nice ● Robust connection management is awesome ● Exceptions are more sane
  • 24. Thoughts on Curator i.e., my non-expert subjective opinions ● Good level of abstraction - doesn't do anything "magical" ● Doesn't hide ZooKeeper ● Weird API design (builder soup) ● Extensive, well tested recipe support ● It works!
  • 25. ZooKeeper in the wild Some use cases
  • 26. Use case: Solr 4.0 Used in "Solr cloud" mode for: ● Cluster management - what machines are available and where are they located ● Leader election - used for picking a shard as the "leader" ● Consolidated config storage ● Watches allow for very non-chatty steady- state ● Herd effect not really an issue
  • 27. Use case: Kafka ● Linkedin's distributed pub/sub system ● Queues are persistent ● Clients request a slice of a queue (offset, length) ● Brokers are registered in ZooKeeper, clients load balance requests among live brokers ● Client state (last consumed offset) is stored in ZooKeeper ● Client rebalancing algorithm, similar to leader election
  • 28. Use case: LucidWorks Big Data ● We use Curator's service discovery to register REST services ● Nice for SOA ● Took 1 dev (me) 1 day to get something functional (mostly reading Curator docs) ● So far, so good!
  • 29. Review of "gotchas" ● Watch execution is single threaded and synchronized ● Can't reliably get every change for a znode ● Excessive watchers on the same znode (herd effect) Some new ones ● GC pauses: if your application is prone to long GC pauses, make sure your session timeout is sufficiently long ● Catch-all watches: if you use one Watcher for everything, it can be tedious to infer exactly what happened
  • 30. Four letter words The ZooKeeper server responds to a few "four letter word" commands via TCP or Telnet* > echo ruok | nc localhost 2181 imok I'm glad you're OK, ZooKeeper - really I am. * http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_zkCommands
  • 31. Quorums In a multi-node deployment (aka, ZooKeeper Quorum), it is best to use an odd number of machines. ZooKeeper uses majority voting, so it can tolerate ceil(N/2)-1 machine failures and still function properly.
  • 32. Multi-tenancy ZooKeeper supports "chroot" at the session level. You can add a path to the connection string that will be implicitly prefixed to everything you do: new ZooKeeper("localhost:2181/my/app"); Curator also supports this, but at the application level: CuratorFrameworkFactory.builder() .namespace("/my/app");
  • 33. Python client Dumb wrapper around C client, not very Pythonic import zookeeper zk_handle = zookeeper.init("localhost:2181") zookeeper.exists(zk_handle, "/demo") zookeeper.get_children(zk_handle, "/demo") Stuff in contrib didn't work for me, I used a statically linked version: zc-zookeeper-static
  • 34. Other clients Included in ZooKeeper under src/contrib: ● C (this is what the Python client uses) ● Perl (again, using the C client) ● REST (JAX-RS via Jersey) ● FUSE? (strange) 3rd-party client implementations: ● Scala, courtesy of Twitter ● Several others
  • 35. Overview ● Basics of ZooKeeper (znode types, watches) ● High-level recipes (group membership, et al.) ● Lots of boilerplate for basic functionality ● 3rd party helpers (Curator, et al.) ● Gotchas and other miscellany