1 / 55

Logic and Lattices for Distributed Programming

Logic and Lattices for Distributed Programming. Neil Conway , William R. Marczak, Peter Alvaro, Joseph M. Hellerstein UC Berkeley. David Maier Portland State University. Distributed Programming: Key Challenges. Partial Failure. Asynchrony. Dealing with Disorder. Enforce global order

salim
Download Presentation

Logic and Lattices for Distributed Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Logic and Lattices for Distributed Programming Neil Conway, William R. Marczak, Peter Alvaro, Joseph M. Hellerstein UC Berkeley David Maier Portland State University

  2. Distributed Programming: Key Challenges Partial Failure Asynchrony

  3. Dealing with Disorder Enforce global order • Paxos, Two-Phase Commit, GCS, … • “Strong Consistency” Tolerate disorder • Programmer must ensure correct behavior for many possible network orders • “Eventual Consistency” • Typical goal: replicas converge to same final state

  4. Dealing with Disorder Enforce global order • Paxos, Two-Phase Commit, GCS, … • “Strong Consistency” Tolerate disorder • Programmer must ensure correct behavior for many possible network orders • “Eventual Consistency” • Typical goal: replicas converge to same final state

  5. Goal:Make it easier to writeprogramson top ofeventual consistency

  6. This Talk • Prior Work • Convergent Modules (CRDTs) • Monotonic Logic (CALM) • BloomL • Case Study

  7. Write: {Alice, Bob, Carol} Read: {Alice, Bob} Students{Alice, Bob, Carol} Students{Alice, Bob} Client0 How to resolve? Write: {Alice, Bob, Dave} Read: {Alice, Bob} Students{Alice, Bob, Dave} Students{Alice, Bob} Client1

  8. Students{Alice, Bob, Carol, Dave} Client0 Merge = Set Union Students{Alice, Bob, Carol, Dave} Client1

  9. Commutative Operations • Common design pattern • Formalized as CRDTs: Convergent and Commutative Replicated Data Types • Shapiro et al., INRIA (2009-2012) • Based on join semilattices

  10. Lattices hS,t,?iis a bounded join semilatticeiff: • S is a set • t is a binary operator (“least upper bound”) • Associative, commutative, and idempotent • Induces a partial order on S: x·Sy if xty = y • Informally, “merge function” for elements of S • ? is the “least” element in S • 8x2S: ?t x= x

  11. Time IncreasingInteger(LUB = Max) Set (LUB = Union) Boolean(LUB = Or)

  12. Students{Alice, Bob, Carol} Students{Alice, Bob, Carol, Dave} Read: {Alice, Bob, Carol, Dave} Client0 Teams{<Alice, Bob>} Teams{<Alice, Bob>,<Carol, Dave>} Teams{<Alice, Bob>,<Carol, Dave>} Read: {<Alice,Bob>} Write: {<Alice,Bob>, <Carol,Dave>} Replica Synchronization Students{Alice, Bob, Carol} Students{Alice, Bob, Carol, Dave} Remove: {Dave} Client1 Teams{<Alice, Bob>,<Carol, Dave>} Teams{<Alice, Bob>} Teams{<Alice, Bob>,<Carol, Dave>}

  13. Students{Alice, Bob, Carol, Dave} Students{Alice, Bob, Carol} Read: {Alice, Bob, Carol} Client0 Teams{<Alice, Bob>} Teams{<Alice, Bob>} Read: {<Alice,Bob>} Replica Synchronization Nondeterministic Outcome! Students{Alice, Bob, Carol} Students{Alice, Bob, Carol, Dave} Remove: {Dave} Client1 Teams{<Alice, Bob>} Teams{<Alice, Bob>}

  14. Problem:Composition of CRDTs canresult in non-determinism

  15. Possible Solution:Encapsulate all distributedstate in a single CRDT Hard to design,verify, and test Doesn’t scale with application size

  16. Goal:Design a language that allowssafe composition of CRDTs

  17. Solution: … Datalog? • Concurrent work: distributed programming using Datalog • P2 (2006-2010) • Bloom (2010-2012) • Monotonic logic: building block for convergent distributed programs

  18. Monotonic Logic • As input set grows, output set does not shrink • “Retraction-free” • Order independent • e.g., map, filter, join, union, intersection Non-Monotonic Logic • New inputs might retract previous outputs • Order sensitive • e.g., aggregation, negation

  19. Monotonicity and Determinism Agents learn strictly more knowledge over time Different learning order, same final outcome Result:Program is deterministic!

  20. CALM Analysis All monotone programs are deterministic Simple syntactic test for monotonicity Result: Whole-program static analysis foreventual consistency ConsistencyAs LogicalMonotonicity

  21. Problem:CALM only applies to programs over growing sets Version Numbers Timestamps Threshold Tests

  22. Quorum Vote • A coordinator accepts votes from agents • Count # of votes • When Count(Votes) > k, send “success” message

  23. Quorum Vote • A coordinator accepts votes from agents • Count # of votes • When Count(Votes) > k, send “success” message Aggregation isnon-monotonic!

  24. BloomL Constructs

  25. Monotone Functions f : ST is a monotone function iff 8a,b2S : a·Sb) f(a)·Tf(b)

  26. Time Monotone function fromset  increase-int Monotone functionfromincrease-intboolean size() >= 5 IncreasingInteger(LUB = Max) Set(LUB = Union) Boolean(LUB = Or)

  27. Quorum Vote in BloomL QUORUM_SIZE=5 RESULT_ADDR="example.org" classQuorumVote includeBud state do channel :vote_chn, [:@addr, :voter_id] channel :result_chn, [:@addr] lset:votes lmax:vote_cnt lbool:got_quorum end bloom do votes <=vote_chn {|v|v.voter_id} vote_cnt<=votes.size got_quorum<=vote_cnt.gt_eq(QUORUM_SIZE) result_chn<~got_quorum.when_true { [RESULT_ADDR] } end end Annotated Ruby class Communication interfaces Program state Lattice state declarations Monotonic  CALM Accumulate votesinto set Monotone function: set ! max Monotone function: max !bool Program logic Merge function for set lattice Threshold test on bool (monotone)

  28. BloomL Features • Generalizes logic programming to lattices • Integration of relational-style queries and functions over lattices • Efficient incremental evaluation scheme • Library of built-in lattices • Booleans, increasing/decreasing integers, sets, multisets, maps, … • API for defining custom lattices

  29. Case Studies Key-Value Store • Object versioning via vector clocks • Quorum replication Replicated Shopping Cart • Using custom lattice types to encode domain-specific knowledge

  30. Case Studies Key-Value Store • Object versioning via vector clocks • Quorum replication Replicated Shopping Cart • Using custom lattice types to encode domain-specific knowledge

  31. Case Study: Shopping Carts

  32. Case Study: Shopping Carts

  33. Case Study: Shopping Carts

  34. Case Study: Shopping Carts

  35. Perspectives on Shopping • CRDTs • Individual server replicas converge • Bloom • Checkout is non-monotonic  requires distributed coordination • Built-in BloomL lattice types • Checkout is not a monotone function of any of the built-in lattices

  36. Observation:Once a checkoutoccurs, no more shopping actionscan be performed

  37. Observation:Each client knowswhena checkout can beprocessed“safely”

  38. Monotone Checkout OPS = [1,2,3]Complete OPS = [2,3]Incomplete OPS = [1,2]Incomplete OPS = [2]Incomplete OPS = [3]Incomplete OPS = [1]Incomplete

  39. Monotone Checkout

  40. Monotone Checkout

  41. Monotone Checkout

  42. Monotone Checkout

  43. Shopping Takeaways • Checkout summary is a monotone function of client’s activities • Custom lattice type captures application-specific notion of “forward progress” • “Unsafe” state hidden behind ADT interface

  44. Recap • How to build eventually consistent systems • Write disorderlyprograms • Disorderly state • Lattices • Disorderly computation • Monotone functions over lattices • BloomL • Type system for deterministic behavior • Support for custom lattice types

  45. Thank You!http://www.bloom-lang.net

  46. Backup Slides

  47. Strong Consistency in Industry “… there was a single overarching theme within the keynote talks… strong synchronization of the sort provided by a locking service must be avoided like the plague… [the key] challenge is to find ways of transforming services that might seem to need locking into versions that … can operate correctly without locking.” -- Birman et al.,“Toward a Cloud Computing Research Agenda” (LADIS, 2009)

More Related