SlideShare a Scribd company logo
1 of 40
Download to read offline
June 29, 2013
Taming Pythons with
ZooKeeper
Wednesday, 3 July 13
$ whoami
Wednesday, 3 July 13
Jyrki Pulliainen
@nailor
jyrki@spotify.com
Wednesday, 3 July 13
Wednesday, 3 July 13
ZooKeeper?
Wednesday, 3 July 13
- This talk is about ZooKeeper.
- Preaching Java software in Python conference. I can think of more healthier things to do too.
- On side note, our Product Owner is really damn good at this game
ZooKeeper!
Wednesday, 3 July 13
- Apache project, Yahoo 2007
- Consistency & Partition tolerance
- Filesystem like, actually can be viewed as a trie, store data in directories too
- In memory, limits the dataset you can store. Maximum zookeeper node, znode, data size 1M
The Tao of
ZooKeeper
7
Wednesday, 3 July 13
Orderly, Reliable, Efficient, Timely, Contention free, ambition free
Wednesday, 3 July 13
June 29, 2013
One library for the enterprise
Curator, from Netflix
Wednesday, 3 July 13
June 29, 2013
Seven for the pythonistas
gevent-zookeeper
zkpython
zc.zk
pykeeper
twitter’s zookeeper library
zoop
txzookeeper
Wednesday, 3 July 13
- gevent-zookeeper -> Spotify
- zkpython segfaults
- Others have somewhat OK implementations, but lack core features
One Library to
rule them all*
* unless you are running twisted
Wednesday, 3 July 13
- txzookeeper still valid for twisted
Kazoo
Wednesday, 3 July 13
- Origins from the Nimbus project
- Ben Bangert as the Sauron of ZooKeeper
- Not Frodo, that bastard wanted to destroy the perfectly good ring.
- All Python, including the protocol. No more segfaults!
CRUD
ZooKeeper CRUD
Let’s talk about KaZoo
13
Wednesday, 3 July 13
Create, Read, Update, Delete
All basic operations available as async too, but we’ll focus on the synchronous use
First we need to connect!
Text
from kazoo.client import KazooClient
zk = KazooClient(hosts='127.0.0.1:2181')
zk.start()
# ...
zk.stop()
TextText
Wednesday, 3 July 13
Easy to connect to one host, multiple host, with namespace....
ZooKeeper supports connection namespacing!
Bonus: get notified when the connection state changes
First we need to connect!
Text
from kazoo.client import KazooClient
zk = KazooClient(hosts='127.0.0.1:2181')
zk.start()
# ...
zk.stop()
TextText
zk = KazooClient(hosts='127.0.0.1:2181,127.0.0.2:2181')
Wednesday, 3 July 13
Easy to connect to one host, multiple host, with namespace....
ZooKeeper supports connection namespacing!
Bonus: get notified when the connection state changes
First we need to connect!
Text
from kazoo.client import KazooClient
zk = KazooClient(hosts='127.0.0.1:2181')
zk.start()
# ...
zk.stop()
Text
zk = KazooClient(hosts='127.0.0.1:2181/namespace,127.0.0.2:2181')
Text
zk = KazooClient(hosts='127.0.0.1:2181,127.0.0.2:2181')
Wednesday, 3 July 13
Easy to connect to one host, multiple host, with namespace....
ZooKeeper supports connection namespacing!
Bonus: get notified when the connection state changes
Create
zk.create('/europython', b'2013')
Wednesday, 3 July 13
Adding nodes easy, helpers exist for recursive creation
Ephemeral ZK feature, session + heartbeats, can’t have children!
Incremental: guaranteed ever increasing 10 digit number in node name
Create
zk.create('/europython', b'2013')
zk.create('/europython/jyrki', ephemeral=True)
Wednesday, 3 July 13
Adding nodes easy, helpers exist for recursive creation
Ephemeral ZK feature, session + heartbeats, can’t have children!
Incremental: guaranteed ever increasing 10 digit number in node name
Create
zk.create('/europython', b'2013')
zk.create('/europython/jyrki', ephemeral=True)
zk.create('/europython/sequential', sequence=True)
Wednesday, 3 July 13
Adding nodes easy, helpers exist for recursive creation
Ephemeral ZK feature, session + heartbeats, can’t have children!
Incremental: guaranteed ever increasing 10 digit number in node name
Read
Text
zk.get('/europython')
Wednesday, 3 July 13
Read
Text
zk.get('/europython')
zk.exists('/europython/jyrki')
Wednesday, 3 July 13
Read
Text
zk.get('/europython')
zk.exists('/europython/jyrki')
zk.get_children('/europython')
Wednesday, 3 July 13
Update & Delete
zk.set_data('/europython/jyrki', b'nervous')
Wednesday, 3 July 13
Update & Delete
zk.set_data('/europython/jyrki', b'nervous')
zk.delete('/europython/jyrki')
Wednesday, 3 July 13
Wednesday, 3 July 13
Distributed locks?
Barrier?
Semaphores?
Counters?
Elections?
Wednesday, 3 July 13
Textfrom kazoo.recipe import <your-favourite-thing>
Wednesday, 3 July 13
Of course it does not have everything from curator
Want to know when things change?
Wednesday, 3 July 13
watchers
Wednesday, 3 July 13
Text
zk.exists('/europython/wine', watch=callback)
zk.get('/europython/wine', watch=callback)
zk.get_children('/europython/dinners', watch=callback)
Wednesday, 3 July 13
from kazoo.recipe.watchers import DataWatch, ChildWatch
@DataWatch('/path/to/node')
def data_callback(data, stat):
# ...
do_something
@ChildWatch('/path/to/node')
def child_callback(children):
# ...
do_something
Wednesday, 3 July 13
TESTS
Wednesday, 3 July 13
What if something goes
WRONG?
Wednesday, 3 July 13
sys.exit()Wednesday, 3 July 13
Stand back!
It’s time for real life example
Wednesday, 3 July 13
Wednesday, 3 July 13
SEARCHED FOR THE NEWEST
JUSTIN BIEBER
Encryption keys were
not available to play it.
Wednesday, 3 July 13
SUMMARY
Wednesday, 3 July 13
Guess what, we’re hiring
Wednesday, 3 July 13
Thank You!
jyrki@spotify.com
@nailor
Wednesday, 3 July 13

More Related Content

What's hot

Data Processing @ bit.ly - Posscon 2011
Data Processing @ bit.ly - Posscon 2011Data Processing @ bit.ly - Posscon 2011
Data Processing @ bit.ly - Posscon 2011
jehiah
 
Active support事始め
Active support事始めActive support事始め
Active support事始め
Jun Yokoyama
 

What's hot (20)

Alta performance com Python
Alta performance com PythonAlta performance com Python
Alta performance com Python
 
Intel IoT webinar #1 - Tedison presentation
Intel IoT webinar  #1 - Tedison presentation Intel IoT webinar  #1 - Tedison presentation
Intel IoT webinar #1 - Tedison presentation
 
Voldemort collections library
Voldemort collections libraryVoldemort collections library
Voldemort collections library
 
Data Processing @ bit.ly - Posscon 2011
Data Processing @ bit.ly - Posscon 2011Data Processing @ bit.ly - Posscon 2011
Data Processing @ bit.ly - Posscon 2011
 
CIALUG: Encrypt all the things
CIALUG: Encrypt all the thingsCIALUG: Encrypt all the things
CIALUG: Encrypt all the things
 
Managing Windows Systems with Puppet - PuppetConf 2013
Managing Windows Systems with Puppet - PuppetConf 2013Managing Windows Systems with Puppet - PuppetConf 2013
Managing Windows Systems with Puppet - PuppetConf 2013
 
Active support事始め
Active support事始めActive support事始め
Active support事始め
 
5 Time Saving Bash Tricks
5 Time Saving Bash Tricks5 Time Saving Bash Tricks
5 Time Saving Bash Tricks
 
gemdiff
gemdiffgemdiff
gemdiff
 
Videos on Android - Stuff What I Learned
Videos on Android - Stuff What I LearnedVideos on Android - Stuff What I Learned
Videos on Android - Stuff What I Learned
 
Puppet without Root - PuppetConf 2013
Puppet without Root - PuppetConf 2013Puppet without Root - PuppetConf 2013
Puppet without Root - PuppetConf 2013
 
A Brief Introduction to Writing and Understanding Puppet Modules
A Brief Introduction to Writing and Understanding Puppet ModulesA Brief Introduction to Writing and Understanding Puppet Modules
A Brief Introduction to Writing and Understanding Puppet Modules
 
Creating beautiful puppet modules with puppet-lint
Creating beautiful puppet modules with puppet-lintCreating beautiful puppet modules with puppet-lint
Creating beautiful puppet modules with puppet-lint
 
pam_container -- jeszcze lżejsza wirtualizacja
pam_container -- jeszcze lżejsza wirtualizacjapam_container -- jeszcze lżejsza wirtualizacja
pam_container -- jeszcze lżejsza wirtualizacja
 
Readme
ReadmeReadme
Readme
 
(Fun clojure)
(Fun clojure)(Fun clojure)
(Fun clojure)
 
Json perl example
Json perl exampleJson perl example
Json perl example
 
The Art, Joy, and Power of Creating Musical Programs (JFugue at SXSW Interact...
The Art, Joy, and Power of Creating Musical Programs (JFugue at SXSW Interact...The Art, Joy, and Power of Creating Musical Programs (JFugue at SXSW Interact...
The Art, Joy, and Power of Creating Musical Programs (JFugue at SXSW Interact...
 
Surf iOS版 中文用户指南
Surf iOS版 中文用户指南Surf iOS版 中文用户指南
Surf iOS版 中文用户指南
 
JFugue, Music, and the Future of Java [JavaOne 2016, CON1851]
JFugue, Music, and the Future of Java [JavaOne 2016, CON1851]JFugue, Music, and the Future of Java [JavaOne 2016, CON1851]
JFugue, Music, and the Future of Java [JavaOne 2016, CON1851]
 

Viewers also liked

Apache ZooKeeper TechTuesday
Apache ZooKeeper TechTuesdayApache ZooKeeper TechTuesday
Apache ZooKeeper TechTuesday
Andrei Savu
 
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
 
Dynamic Reconfiguration of Apache ZooKeeper
Dynamic Reconfiguration of Apache ZooKeeperDynamic Reconfiguration of Apache ZooKeeper
Dynamic Reconfiguration of Apache ZooKeeper
DataWorks Summit
 
Centralized Application Configuration with Spring and Apache Zookeeper
Centralized Application Configuration with Spring and Apache ZookeeperCentralized Application Configuration with Spring and Apache Zookeeper
Centralized Application Configuration with Spring and Apache Zookeeper
Ryan Gardner
 

Viewers also liked (20)

ZooKeeper (and other things)
ZooKeeper (and other things)ZooKeeper (and other things)
ZooKeeper (and other things)
 
ZooKeeper Futures
ZooKeeper FuturesZooKeeper Futures
ZooKeeper Futures
 
Zookeeper Introduce
Zookeeper IntroduceZookeeper Introduce
Zookeeper Introduce
 
Apache ZooKeeper TechTuesday
Apache ZooKeeper TechTuesdayApache ZooKeeper TechTuesday
Apache ZooKeeper TechTuesday
 
Zookeeper
ZookeeperZookeeper
Zookeeper
 
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 In Action
Zookeeper In ActionZookeeper In Action
Zookeeper In Action
 
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
 
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...
 
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!
 
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)
 
ZooKeeper - wait free protocol for coordinating processes
ZooKeeper - wait free protocol for coordinating processesZooKeeper - wait free protocol for coordinating processes
ZooKeeper - wait free protocol for coordinating processes
 
Jcconf 2016 zookeeper
Jcconf 2016 zookeeperJcconf 2016 zookeeper
Jcconf 2016 zookeeper
 
Zookeeper
ZookeeperZookeeper
Zookeeper
 
Dynamic Reconfiguration of Apache ZooKeeper
Dynamic Reconfiguration of Apache ZooKeeperDynamic Reconfiguration of Apache ZooKeeper
Dynamic Reconfiguration of Apache ZooKeeper
 
Centralized Application Configuration with Spring and Apache Zookeeper
Centralized Application Configuration with Spring and Apache ZookeeperCentralized Application Configuration with Spring and Apache Zookeeper
Centralized Application Configuration with Spring and Apache Zookeeper
 
Apache Zookeeper 分布式服务框架
Apache Zookeeper 分布式服务框架Apache Zookeeper 分布式服务框架
Apache Zookeeper 分布式服务框架
 
Zookeeper
ZookeeperZookeeper
Zookeeper
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeper
 
Curator intro
Curator introCurator intro
Curator intro
 

Similar to Taming Pythons with ZooKeeper

실시간 웹 협업도구 만들기 V0.3
실시간 웹 협업도구 만들기 V0.3실시간 웹 협업도구 만들기 V0.3
실시간 웹 협업도구 만들기 V0.3
NAVER D2
 
Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...
NETWAYS
 

Similar to Taming Pythons with ZooKeeper (20)

Don't do this
Don't do thisDon't do this
Don't do this
 
실시간 웹 협업도구 만들기 V0.3
실시간 웹 협업도구 만들기 V0.3실시간 웹 협업도구 만들기 V0.3
실시간 웹 협업도구 만들기 V0.3
 
Symfony2 and MongoDB - MidwestPHP 2013
Symfony2 and MongoDB - MidwestPHP 2013   Symfony2 and MongoDB - MidwestPHP 2013
Symfony2 and MongoDB - MidwestPHP 2013
 
20131001 lab meeting
20131001 lab meeting20131001 lab meeting
20131001 lab meeting
 
Playing With Ruby
Playing With RubyPlaying With Ruby
Playing With Ruby
 
Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...
 
batou - multi(component|host|environment|.*) deployment
batou - multi(component|host|environment|.*) deploymentbatou - multi(component|host|environment|.*) deployment
batou - multi(component|host|environment|.*) deployment
 
Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...Building scalable applications while scaling your infrastructure by rhommel l...
Building scalable applications while scaling your infrastructure by rhommel l...
 
How to write better code: in-depth best practices for writing readable, simpl...
How to write better code: in-depth best practices for writing readable, simpl...How to write better code: in-depth best practices for writing readable, simpl...
How to write better code: in-depth best practices for writing readable, simpl...
 
How to write better code: in-depth best practices for writing readable, simpl...
How to write better code: in-depth best practices for writing readable, simpl...How to write better code: in-depth best practices for writing readable, simpl...
How to write better code: in-depth best practices for writing readable, simpl...
 
Storyplayer
StoryplayerStoryplayer
Storyplayer
 
Fun with Functional Programming in Clojure - John Stevenson - Codemotion Amst...
Fun with Functional Programming in Clojure - John Stevenson - Codemotion Amst...Fun with Functional Programming in Clojure - John Stevenson - Codemotion Amst...
Fun with Functional Programming in Clojure - John Stevenson - Codemotion Amst...
 
The future of async i/o in Python
The future of async i/o in PythonThe future of async i/o in Python
The future of async i/o in Python
 
A couple of things about PostgreSQL...
A couple of things  about PostgreSQL...A couple of things  about PostgreSQL...
A couple of things about PostgreSQL...
 
Workers of the web - BrazilJS 2013
Workers of the web - BrazilJS 2013Workers of the web - BrazilJS 2013
Workers of the web - BrazilJS 2013
 
Bring the Noise
Bring the NoiseBring the Noise
Bring the Noise
 
Web directions code 13 notes
Web directions code 13 notesWeb directions code 13 notes
Web directions code 13 notes
 
Vaadin 7
Vaadin 7Vaadin 7
Vaadin 7
 
Introduction to Vaadin 7
Introduction to Vaadin 7Introduction to Vaadin 7
Introduction to Vaadin 7
 
Zen of Akka
Zen of AkkaZen of Akka
Zen of Akka
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Taming Pythons with ZooKeeper