+ All Categories
Home > Documents > Distributed Transactions on Serverless Stateful Functions

Distributed Transactions on Serverless Stateful Functions

Date post: 27-Dec-2021
Category:
Upload: others
View: 5 times
Download: 0 times
Share this document with a friend
50
1 Distributed Transactions on Serverless Stateful Functions Distributed Transactions on Serverless Stateful Functions Martijn De Heus, Kyriakos Psarakis, Marios Fragkoulis, Asterios Katsifodimos. To appear in the proceedings of the 15th ACM International Conference on Distributed and Eventbased Systems (DEBS) 2021.
Transcript
Page 1: Distributed Transactions on Serverless Stateful Functions

1

Distributed Transactions on

Serverless Stateful Functions

Distributed Transactions on Serverless Stateful Functions Martijn De Heus, Kyriakos Psarakis, Marios Fragkoulis, Asterios Katsifodimos. To appear in the proceedings of the 15th ACM International Conference on Distributed and Event‐based Systems (DEBS) 2021.

Page 2: Distributed Transactions on Serverless Stateful Functions

2

• Transactions• Microservices & Cloud computing• Stateful Functions & Coordinator Functions• Evaluation• Conclusion & discussion

Page 3: Distributed Transactions on Serverless Stateful Functions

3

Transactions

Page 4: Distributed Transactions on Serverless Stateful Functions

4

TransactionsA transactions are a set of operations on data with 4 (ACID) guarantees:

● Atomicity● Consistency● Isolation

○ (serializability)

● Durability

Page 5: Distributed Transactions on Serverless Stateful Functions

5

Traditional Architecture

BEGINx = SELECT credit FROM users WHERE id=1UPDATE users SET credit=(x-1) WHERE id=1y = SELECT stock FROM items WHERE id=1UPDATE items SET stock=(y-1) WHERE id=1COMMIT

id credit

1 5

Usersid stock

1 0

Items

Application

Page 6: Distributed Transactions on Serverless Stateful Functions

6

Distributed transactions.

• Two-Phase Commit ensures atomicity• Two-Phase Locking ensures serializability

Combining Two-Phase Locking and Two-Phase Commit can be used to implement distributed transactions

Page 7: Distributed Transactions on Serverless Stateful Functions

7

Microservice systems

Page 8: Distributed Transactions on Serverless Stateful Functions

8

Microservices

Order service

Stock serviceUser service

Page 9: Distributed Transactions on Serverless Stateful Functions

9

Microservices

Benefits• Scaling components separately• Deploying / updating components separately• Deploying components on specific hardware• Scaling development in organisations

Page 10: Distributed Transactions on Serverless Stateful Functions

10

Two Generals’ Problem

Service BService A

(1) request(2) action

(3) response

The network is unreliable, it is never certain whether a message will arrive

If Service A never receives message at 3, it does not know whether Service B has performed action at 2.

Page 11: Distributed Transactions on Serverless Stateful Functions

11

Processing guarantees

Service BService A

(1) request(2) action

AT_MOST_ONCE: only try to send once and do not care about the results, action 2 may not be performed

AT_LEAST_ONCE: keep retrying until a response is received, action 2 may be performed multiple times

(3) response

Page 12: Distributed Transactions on Serverless Stateful Functions

12

Saga orchestration

Order service (orchestrator)

Stock serviceUser service

subtractCredit subtractStock

Page 13: Distributed Transactions on Serverless Stateful Functions

13

Saga orchestration

Order service (orchestrator)

Stock serviceUser service

failed success

Page 14: Distributed Transactions on Serverless Stateful Functions

14

Saga orchestration

Order service (orchestrator)

Stock serviceUser service

addStock

Transactions but with completely no isolationAtomicity with of fault-tolerance is also hard to achieve

Page 15: Distributed Transactions on Serverless Stateful Functions

15

Cloud computing

Page 16: Distributed Transactions on Serverless Stateful Functions

16

Cloud computing

Make computing accessible for everyone

Goals:• Eliminate up-front investment requirements and offer

compute resources on demand• Simplify distributed computing

• Deployment and scalability• State management

● Processing guarantees (exactly-once)● Distributed transactions

Page 17: Distributed Transactions on Serverless Stateful Functions

17

Cloud computing

Make computing accessible for everyone

Goals:✓ Eliminate up-front investment requirements and offer

compute resources on demand⁓ Simplify distributed computing

● Deployment and scalability● State management

● Processing guarantees (exactly-once)● Distributed transactions

Page 18: Distributed Transactions on Serverless Stateful Functions

18

How can we improve on this?

Make computing accessible for everyone

Goals:✓ Eliminate up-front investment requirements and offer

compute resources on demand⁓ Simplify distributed computing

● Deployment and scalability● State management

● Processing guarantees (exactly-once)● Distributed transactions

Page 19: Distributed Transactions on Serverless Stateful Functions

19

Serverless computing

Function-as-a-Service (FaaS) models as the first iteration of serverless

Goals:✓ Eliminate up-front investment requirements and offer

compute resources on demand⁓ Simplify distributed computing

✓ Deployment and scalability● State management

● Processing guarantees (exactly-once)● Distributed transactions

Page 20: Distributed Transactions on Serverless Stateful Functions

20

Function-as-a-Service

Order functions

Stock functionsUser functions

Page 21: Distributed Transactions on Serverless Stateful Functions

21

Serverless computing

Stateful-Function-as-a-Service (SFaaS) models as the second iteration of serverless

Goals:✓ Eliminate up-front investment requirements and offer

compute resources on demand⁓ Simplify distributed computing

✓ Deployment and scalability⁓ State management

✓ Processing guarantees (exactly-once)● Distributed transactions

Page 22: Distributed Transactions on Serverless Stateful Functions

22

Flink Statefun

Page 23: Distributed Transactions on Serverless Stateful Functions

23

Functions-as-a-Service

Order functions

Stock functionsUser functions

Page 24: Distributed Transactions on Serverless Stateful Functions

24

Cluster

Stateful Function-as-a-Service

Order functions

Stock functionsUser functions

Couples messaging and state management to ensure exactly-once guarantees across both

Page 25: Distributed Transactions on Serverless Stateful Functions

25

Flink Statefun

Page 26: Distributed Transactions on Serverless Stateful Functions

26

Flink StatefunFunction instances encapsulate specific state based on their address (combination of type and id)

Function instances can perform four side effects:• Updates to their encapsulated state• Messages to other function instances• Delayed messages to other function instances• Messages to egresses

Function instances can be invoked by:• Messages from other function instances• Messages from ingresses

Page 27: Distributed Transactions on Serverless Stateful Functions

27

Flink Statefun

state access

state update

egress message

Page 28: Distributed Transactions on Serverless Stateful Functions

28

Flink Statefun

State is sent to the remote function

The resulting side effects

Page 29: Distributed Transactions on Serverless Stateful Functions

29

Coordinator functionsfor distributed transactions

Page 30: Distributed Transactions on Serverless Stateful Functions

30

Serverless computing

Goals:✓ Eliminate up-front investment requirements and offer

compute resources on demand✓ Simplify distributed computing

✓ Deployment and scalability✓ State management

✓ Processing guarantees (exactly-once)✓ Distributed transactions

Page 31: Distributed Transactions on Serverless Stateful Functions

31

Coordinator functions

This relies on Statefun’s exactly_once guarantees and linearizable operations on single function instances

Page 32: Distributed Transactions on Serverless Stateful Functions

32

Coordinator functionsCoordinator functions are simply specialized function instances to coordinate a serializable transaction or sagas

Coordinator function instances can perform side effects:• Add messages to other function instances to the saga or

transactions• Add side effects to perform based on the completion of the saga

Coordinator function instances can be invoked by:• Messages from other function instances• Messages from ingresses

Page 33: Distributed Transactions on Serverless Stateful Functions

33

Coordinator functions

invocations part of the transaction

Page 34: Distributed Transactions on Serverless Stateful Functions

34

Coordinator functions

invocations part of the saga

require explicit compensating invocations

Page 35: Distributed Transactions on Serverless Stateful Functions

35

Regular functions• Functions should be able to fail explicitly• Batching should be adjusted to respect isolation of

invocations part of a serializable transaction• Locking should be introduced• It should participate in the protocols for sagas and serializable

transactions

Page 36: Distributed Transactions on Serverless Stateful Functions

36

Explicit failure

Raise an exception

Exception handler for non-transactional invocations

Page 37: Distributed Transactions on Serverless Stateful Functions

37

Coordinator functions

Page 38: Distributed Transactions on Serverless Stateful Functions

38

Deadlock detection

K. Mani Chandy, Jayadev Misra, and Laura M. Haas. 1983. Distributed Deadlock Detection. ACM Trans. Comput. Syst. 1, 2 (May 1983), 144–156.

Page 39: Distributed Transactions on Serverless Stateful Functions

39

Evaluation

Page 40: Distributed Transactions on Serverless Stateful Functions

40

EvaluationBased on an extension of YCSB

• Stage 1: insert x keys in the system• Stage 2: perform of workload of read and write operations

– Extended with transfer operations– Uniform distribution

Measured maximum throughput and latency

Page 41: Distributed Transactions on Serverless Stateful Functions

41

Evaluation

Statefun is restricted to a number of instances and CPUsother components are scaled so they are not the bottleneck

Page 42: Distributed Transactions on Serverless Stateful Functions

42

Evaluation

~20% drop in performance for 100 keys~10% drop in performance for 5000+ keys

Page 43: Distributed Transactions on Serverless Stateful Functions

43

Evaluation

Mean Median

95th percentile

Page 44: Distributed Transactions on Serverless Stateful Functions

44

Evaluation

Very poor performance for serializable transaction across 100 keysMore comparable performance for 5000+ keys

Page 45: Distributed Transactions on Serverless Stateful Functions

45

Evaluation

Rollbacks have some overhead for sagasSagas still perform better than serializable transactions even at

100% rollbacks

Page 46: Distributed Transactions on Serverless Stateful Functions

46

Evaluation

Page 47: Distributed Transactions on Serverless Stateful Functions

47

Evaluation

Consistent 90% scalability efficiency for sagas

87% scalability efficiency for serializable transactions at 10% transfers

75% scalability efficiency for serializable transactions at 100% transfers

Page 48: Distributed Transactions on Serverless Stateful Functions

48

Conclusion• Simple programming model abstracting away all

distributed systems concerns from the application developer

• Acceptable performance overhead on non-transactional workloads

• Good scalability for saga-based transactions and acceptable scalability for serializable transactions

Page 49: Distributed Transactions on Serverless Stateful Functions

49

Future workMake Stateful Functions complete

• State access without specific function ID– Secondary indices– WHERE clause

• Aggregates over state across function instances• Versioning of state / updating functions• Research based on use cases developing improved benchmarks

Page 50: Distributed Transactions on Serverless Stateful Functions

50

Distributed Transactions on

Serverless Stateful Functions

Martijn de Heus4367839

Web Information Systems


Recommended