SlideShare a Scribd company logo
java.util.concurrent
for distributed coordination
Berlin Expert Days 2019
@metanet
Hazelcast
The leading open source Java IMDG
Distributed Java collections, concurrency primitives, messaging
Caching, application scaling, distributed coordination 🎉
Hazelcast Cloud
https://hazelcast.cloud
Hazelcast Jet: In-memory stream and fast batch processing
#bedcon
@metanet
Agenda
What is distributed coordination?
How distributed coordination APIs evolved over time?
Why to use java.util.concurrent.*
Demo on Hazelcast IMDG 3.12
#bedcon
#
#bedcon
@metanet
Distributed Coordination
Leader election
Synchronization
Group membership
Configuration and metadata management
#bedcon
@metanet
Challenges
Concurrency
Strong consistency
Partial failures
Crashes
Network failures
Timing failures
#bedcon
java.util.concurrent for Distributed Coordination - Berlin Expert Days 2019
@metanet
Consensus algorithms under the hood
CP with respect to CAP
Deployed as a central repository
APIs for coordination tasks
Distributed Coordination Systems
#bedcon
Google Chubby (Paxos)
@metanet
#bedcon
Google Chubby (Paxos)
Apache ZooKeeper (ZAB)
@metanet
#bedcon
Google Chubby (Paxos)
Apache ZooKeeper (ZAB)
etcd (Raft)
@metanet
#bedcon
@metanet
/services
/payment
/product
/photo
/services
/services/payment
/services/product
/services/product/photo
Chubby & ZooKeeper etcd
#bedcon
@metanet
Chubby
Locking APIs Recipes
ZooKeeper etcd
#bedcon
@metanet
A Simple Locking Recipe for ZooKeeper
1. create an ephemeral znode “/lock”
2. if success, enter to the critical section
3. else, register a watch on “/lock”
4. when the watch is notified, i.e., the lock is released, retry step #1
#bedcon
@metanet
Chubby
Locking APIs Recipes
“Friends don't let
friends write
ZK recipes.”
Apache Curator
Tech Notes #6
Leader election and
distributed lock
primitives
ZooKeeper etcd
#bedcon
@metanet
High-level APIs
A low-level file-system / KV store API is
- easy to misuse,
- not suitable for all coordination tasks.
“Consensus in the Cloud: Paxos Systems Demystified”
High-level APIs minimise guesswork and development effort.
java.util.concurrent.* in JDK
#bedcon
Google Chubby (Paxos)
Apache ZooKeeper (ZAB)
etcd (Raft)
Hazelcast IMDG 3.12
java.util.concurrent
on top of Raft
@metanet
#bedcon
@metanet
An Opinionated & High-Level Framework
IAtomicLong, IAtomicReference,
ICountDownLatch, ISemaphore, FencedLock
Well-defined failure semantics
CP with respect to CAP
DIY-style tested with Jepsen
#bedcon
@metanet
Strong consistency
Used for building RSM.
Handles crashes and network failures.
Operational as long as the majority is up.
Consensus
#bedcon
Node
Count
Majority Degree of
Fault Tolerance
2 2 0
3 2 1
4 3 1
5 3 2
6 4 2
7 4 3
@metanet
Understandability as a primary goal.
Runtime concerns (snapshotting, dynamic membership)
Performance optimizations (fast reads, batching)
https://raft.github.io
Why Raft?
#bedcon
@metanet
A leader is elected among the nodes.
The leader replicates ops to the followers.
All nodes run the ops in the same order.
Result of a commit is never lost.
Replicated State Machines
#bedcon
@metanet
ENOUGH TALK
LET’S DEMO
@metanet
https://github.com/metanet/juc-talk
DEMO #1: Configuration management
#bedcon
@metanet
FencedLock
Linearizable distributed impl of java.util.concurrent.locks.Lock
Suitable for both fine-grained and coarse-grained locking
#bedcon
@metanet
CP Sessions
A session starts on the first lock / semaphore request.
Session heartbeats are periodically committed in the background.
If no heartbeat for some time (session TTL), the session is closed.
Auto-release mechanism for FencedLock and ISemaphore
#bedcon
@metanet
DEMO #2: Adding Redundancy
We use FencedLock for leader election.
#bedcon
@metanet
CP sessions offer a trade-off between safety and liveness.
#bedcon
@metanet
DEMO #3: Fencing-off Stale Lock Holders
“How to do distributed locking”
“Distributed locks are dead; long live distributed locks!”
#bedcon
@metanet
Recap
Avoid writing your own implementations for coordination.
High-level APIs minimise guesswork and development effort.
java.util.concurrent.* FTW!
Operational simplicity matters.
Dynamic clustering
Horizontal scalability
#bedcon
@metanet
Current Status
Disk persistence (WIP - 95% done)
Tooling & Metrics (WIP - 95% done)
KV Store (in roadmap)
Event Listeners (in roadmap)
#bedcon
@metanet
Resources
https://github.com/metanet/juc-talk (demos)
Hazelcast IMDG Docs
CP Subsystem Code Samples
https://hazelcast.com/blog/author/ensarbasri
Hazelcast IMDG 3.12
#bedcon
Dankeschön!
Berlin Expert Days
#bedcon

More Related Content

PDF
Event Machine
PDF
Minko - Flash Conference #5
PDF
Latency tracing in distributed Java applications
PPTX
Best practices of building data streaming API
PPT
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
PDF
JRuby and Google App Engine
PPTX
OSCONF Hyderabad - Shorten all URLs!
PDF
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Event Machine
Minko - Flash Conference #5
Latency tracing in distributed Java applications
Best practices of building data streaming API
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
JRuby and Google App Engine
OSCONF Hyderabad - Shorten all URLs!
Highly Surmountable Challenges in Ruby+OMR JIT Compilation

Similar to java.util.concurrent for Distributed Coordination - Berlin Expert Days 2019 (20)

PDF
java.util.concurrent for Distributed Coordination, Riga DevDays 2019
PDF
java.util.concurrent for Distributed Coordination, GeeCON Krakow 2019
PDF
java.util.concurrent for Distributed Coordination, JEEConf 2019
PDF
ClickHouse Keeper
PDF
Abhishek Kumar - CloudStack Locking Service
PPTX
Comparison between zookeeper, etcd 3 and other distributed coordination systems
PPTX
Winter is coming? Not if ZooKeeper is there!
PPTX
Hazelcast Jet v0.4 - August 9, 2017
PDF
SpringOne 2016 in a nutshell
PPT
Shopzilla On Concurrency
PPTX
Think Distributed: The Hazelcast Way
PPTX
Distributed caching and computing v3.7
PDF
Scalability, Availability & Stability Patterns
PPTX
Zookeeper
PDF
Introduction to Apache ZooKeeper | Big Data Hadoop Spark Tutorial | CloudxLab
PDF
2012-08-21 NRO GED Industry Day
PPT
Shopzilla On Concurrency
PPTX
Building a Modern Website for Scale (QCon NY 2013)
PPTX
Istanbul JUG - 3 performance improvements with Hazelcast IMDG in your microse...
PPTX
YaJUG/Kaiserslautern JUG - 3 easy improvements in your microservices architec...
java.util.concurrent for Distributed Coordination, Riga DevDays 2019
java.util.concurrent for Distributed Coordination, GeeCON Krakow 2019
java.util.concurrent for Distributed Coordination, JEEConf 2019
ClickHouse Keeper
Abhishek Kumar - CloudStack Locking Service
Comparison between zookeeper, etcd 3 and other distributed coordination systems
Winter is coming? Not if ZooKeeper is there!
Hazelcast Jet v0.4 - August 9, 2017
SpringOne 2016 in a nutshell
Shopzilla On Concurrency
Think Distributed: The Hazelcast Way
Distributed caching and computing v3.7
Scalability, Availability & Stability Patterns
Zookeeper
Introduction to Apache ZooKeeper | Big Data Hadoop Spark Tutorial | CloudxLab
2012-08-21 NRO GED Industry Day
Shopzilla On Concurrency
Building a Modern Website for Scale (QCon NY 2013)
Istanbul JUG - 3 performance improvements with Hazelcast IMDG in your microse...
YaJUG/Kaiserslautern JUG - 3 easy improvements in your microservices architec...
Ad

More from Ensar Basri Kahveci (12)

PDF
Replication Distilled: Hazelcast Deep Dive @ In-Memory Computing Summit San F...
PDF
Replication Distilled: Hazelcast Deep Dive - Berlin Expert Days 2018
PDF
From AP to CP and Back: The Curious Case of Hazelcast (jdk.io 2018)
PDF
Distributed Systems Theory for Mere Mortals - Software Craftsmanship Turkey
PDF
Distributed Systems Theory for Mere Mortals - Topconf Dusseldorf October 2017
PDF
Distributed Systems Theory for Mere Mortals - GeeCON Krakow May 2017
PDF
Replication in the Wild - Warsaw Cloud Native Meetup - May 2017
PDF
Distributed Systems Theory for Mere Mortals - Java Day Istanbul May 2017
PDF
Client-centric Consistency Models
PDF
Replication in the Wild
PDF
Distributed Systems Theory for Mere Mortals
PDF
Ankara Jug - Practical Functional Programming with Scala
Replication Distilled: Hazelcast Deep Dive @ In-Memory Computing Summit San F...
Replication Distilled: Hazelcast Deep Dive - Berlin Expert Days 2018
From AP to CP and Back: The Curious Case of Hazelcast (jdk.io 2018)
Distributed Systems Theory for Mere Mortals - Software Craftsmanship Turkey
Distributed Systems Theory for Mere Mortals - Topconf Dusseldorf October 2017
Distributed Systems Theory for Mere Mortals - GeeCON Krakow May 2017
Replication in the Wild - Warsaw Cloud Native Meetup - May 2017
Distributed Systems Theory for Mere Mortals - Java Day Istanbul May 2017
Client-centric Consistency Models
Replication in the Wild
Distributed Systems Theory for Mere Mortals
Ankara Jug - Practical Functional Programming with Scala
Ad

Recently uploaded (20)

PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
System and Network Administraation Chapter 3
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
top salesforce developer skills in 2025.pdf
PPTX
assetexplorer- product-overview - presentation
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Introduction to Artificial Intelligence
PPTX
history of c programming in notes for students .pptx
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
Digital Strategies for Manufacturing Companies
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Reimagine Home Health with the Power of Agentic AI​
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Wondershare Filmora 15 Crack With Activation Key [2025
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
System and Network Administraation Chapter 3
Adobe Illustrator 28.6 Crack My Vision of Vector Design
top salesforce developer skills in 2025.pdf
assetexplorer- product-overview - presentation
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Which alternative to Crystal Reports is best for small or large businesses.pdf
Introduction to Artificial Intelligence
history of c programming in notes for students .pptx
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Digital Strategies for Manufacturing Companies
Operating system designcfffgfgggggggvggggggggg
wealthsignaloriginal-com-DS-text-... (1).pdf
Odoo POS Development Services by CandidRoot Solutions

java.util.concurrent for Distributed Coordination - Berlin Expert Days 2019