Beruflich Dokumente
Kultur Dokumente
Consistency,
Integrity, Durability,
Availability, etc.
Account balances should be non-negative
Application invariants
Strong consistency
Linearizability & Serializability
INTERNET
Eventual Consistency
∞
(convergence)
Session 1
//init balance = 0
deposit(100)
? get_balance()
Eventually
Consistent
Data Stores
INTERNET
Replica 1 Replica 1
Session 1 Session 1
bal=100 bal=100
//init balance = 0 //init balance = 0
deposit(100) deposit(100)
0 get_balance() ??? get_balance()
bal=0 bal=0
Replica 2 Replica 2
Eventually
Consistent
Data Stores
INTERNET
Replica 1 Replica 1
Session 1 Session 1
bal=100 bal=100
//init balance = 0 //init balance = 0
deposit(100) deposit(100)
0 get_balance() 100 get_balance()
bal=0 bal=100
Replica 2 Replica 2
Eventually
Consistent
Data Stores
INTERNET
Application
deposit() withdraw() tweet() bid()
invariants
Eventually
Consistent
Data Stores
INTERNET
Application
deposit() withdraw() tweet() bid()
invariants
Eventually
Consistent
Data Stores
INTERNET
Our solution …
Classification
Scheme
An algorithm to …
Application Store consistency
requirements Map guarantees
• Unique usernames. • Sound.
• Read-my-writes consistency
• Non-negative balance. • Optimal
• Causal consistency
• Bona fide bids. • Read committed isolation level
• Repeatable read isolation level
Specification
Language
Session 1 Session n
v1 = getBalance();
Session Order (SO)
…… ……
v2 = getBalance();
Specification Language
• Axiomatically capture set of valid executions
• Associate with each operation a single abstract effect
– Express relationship between effects
– Visibility (vis), Session order (so), Same object (sameobj)
Primitive relations
Happens-before
12
Replicated Bank Account (1)
balance >= 0 violated
Session 1 Session 2
vis
//init balance = 100 //init balance = 100
withdraw(70); a b withdraw(70);
vis
Bank Account Contracts (2)
Session 1 Session 2
vis
a b
deposit(100) withdraw(50)
vis vis
c
Session 3
50
-50
getbalance () () ()
A.getbalance
getbalance
Capturing Store Consistency Levels
Eventual
Consistency
Causal
Consistency
Strong
Consistency
Classification Scheme
Causal
Consistency deposit EC
withdraw SC
Strong getBalance CC
Consistency
Classification Scheme (2)
Transactions
• Generalizing to transactions is easy.
– Add single primitive relation - sametxn(a,b)
– Derived relation:
Read Committed
vis
oper1(…) a b oper2(…)
vis c oper3(…)
anope
operara tion at 1som
tionsinT willeare plica, sesthee
lsowitne nsureffetha t the
ctsof T2re plica
. MA V sinclude s
emantics
theistra
usens actions
ful for main
intaSining
t . He nce
the , MAV
inte isfore
grity of coordina
ign ketion-fre e.ints
y constra MA,
semantics
Read
mate isdvie
Committed
rialize captured
wsands with thery
econda following contract:
updates[2]. Inorder toimplement
MAV, a store only needs to keep track of the set of transactions
St mav =ss8a,
witne b, c,the
ed by d.running
txn{ a, b}
tra{ns
c,ad} ^ aso
ction, nd(a, b) ^pevis
before (c,ing
rform a)
an operation at some re^plica , ensure(d,
sameobj thab) ) re
t the vis (d, include
plica b) s all
the transactions in St . Hence, MAV is coordination-free. MAV
whose semantics
Monotonic
semanticsatomic is
view
is capturedillustrated
with the in the Figure
following 8(b).
contract:
ANSI RR semantics requires that the transaction witness
mav = 8a, b, c, d. txn{ a, b} { c, d} ^ so(a, b) ^ vis(c, a)
snapshot of thedatastorestate. Importantly, thissnapshot can
obtained fromany replica ^, asameobj (d, b) ) vis
ndhenceRRisa (d,coordina
lso b) tion-fr
Ane xamplefor
whose Readsuchatra
semantics
Repeatable nsactionisthe
is illustrated in the Figure al Bal ance transacti
t ot8(b).
ANSI RRofseRR
The semantics mantics requiresbytha
is captured t the
the transaction
following witness a
contract:
snapshot of thedatastorestate. Importantly, thissnapshot can be
= 8a,
obtainedrrfromanyb, c, d.,txn
replica and{ a, b} { c, d} ^lsovis
henceRRisa (c, a) tion-free.
coordina
Anexamplefor suchatransa^ctionisthe
sameobj t ot
(d,alb)Bal) ance trab)
vis(d, nsaction.
The semantics of RR is captured by the following contract:
whose semantics is illustrated in the Figure 8(c).
rr = 8a, b, c, d. txn{ a, b} { c, d} ^ vis(c, a)
• Haskell library for Eventually Consistent Data Stores
(ECDS)
– Definition language define operations and transactions on
replicated data.
– Specification language specify consistency and isolation
requirements.
DEFS GHC
+
Quelea Data Store
Case Studies
Application RUBiS Twitter-lite
#Tables 6 5
#Operations 17 20
#Transactions 6 10
Invariants e.g. See all bids placed in Unique username
current session
Results of classification
#EC Ops 14 13
#CC Ops 2 6
#SC Ops 1 1
#RC Txns 4 6
#MAV Txns 2 3
#RR Txns 0 1
Evaluation
• Correctness with classification vs without classification
– How do they compare in terms of availability?
• NoRep: No Replication • StrongRep: Strong Replication
• Experimental Setup:
– Amazon EC2; 5 replicas (StrongRep & Quelea); 1 replica (NoRep)
– Gradually increased # of concurrent clients from 128 to 1024.
Conclusion
• Quelea Haskell-library for programming
ECDS
– Automatic classification of operation and transaction
contracts through SMT solver
• Leveraging off-the-shelf ECDS
– Avoid re-engineering complex systems
– Makes it practical!
http://kcsrk.info/Quelea
Thank you!
State Summarization
• Summarization is essential to check the unbounded
growth of the log.
• How is summarization done?
– Ask developer for summarization semantics.
• In the paper
Figur e 9: Implementation Model.
– Stronger eventual consistency
– Highly available transaction support
dependencies introduced between effectsdueto visibility, session
– Summarization
andsametransactionrelations. Dependencetrackingissimilar tothe
techniques presented in [3] and [21]. BecauseCassandraprovides
System Model
Effects Quelea Data Store
R1 R2 Rn
B.deposit($5) d5
Session
B.withdraw($6) ……
Order w6
System Model
Quelea Data Store
R1 R2 Rn
B.deposit($5) d5
Session
B.withdraw($6) ……
Order w6
System Model
Quelea Data Store
R1 R2 Rn
B.deposit($5) d5
Session
B.withdraw($6) ……
Order w6
System Model
Quelea Data Store
R1 R2 Rn
B.deposit($5) d5
Session
B.withdraw($6) ……
Order w6
System Model
Quelea Data Store
R1
Session 1
B.deposit($5) d5
B.withdraw($6) w6
……
v1 = B.getBalance()
gb
System Model
Quelea Data Store
R1
Session 1
B.deposit($5) d5
B.withdraw($6) w6
……
v1 = $3+$5–$6 = $2
gb
System Model
Replicated Data Store
Replica 1 Replica n
Deposit(200) Deposit(200)
Withdraw(20) Withdraw(10)
Withdraw(10) Deposit(10)
……
…… ……
Session 1 Session n
getBalance;
Session Order (SO)
…… ……
withdraw(6);
Replicated Bank Account (2)
Session 1 Session 2
vis
a b
deposit(100) withdraw(50)
vis vis
c
Session 3
-50
getbalance
50 getbalance () ()()
getbalance
Table 1: The distribution of classified contracts. #T refers to the
Evaluation
number of tablesintheapplication. Thecolumns4-6(7-9) represent
operations (transactions) assigned to this consistency (isolation)
level.
Benchmar k L OC #T EC CC SC RC M AV RR
LWW Reg 108 1 2 2 2 0 0 0
DynamoDB 126 1 3 1 2 0 0 0
Bank Account 155 1 1 1 1 1 0 1
Shopping List 140 1 2 1 1 0 0 0
Online store 340 4 9 1 0 2 0 1
RUBiS 640 6 14 2 1 4 2 0
Microblog 659 5 13 6 1 6 3 1
Session 1 Session 2
bal = A.getBalance();
A.withdraw(70);
If (bal ≥ 70)
A.withdraw(70);
Replicated Bank Account (1)
SO
a b
Session 1
c
Session 2
Session 1 Session 2
100 = A.getBalance(); a
c A.withdraw(70);
If (100 ≥ 70)
A.withdraw(70); b
Replicated Bank Account (1)
SO
a b
Session 1
VIS
c
Session 2
Session 1 Session 2
100 = A.getBalance(); a
c A.withdraw(70);
If (100 ≥ 70)
A.withdraw(70); b
Replicated Bank Account (1)
Required invariant: balance >= 0
SO
a b
Session 1
VIS
c
Session 2
Replicated Bank Account (1)
Session 1 Session 2
1
2
EC 2
RC
CC
MAV
SC 4
14
VIDEO_ID COUNT
… …
VIDEO_ID COUNT
INTERNET
… … VIDEO_ID COUNT
… …
VIDEO_ID COUNT
… …
☐ Strongly consistent, but not “always on”
☐ Be “always on”, but no strong consistency
Eventual Consistency
∞
(convergence)