rococo: extract more concurrency from distributed transactions · rococo has higher throughput 0...

27
Rococo: Extract more concurrency from distributed transactions Shuai Mu, Yang Cui, Yang Zhang, Wyatt Lloyd, Jinyang Li Tsinghua University, New York University, University of Southern California, Facebook 1

Upload: others

Post on 25-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

Rococo: Extract more concurrency from distributed transactions

Shuai Mu, Yang Cui, Yang Zhang, Wyatt Lloyd, Jinyang Li

Tsinghua University, New York University, University of Southern California, Facebook

1

Page 2: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

What Large Web Sites Need

170 million sold/day 36.8 million sold/day $169 billion trade/day

Scalable Storage w/ Transactions!

……

2

Page 3: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

What is a Distributed Transaction?

Item Stock iPhone 6 Plus 1 iPhone Case 1

iPhone=1 Case=1

BEGIN_TX if (iphone > 0) { iphone--; } if (case > 0) { case--; } END_TX

if (case > 0) { case--; }

if (iphone > 0) { iphone--; }

3

Transactions should be strictly serializable! Otherwise…

Page 4: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

Loss of serializability = angry customer

4

Page 5: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

Serializability is Costly under Contention Th

roug

hput

tra

nsac

tion/

s

# of concurrent transactions

Two-Phase Locking (2PL) Optimistic Concurrency Control (OCC)

5

Page 6: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

OCC Aborts Contended Transactions

If (iphone > 0) { iphone--; }

if (case > 0) { case--; }

iPhone=1 Case=1 If (iphone > 0) { iphone--; }

if (case > 0) { case--; }

Execute

6

if (iphone > 0) { iphone--; } if (case > 0) { case--; }

if (iphone > 0) { iphone--; } if (case > 0) { case--; }

Two-Phase Commit (2PC)

Page 7: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

2PL Blocks Contended Transactions

If (iphone > 0) { iphone--; }

if (case > 0) { case--; } iPhone=1 Case=1 If (iphone > 0) {

iphone--; }

if (case > 0) { case--; }

7

Execute

if (iphone > 0) { iphone--; } if (case > 0) { case--; }

if (iphone > 0) { iphone--; } if (case > 0) { case--; } 2PC

Page 8: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

Achieve serializability w/o aborting or blocking*

* for common workloads

8

Page 9: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

Rococo’s Approach

If (iphone > 0) { iphone--; }

if (case > 0) { case--; }

iPhone=1 Case=1 If (iphone > 0) { iphone--; }

if (case > 0) { case--; }

Defer piece execution to enable reordering 9

if (iphone > 0) { iphone--; } if (case > 0) { case--; }

if (iphone > 0) { iphone--; } if (case > 0) { case--; }

Page 10: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

Rococo Overview: Key techniques

1.  Two-phase protocol •  Most pieces are executed at the second (commit) phase

2.  Decentralized dependency tracking •  Servers track pieces’ arrival order •  Identify non-serializable orders •  Deterministically reorder pieces

3.  Offline workload checking •  Identifies safe workloads (common) •  Identifies small parts that need traditional approaches (rare)

10

Enable piece reordering for serializability

Avoid aborts for common workloads

Page 11: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

#1 Two-phase protocol

Start Phase Commit Phase

Send pieces to servers w/o

executing them

Establish a final order and

execute pieces

Reorder for serializability

Set up a provisional order

11

Page 12: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

dep dep

dep

T2: T1:

#2 Dependency Tracking: Start Phase

if ... iphone--

if ... case--

iPhone=1

if ... iphone--

if ... case--

12

if ...iphone--

if ... case--

if ... iphone--

if ... case--

T2

T1

dep

Case=1

T1

T2

T1 T2

T1

T1

T2

T2

Page 13: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

if ... case--

if ... case--

dep dep

dep

#2 Dependency Tracking: Commit Phase

if ... iphone--

iPhone=1

if ... iphone--

13

T2

T1

dep

Case=1

T1

T2

T2

T1

T1

T2

T1

T2

T1

T2

T2

T1

T2

T1

Sort the cycle by any deterministic order

Page 14: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

oid = next_oid ++

if ... iphone--

if ... case--

orderline.insert(oid, …)

iPhone Case

orderline.insert(

oid, ……)

Problem: Not Every Piece is Deferrable

Intermediate Results Calls for Immediate Execution

next_oid orderline

14

if ... iphone-- if ... case-- oid oid = next_oid ++

Page 15: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

a = next_a++;

b = next_b++;

ol_a.insert(a, …);

ol_b.insert(b, …);

a = next_a++;

b = next_b++;

ol_a.insert(a, …);

ol_b.insert(b, …);

Immediate Pieces are Naughty!

a = next_a++ b = next_b ++

b = next_b ++

1. Common workloads have few immediate pieces 2. Pre-known workload à Offline check

next_a = 0 next_b = 0

15

a = next_a++

Page 16: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

S(ibling)-edge linking pieces within a transaction

#3: Offline Checking: Basic

T1

T2

iphone case

iphone case

T1 T1

T2

Item_Table Item_Table

Item_Table Item_Table

T1 C(onflict)-edge linking pieces w/ conflicting access

An SC-cycle consists of

both S-edge and C-edge

SC-cycles represent potential non-serializable executions

that require 2PL/OCC 16

Page 17: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

#3: Offline Checking: Enhanced

SC-cycles with deferrable pieces can be safely reordered!

17

T1

T2

OidTable ItemTable

OidTable ItemTable

ItemTable

ItemTable

Deferrable Immediate

Page 18: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

dep dep dep dep

Incorporating Immediate Pieces

18

oid

iPhone Case next_oid orderline

18

iphone

case

orderline

oid

iphone

case

orderline

oid

oid

iphone

iphone

Immediate dependency

T2 T1

orderline

orderline

T2 T1 T2 T1 T2 T1

case

case

Every cycle contains deferrable pieces, ensured by

offline checking

Deferrable dependency

A cycle with deferrable pieces is

safe to reorder

Page 19: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

Merged Pieces

Read-only Transactions

Reducing Dep. Size

Fault Tolerance

Overlapping Trans.

……

Deferred Execution

Decentralized Dependency

Tracking

Offline Checking

19

Page 20: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

Evaluation

• How does Rococo perform under contention?

• How does Rococo scale?

20

Page 21: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

Workload: Scaled TPC-C

• One warehouse, many districts • Partitioned by districts - all transactions distributed

5~15 5~15 5~15 5~15

5~15 5~15 5~15 5~15

21

New order (45%)

Payment (43%)

Delivery (4%)

Read-only: OrderStatus(4%), StockLevel (4%)

Page 22: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

Rococo Has Higher Throughput

0

1000

2000

3000

4000

5000

6000

7000

0 20 40 60 80 100

Thro

ughp

ut-(n

ew-o

rder

/s)

Concurrent reqs/server

Rococo

2PL

OCC

Aborts due to conflicts in validation

Aborts due to deadlock detection

Increasing graph size

22

8 servers, 10 districts per server à Main source of contention is next_oid of each district

Page 23: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

Rococo Avoids Aborts

0

0.2

0.4

0.6

0.8

1

1.2

0 20 40 60 80 100

Com

mit

rate

Concurrent reqs/server

Rococo 2PL OCC

173~645ms

152~392ms

61~66ms

23

Page 24: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

Rococo Scales Out

0

10000

20000

30000

40000

50000

60000

0 20 40 60 80 100

Thro

ughp

ut-(n

ew-o

rder

/s)

Number of servers

Rococo

2PL

OCC

Aborts

Blocking

Almost Linear

24

10 districts per server, fixed # of items à contention grows slowly

Page 25: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

Related Work Isolation Level Concurrency Control Mech.

Rococo Strict-Serial. Rococo

Lynx [SOSP’13] Serial. Origin Ordering Granola [SIGMOD’10] Serial. Timestamp based Percolator [OSDI’10] S.I. OCC

Walter [SOSP’11] P.S.I. W-W Preclusion COPS [SOSP’11] Causal Dependency Tracking

Spanner [OSDI’12] Strict-Serial. 2PL HStore [VLDB’07] Strict-Serial. OCC

Calvin [SIGMOD’12] Strict-Serial. Pre-ordered Locking

25

Decentralized dependency tracking

Centralized sequencing layer, difficult to scale

Page 26: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

Conclusion

• Traditional protocols perform poorly w/ contention •  OCC aborts & 2PL blocks

• Rococo defers execution to enable reordering •  Strict serializability w/o aborting or blocking

for common workloads

• Rococo outperforms 2PL & OCC •  With growing contention •  Scales out

26

Page 27: Rococo: Extract more concurrency from distributed transactions · Rococo Has Higher Throughput 0 1000 2000 3000 4000 5000 6000 7000 0 20 40 60 80 100 ) Concurrent reqs/server Rococo

Thank you!

Questions?

https://github.com/msmummy/rococo

27

Poster tonight!