java util concurrent for distributed coordination
play

java.util.concurrent for distributed coordination Ensar Basri - PowerPoint PPT Presentation

java.util.concurrent for distributed coordination Ensar Basri Kahveci Hazelcast @metanet Hazelcast The leading open source Java IMDG Distributed Java collections, concurrency primitives, messaging Caching, application scaling, distributed


  1. java.util.concurrent for distributed coordination Ensar Basri Kahveci Hazelcast

  2. @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

  3. @metanet Agenda What is distributed coordination? How distributed coordination APIs evolved over time? java.util.concurrent.* for distributed coordination Demo on Hazelcast IMDG 3.12

  4. #

  5. @metanet Distributed Coordination Leader election Synchronization Group membership Configuration and metadata management

  6. DO IT YOURSELF

  7. @metanet Distributed Coordination Systems Consensus algorithms under the hood CP with respect to CAP Deployed as a central repository APIs for coordination tasks

  8. @metanet Google Chubby (Paxos)

  9. @metanet Google Chubby (Paxos) Apache ZooKeeper (ZAB)

  10. @metanet Google Chubby (Paxos) Apache ZooKeeper (ZAB) etcd (Raft)

  11. @metanet Chubby & ZooKeeper etcd /services /services /payment /services/payment /product /services/product /photo /services/product/photo

  12. @metanet Chubby ZooKeeper etcd Locking APIs Recipes

  13. @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

  14. @metanet Chubby ZooKeeper etcd Locking APIs Recipes Leader election and distributed lock “Friends don't let primitives friends write ZK recipes.” Apache Curator Tech Notes #6

  15. @metanet High-level APIs A low-level file-system / KV store API is - easy to misuse, - not suitable for all coordination tasks. High-level APIs minimise guesswork and development effort. java.util.concurrent.* in JDK

  16. Concurrency Multithreaded Nondeterminism applications Partial failures Distributed applications

  17. @metanet Google Chubby (Paxos) Apache ZooKeeper (ZAB) Hazelcast IMDG 3.12 java.util.concurrent on top of Raft etcd (Raft)

  18. @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

  19. @metanet Why Raft? Understandability as a primary goal Handles crash failures and network failures. Operational as long as the majority is up. Runtime concerns (snapshotting, dynamic membership) Performance optimizations (fast reads, batching) https://raft.github.io

  20. @metanet Replicated State Machines A leader is elected among the nodes. The leader replicates ops to the followers. All nodes run the ops in the same order.

  21. @metanet CP Subsystem Minimal configuration CP primitives and AP data structures in the same cluster Dynamic clustering programmatically or via REST API

  22. @metanet Horizontal Scalability Each CP group runs the Raft algorithm independently. CP primitives can be distributed to multiple CP groups. CP groups can be distributed to CP members.

  23. @metanet ENOUGH TALK LET’S DEMO

  24. @metanet DEMO #1: Configuration management https://github.com/metanet/juc-talk

  25. @metanet FencedLock Linearizable distributed impl of java.util.concurrent.locks.Lock Suitable for both fine-grained and coarse-grained locking

  26. @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

  27. @metanet DEMO #2: Adding Redundancy We use FencedLock for leader election.

  28. @metanet CP sessions offer a trade-off between safety and liveness.

  29. @metanet DEMO #3: Fencing-off Stale Lock Holders “How to do distributed locking” “Distributed locks are dead; long live distributed locks!”

  30. @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

  31. @metanet Future Plans KV Store Event Listeners Disk persistence Tooling

  32. @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

  33. Thanks! In-Memory Computing Summit Europe 2019 Ensar Basri Kahveci Distributed Systems Engineer @ Hazelcast @ metanet

Recommend


More recommend