Disorderly programming. CALM analysis.. The future is already here Nearly all nontrivial systems are (or are becoming) distributed Programming distributed.

Slides:



Advertisements
Similar presentations
Disorderly Distributed Programming with Bloom
Advertisements

Chapter 10: Designing Databases
Distributed DBMS©M. T. Özsu & P. Valduriez Ch.15/1 Outline Introduction Background Distributed Database Design Database Integration Semantic Data Control.
Edelweiss: Automatic Storage Reclamation for Distributed Programming Neil Conway Peter Alvaro Emily Andrews Joseph M. Hellerstein University of California,
BloomUnit Declarative testing for distributed programs Peter Alvaro UC Berkeley.
Based on the text by Jimmy Lin and Chris Dryer; and on the yahoo tutorial on mapreduce at index.html
MapReduce Online Created by: Rajesh Gadipuuri Modified by: Ying Lu.
Dynamo: Amazon's Highly Available Key-value Store Distributed Storage Systems CS presented by: Hussam Abu-Libdeh.
Logic and Lattices for Distributed Programming Neil Conway, William R. Marczak, Peter Alvaro, Joseph M. Hellerstein UC Berkeley David Maier Portland State.
Steven Pelley, Peter M. Chen, Thomas F. Wenisch University of Michigan
EEC 688/788 Secure and Dependable Computing Lecture 12 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
Consistency analysis in bloom a CALM and collected approach peter alvaro, neil conway, joseph m. hellerstein, william r. marczak uc berkeley.
Virtual Synchrony Jared Cantwell. Review Multicast Causal and total ordering Consistent Cuts Synchronized clocks Impossibility of consensus Distributed.
Scaling Distributed Machine Learning with the BASED ON THE PAPER AND PRESENTATION: SCALING DISTRIBUTED MACHINE LEARNING WITH THE PARAMETER SERVER – GOOGLE,
CS 584. A Parallel Programming Model We need abstractions to make it simple. The programming model needs to fit our parallel machine model. Abstractions.
CS 582 / CMPE 481 Distributed Systems
Distributed Systems Fall 2009 Replication Fall 20095DV0203 Outline Group communication Fault-tolerant services –Passive and active replication Highly.
Homework 2 In the docs folder of your Berkeley DB, have a careful look at documentation on how to configure BDB in main memory. In the docs folder of your.
Mapping Techniques for Load Balancing
Amazon’s Dynamo System The material is taken from “Dynamo: Amazon’s Highly Available Key-value Store,” by G. DeCandia, D. Hastorun, M. Jampani, G. Kakulapati,
Maria-Cristina Marinescu Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology A Synthesis Algorithm for Modular Design of.
Maria-Cristina Marinescu Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology High-level Specification and Efficient Implementation.
ECE 526 – Network Processing Systems Design Network Processor Architecture and Scalability Chapter 13,14: D. E. Comer.
Orbe: Scalable Causal Consistency Using Dependency Matrices & Physical Clocks Jiaqing Du, EPFL Sameh Elnikety, Microsoft Research Amitabha Roy, EPFL Willy.
SAP Overview SAP? Company ERP Software package –R/2 –R/3.
Disorderly programming for a distributed world Peter Alvaro UC Berkeley.
Parallel Programming Models Basic question: what is the “right” way to write parallel programs –And deal with the complexity of finding parallelism, coarsening.
Molecular Transactions G. Ramalingam Kapil Vaswani Rigorous Software Engineering, MSRI.
Copyright © George Coulouris, Jean Dollimore, Tim Kindberg This material is made available for private study and for direct.
Reliable Communication in the Presence of Failures Based on the paper by: Kenneth Birman and Thomas A. Joseph Cesar Talledo COEN 317 Fall 05.
Overview – Chapter 11 SQL 710 Overview of Replication
The Vesta Parallel File System Peter F. Corbett Dror G. Feithlson.
Checkpointing and Recovery. Purpose Consider a long running application –Regularly checkpoint the application Expensive task –In case of failure, restore.
Lecture 8 Page 1 CS 111 Online Other Important Synchronization Primitives Semaphores Mutexes Monitors.
Copyright © George Coulouris, Jean Dollimore, Tim Kindberg This material is made available for private study and for direct.
Feb 1, 2001CSCI {4,6}900: Ubiquitous Computing1 Eager Replication and mobile nodes Read on disconnected clients may give stale data Eager replication prohibits.
Chapter 4 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University Building Dependable Distributed Systems.
Blazes: coordination analysis for distributed program Peter Alvaro, Neil Conway, Joseph M. Hellerstein David Maier UC Berkeley Portland State.
Chapter 7: Consistency & Replication IV - REPLICATION MANAGEMENT By Jyothsna Natarajan Instructor: Prof. Yanqing Zhang Course: Advanced Operating Systems.
CS 240A: Databases and Knowledge Bases Analysis of Active Databases Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
Threaded Programming Lecture 1: Concepts. 2 Overview Shared memory systems Basic Concepts in Threaded Programming.
MapReduce: Simplified Data Processing on Large Clusters By Dinesh Dharme.
Tornado: Maximizing Locality and Concurrency in a Shared Memory Multiprocessor Operating System Ben Gamsa, Orran Krieger, Jonathan Appavoo, Michael Stumm.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Replication Steve Ko Computer Sciences and Engineering University at Buffalo.
EEC 688/788 Secure and Dependable Computing Lecture 9 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
1 Information Retrieval and Use De-normalisation and Distributed database systems Geoff Leese September 2008, revised October 2009.
CS 540 Database Management Systems NoSQL & NewSQL Some slides due to Magda Balazinska 1.
Bloom: Big Systems, Small Programs Neil Conway UC Berkeley.
Consistency Analysis in Bloom: a CALM and Collected Approach Authors: Peter Alvaro, Neil Conway, Joseph M. Hellerstein, William R. Marczak Presented by:
Introduction toData structures and Algorithms
Contents. Goal and Overview. Ingredients. The Page Model.
CS 440 Database Management Systems
Distributed Systems – Paxos
Computational Models Database Lab Minji Jo.
Alternative system models
Parallel Programming By J. H. Wang May 2, 2017.
Other Important Synchronization Primitives
The Client/Server Database Environment
MapReduce Computing Paradigm Basics Fall 2013 Elke A. Rundensteiner
Chapter 7: Consistency & Replication IV - REPLICATION MANAGEMENT -Sumanth Kandagatla Instructor: Prof. Yanqing Zhang Advanced Operating Systems (CSC 8320)
EECS 498 Introduction to Distributed Systems Fall 2017
CS 440 Database Management Systems
Active replication for fault tolerance
EEC 688/788 Secure and Dependable Computing
EEC 688/788 Secure and Dependable Computing
Lecture 21: Replication Control
EEC 688/788 Secure and Dependable Computing
NoSQL & Document Stores
Lecture 21: Replication Control
Presentation transcript:

Disorderly programming. CALM analysis.

The future is already here Nearly all nontrivial systems are (or are becoming) distributed Programming distributed systems is hard Reasoning about them is harder

Outline 1.Disorderly Programming 2.The Bloom programming language 3.CALM Analysis and visualization 4.Challenge app: replicated shopping carts

Programming distributed systems

The state of the art Order is pervasive in the stored program model Program state is an ordered array Program logic is a list of instructions with a PC

The state of the art Order is pervasive in the stored program model Program state is an ordered array Program logic is a list of instructions with a PC

The state of the art Order is pervasive in the stored program model Parallelism and concurrency via retrofits: Threads – execute many copies of sequential instructions Event-driven programming – a single sequential program dispatches async processes

The state of the art In distributed systems, order is expensive to enforce frequently unnecessary / overspecified easy to get wrong

The art of the state Disorderly programming Design maxim: Think about the hard stuff. Forget about the easy stuff.

The art of the state Disorderly programming Program state is unordered collections Program logic is an unordered set of rules

The art of the state Disorderly programming Program state is unordered collections Program logic is an unordered set of rules Independence and concurrency are assumed Ordering of data or instructions are explicit, special-case behaviors – This is the hard stuff

BUD: Bloom Under Develoment Ruby internal DSL Set comprehension style of programming Fully declarative semantics – Based on Dedalus (Datalog + time)

Bloom Rules multicast <~ (message * members) do |mes, mem| [mem.address, mes.id, mes.payload] end

Bloom Rules multicast <~ (message * members) do |mes, mem| [mem.address, mes.id, mes.payload] end

Bud language features Module system – Encapsulation and composition via mixins – Separation of abstract interfaces and concrete implementations Metaprogramming and reflection – Program state is program data Pay-as-you-code schemas – Default is key => value

Operational model

Writing distributed programs in Bloom

Abstract Interfaces and Declarations module DeliveryProtocol state do interface input, :pipe_in, [:dst, :src, :ident] => [:payload] interface output, :pipe_sent, pipe_in.schema end

Abstract Interfaces and Declarations module DeliveryProtocol state do interface input, :pipe_in, [:dst, :src, :ident] => [:payload] interface output, :pipe_sent, pipe_in.schema end

Concrete Implementations module BestEffortDelivery include DeliveryProtocol state do channel :pipe_chan, pipe_in.schema end bloom :snd do pipe_chan <~ pipe_in end bloom :done do pipe_sent <= pipe_in end

Concrete Implementations module BestEffortDelivery include DeliveryProtocol state do channel :pipe_chan, pipe_in.schema end bloom :snd do pipe_chan <~ pipe_in end bloom :done do pipe_sent <= pipe_in end

Concrete Implementations module BestEffortDelivery include DeliveryProtocol state do channel :pipe_chan, pipe_in.schema end bloom :snd do pipe_chan <~ pipe_in end bloom :done do pipe_sent <= pipe_in end Asynchrony

Concrete Implementations module ReliableDelivery include DeliveryProtocol import BestEffortDelivery => :bed state do table :buf, pipe_in.schema channel :ack, :dst, :ident] periodic :clock, 2 end bloom :remember do buf <= pipe_in bed.pipe_in <= pipe_in bed.pipe_in <= (buf * clock).lefts end bloom :send_ack do ack <~ bed.pipe_chan do|p| [p.src, p.dst, p.ident] end bloom :done do temp :msg_acked <= (buf * ack).lefts (:ident => :ident) pipe_sent <= msg_acked buf <- msg_acked end

Concrete Implementations module ReliableDelivery include DeliveryProtocol import BestEffortDelivery => :bed state do table :buf, pipe_in.schema channel :ack, :dst, :ident] periodic :clock, 2 end bloom :remember do buf <= pipe_in bed.pipe_in <= pipe_in bed.pipe_in <= (buf * clock).lefts end bloom :send_ack do ack <~ bed.pipe_chan do|p| [p.src, p.dst, p.ident] end bloom :done do temp :msg_acked <= (buf * ack).lefts (:ident => :ident) pipe_sent <= msg_acked buf <- msg_acked end

Concrete Implementations module ReliableDelivery include DeliveryProtocol import BestEffortDelivery => :bed state do table :buf, pipe_in.schema channel :ack, :dst, :ident] periodic :clock, 2 end bloom :remember do buf <= pipe_in bed.pipe_in <= pipe_in bed.pipe_in <= (buf * clock).lefts end bloom :send_ack do ack <~ bed.pipe_chan do|p| [p.src, p.dst, p.ident] end bloom :done do temp :msg_acked <= (buf * ack).lefts (:ident => :ident) pipe_sent <= msg_acked buf <- msg_acked end Asynchrony + Nonmonotonicity

CALM Analysis

Monotonic Logic The more you know, the more you know. E.g., select, project, join, union – (Filter, map, compose, merge) Pipelinable Insensitive to the ordering of inputs

Nonmonotonic Logic Possible belief revision or retraction (Un-firing missiles) E.g. aggregation, negation as complement – (Counting, taking a max/min, checking that an element isn’t in a hash) Blocking Ordering of inputs may affect results

Consistency A family of correctness criteria for data-oriented systems Do my replicas all converge to the same final state? Am I missing any partitions? State of the art: choose an extreme

Strong Consistency Coordination: baked-in consistency via protocol Serializable reads and writes, atomic transactions, ACID 2PC, paxos, GCS, etc Establish a total order of updates Problem: latency, availability

Strong Consistency

Loose Consistency Application-specific correctness via “rules of thumb” Asynchronous replication Commutative (i.e., reorderable) operations Custom compensation / repair logic Tolerate all update orders Problem: informal, fragile

Loose Consistency

CALM Conjecture Consistency ``is’’ logical monotonicity

CALM Analysis Logic programming dependency analysis applied to a distributed system Represent program as a directed graph – Nodes are collections – Arcs are rules may be labeled asynchronous or nonmonotonic Tools identify “points of order” – Where different input orderings may produce divergent outputs

Points of order Nonmonotonicity after asynchrony in dataflow Asynchronous messaging => nondeterministic message orders Nonmonotonic => order-sensitive Coordination may be required to ensure convergent results. Here (and only here) the programmer should reason about ordering!

Resolving points of order 1.Coordinate – Enforce an ordering over inputs – Or block till input set is completely determined

Resolving points of order 1.Coordinate – Enforce an ordering over inputs – Or block till input set is completely determined 2.Speculate – Track ``taint’’ – Tainted conclusions may be retracted

Resolving points of order 1.Coordinate – Enforce an ordering over inputs – Or block till input set is completely determined 2.Speculate – Track ``taint’’ – Tainted conclusions may be retracted 3.Rewrite – ``Push down’’ points of order Past async edges (localize coordination) To edges with less flow (minimize coordination)

Resolving points of order 1.Coordinate – Enforce an ordering over inputs – Or block till input set is completely determined 2.Speculate – Track ``taint’’ – Tainted conclusions may be retracted 3.Rewrite – ``Push down’’ points of order Past async edges (localize coordination) To edges with less flow (minimize coordination)

Shopping Carts

Example application: a replicated shopping cart Replicated to achieve high availability and low latency Clients are associated with unique session ids Add item, delete item and “checkout” operations Challenge: Ensure that replicas are ``eventually consistent’’

Carts done two ways 1.A “destructive” cart – Use a replicated KVS as a storage system – Client session id is the key – Value is an array representing cart contents – Checkout causes value array to be sent to client 2.A “disorderly” cart – Accumulate (and asynchronously replicate) a set of cart actions – At checkout, count additions and deletions, take difference – Aggregate the summary into an array “just in time”

A simple key/value store module KVSProtocol state do interface input, :kvput, [:key] => [:reqid, :value] interface input, :kvdel, [:key] => [:reqid] interface input, :kvget, [:reqid] => [:key] interface output, :kvget_response, [:reqid] => [:key, :value] end

A simple key/value store module KVSProtocol state do interface input, :kvput, [:key] => [:reqid, :value] interface input, :kvdel, [:key] => [:reqid] interface input, :kvget, [:reqid] => [:key] interface output, :kvget_response, [:reqid] => [:key, :value] end

A simple key/value store module BasicKVS include KVSProtocol state do table :kvstate, [:key] => [:value] end bloom :mutate do kvstate <+ kvput {|s| [s.key, s.value]} kvstate :key) end bloom :get do temp :getj :key) kvget_response <= getj do |g, t| [g.reqid, t.key, t.value] end bloom :delete do kvstate :key) end

A simple key/value store module BasicKVS include KVSProtocol state do table :kvstate, [:key] => [:value] end bloom :mutate do kvstate <+ kvput {|s| [s.key, s.value]} kvstate :key) end bloom :get do temp :getj :key) kvget_response <= getj do |g, t| [g.reqid, t.key, t.value] end bloom :delete do kvstate :key) end

A simple key/value store module BasicKVS include KVSProtocol state do table :kvstate, [:key] => [:value] end bloom :mutate do kvstate <+ kvput {|s| [s.key, s.value]} kvstate :key) end bloom :get do temp :getj :key) kvget_response <= getj do |g, t| [g.reqid, t.key, t.value] end bloom :delete do kvstate :key) end Nonmononic operations

A simple key/value store module BasicKVS include KVSProtocol state do table :kvstate, [:key] => [:value] end bloom :mutate do kvstate <+ kvput {|s| [s.key, s.value]} kvstate :key) end bloom :get do temp :getj :key) kvget_response <= getj do |g, t| [g.reqid, t.key, t.value] end bloom :delete do kvstate :key) end Nonmononic operations

A simple key/value store module BasicKVS include KVSProtocol state do table :kvstate, [:key] => [:value] end bloom :mutate do kvstate <+ kvput {|s| [s.key, s.value]} kvstate :key) end bloom :get do temp :getj :key) kvget_response <= getj do |g, t| [g.reqid, t.key, t.value] end bloom :delete do kvstate :key) end Nonmononic operations

A simple key/value store module BasicKVS include KVSProtocol state do table :kvstate, [:key] => [:value] end bloom :mutate do kvstate <+ kvput {|s| [s.key, s.value]} kvstate :key) end bloom :get do temp :getj :key) kvget_response <= getj do |g, t| [g.reqid, t.key, t.value] end bloom :delete do kvstate :key) end Nonmononic operations

``Destructive’’ Cart module DestructiveCart include CartProtocol include KVSProtocol declare def queueing kvget <= action_msg {|a| [a.reqid, a.session] } kvput <= action_msg do |a| if a.action == "Add" and not kvget_response.map{|b| b.key}.include? a.session [a.client, a.session, a.reqid, Array.new.push(a.item)] end old_state = join [kvget_response, action_msg], [kvget_response.key, action_msg.session] kvput <= old_state do |b, a| if a.action == "Add" [a.client, a.session, a.reqid, (b.value.clone.push(a.item))] elsif a.action == "Del" [a.client, a.session, a.reqid, delete_one(b.value, a.item)] end declare def finish kvget <= checkout_msg {|c| [c.reqid, c.session] } lookup = join([kvget_response, checkout_msg], [kvget_response.key, checkout_msg.session]) response_msg <~ lookup do |r, c| [r.client, r.server, r.key, r.value, nil] end

``Destructive’’ Cart module DestructiveCart include CartProtocol include KVSProtocol declare def queueing kvget <= action_msg {|a| [a.reqid, a.session] } kvput <= action_msg do |a| if a.action == "Add" and not kvget_response.map{|b| b.key}.include? a.session [a.client, a.session, a.reqid, Array.new.push(a.item)] end old_state = join [kvget_response, action_msg], [kvget_response.key, action_msg.session] kvput <= old_state do |b, a| if a.action == "Add" [a.client, a.session, a.reqid, (b.value.clone.push(a.item))] elsif a.action == "Del" [a.client, a.session, a.reqid, delete_one(b.value, a.item)] end declare def finish kvget <= checkout_msg {|c| [c.reqid, c.session] } lookup = join([kvget_response, checkout_msg], [kvget_response.key, checkout_msg.session]) response_msg <~ lookup do |r, c| [r.client, r.server, r.key, r.value, nil] end React to client updates React to client checkout

``Destructive’’ Cart

Asynchrony

``Destructive’’ Cart Asynchrony Nonmonotonicity

``Destructive’’ Cart Asynchrony Nonmonotonicity Divergent Results?

``Destructive’’ Cart Add coordination? E.g., Synchronous replication Paxos

``Destructive’’ Cart Add coordination? E.g., Synchronous replication Paxos n = |client_action| m = |client_checkout| = 1 n rounds of coordination

``Disorderly Cart’’ module DisorderlyCart include CartProtocol state do table :cart_action, [:session, :reqid] => [:item, :action] scratch :action_cnt, [:session, :item, :action] => [:cnt] scratch :status, [:server, :client, :session, :item] => [:cnt] end declare def saved cart_action <= action_msg { |c| [c.session, c.reqid, c.item, c.action] } action_cnt <= cart_action.group([cart_action.session, cart_action.item, cart_action.action], count(cart_action.reqid)) end declare def consider status <= (action_cnt * action_cnt * checkout_msg) do |a1, a2, c| if a1.session == a2.session and a1.item == a2.item and a1.session == c.session and a1.action == "Add" and a2.action == "Del" [c.client, c.server, a1.session, a1.item, a1.cnt - a2.cnt] if (a1.cnt - a2.cnt) > 0 end status <= (action_cnt * checkout_msg) do |a, c| if a.action == "Add" and not action_cnt.map{|d| d.item if d.action == "Del"}.include? a.item [c.client, c.server, a.session, a.item, a.cnt] end out = status.reduce({}) do |memo, i| memo[[i[0],i[1],i[2]]] ||= []; i[4].times {memo[[i[0],i[1],i[2]]] << i[3]}; memo end.to_a response_msg <~ out {|k, v| k << v} end

``Disorderly Cart’’ module DisorderlyCart include CartProtocol state do table :cart_action, [:session, :reqid] => [:item, :action] scratch :action_cnt, [:session, :item, :action] => [:cnt] scratch :status, [:server, :client, :session, :item] => [:cnt] end declare def saved cart_action <= action_msg { |c| [c.session, c.reqid, c.item, c.action] } action_cnt <= cart_action.group([cart_action.session, cart_action.item, cart_action.action], count(cart_action.reqid)) end declare def consider status <= (action_cnt * action_cnt * checkout_msg) do |a1, a2, c| if a1.session == a2.session and a1.item == a2.item and a1.session == c.session and a1.action == "Add" and a2.action == "Del" [c.client, c.server, a1.session, a1.item, a1.cnt - a2.cnt] if (a1.cnt - a2.cnt) > 0 end status <= (action_cnt * checkout_msg) do |a, c| if a.action == "Add" and not action_cnt.map{|d| d.item if d.action == "Del"}.include? a.item [c.client, c.server, a.session, a.item, a.cnt] end out = status.reduce({}) do |memo, i| memo[[i[0],i[1],i[2]]] ||= []; i[4].times {memo[[i[0],i[1],i[2]]] << i[3]}; memo end.to_a response_msg <~ out {|k, v| k << v} end Actions Checkout

Disorderly Cart Analysis

Asynchrony

Disorderly Cart Analysis Asynchrony Nonmonotonicity

Disorderly Cart Analysis Asynchrony Nonmonotonicity Divergent Results?

Disorderly Cart Analysis n = |client_action| m = |client_checkout| = 1 1 round of coordination

Replicated Disorderly Cart Asynchronous (uncoordinated) replication

Replicated Disorderly Cart Asynchronous (uncoordinated) replication Still just 1 round of coordination

Summary Why disorderly? – Order is expensive and sometimes distracting When is order really needed? – When nomonotonicity makes the computation order- dependent What is coordination for? – Re-establishing order, to guarantee consistency. CALM <~ Bloom – A disorderly programming language – Tools to identify points of order

More Resources: Writeups: Consistency Analysis in Bloom: A CALM and Collected Approach (CIDR’11) Dedalus: Datalog in Time and Space (Datalog2.0) The Declarative Imperative (PODS’10 Keynote address) Model-theoretic Correctness Criteria for Distributed Systems (in submission)

Queries?