Serverless Performance on a Budget Erwin van Eyk The central - - PowerPoint PPT Presentation

serverless performance on a budget
SMART_READER_LITE
LIVE PREVIEW

Serverless Performance on a Budget Erwin van Eyk The central - - PowerPoint PPT Presentation

Serverless Performance on a Budget Erwin van Eyk The central trade-off in serverless computing High Performance Infinite scaling High availability Low latency 2 The central trade-off in serverless computing High Performance Low


slide-1
SLIDE 1

Serverless Performance

  • n a Budget

Erwin van Eyk

slide-2
SLIDE 2

The central trade-off in serverless computing

High Performance

“Infinite” scaling High availability Low latency

2

slide-3
SLIDE 3

The central trade-off in serverless computing

High Performance

“Infinite” scaling High availability Low latency

Low Cost

No costs when idle No operational cost Granular billing

2

slide-4
SLIDE 4

The central trade-off in serverless computing

High Performance

“Infinite” scaling High availability Low latency

Low Cost

No costs when idle No operational cost Granular billing

How can we optimize the performance-cost trade-off?

2

slide-5
SLIDE 5

Anatomy of a Functions-as-a-Service (FaaS) platform

pods and other resources

  • Function Configuration
  • Environment variables
  • Arguments
  • Version
  • Source pointer
  • ...

3

slide-6
SLIDE 6

Anatomy of a FaaS platform

4

slide-7
SLIDE 7

Anatomy of a FaaS platform: Fission (without optimizations)

5

slide-8
SLIDE 8

Anatomy of a FaaS platform: cold start

6

slide-9
SLIDE 9

Anatomy of a FaaS platform: cold start

6

slide-10
SLIDE 10

Anatomy of a FaaS platform: cold start 1

Trigger function deployment

6

slide-11
SLIDE 11

Anatomy of a FaaS platform: cold start 1

Trigger function deployment Fetch function metadata

2

6

slide-12
SLIDE 12

Anatomy of a FaaS platform: cold start 1

Trigger function deployment

3

kubectl create Fetch function metadata

2

6

slide-13
SLIDE 13

Anatomy of a FaaS platform: cold start 1

Trigger function deployment

3

kubectl create

4

Wait for K8S to deploy function Fetch function metadata

2

6

slide-14
SLIDE 14

Anatomy of a FaaS platform: cold start 1

Trigger function deployment

3

kubectl create

4

Wait for K8S to deploy function

5

Send request Fetch function metadata

2

6

slide-15
SLIDE 15

Anatomy of a FaaS platform: cold start 1

Trigger function deployment

3

kubectl create

4

Wait for K8S to deploy function

5

Send request Response

6

Fetch function metadata

2

6

slide-16
SLIDE 16

Anatomy of a FaaS platform: cold start 1

Trigger function deployment

3

kubectl create

4

Wait for K8S to deploy function

5

Send request Response

6 7

Fetch function metadata

2

6

slide-17
SLIDE 17

Anatomy of a FaaS platform: warm execution

7

slide-18
SLIDE 18

Anatomy of a FaaS platform: warm execution

7

slide-19
SLIDE 19

Anatomy of a FaaS platform: warm execution

7

5

Send request

slide-20
SLIDE 20

Anatomy of a FaaS platform: warm execution

7

5

Send request Response

6

slide-21
SLIDE 21

Anatomy of a FaaS platform: warm execution

7

5

Send request Response

6 7

slide-22
SLIDE 22

8

Cold Start Warm Execution

slide-23
SLIDE 23

8

Cold Start

Trigger deployer

Warm Execution

slide-24
SLIDE 24

8

Cold Start

Trigger deployer

Warm Execution

Fetch function metadata

slide-25
SLIDE 25

8

Cold Start

Trigger deployer

Warm Execution

Fetch function metadata Deploy Pod

slide-26
SLIDE 26

8

Cold Start

Trigger deployer

Warm Execution

Fetch function metadata Fetch function Deploy Pod

slide-27
SLIDE 27

8

Cold Start

Trigger deployer

Warm Execution

Fetch function metadata Fetch function Deploy Pod Deploy function

slide-28
SLIDE 28

8

Route request

Cold Start

Trigger deployer

Warm Execution

Fetch function metadata Fetch function Deploy Pod Deploy function

slide-29
SLIDE 29

8

Route request

Cold Start

Trigger deployer

Warm Execution

Fetch function metadata Fetch function Deploy Pod Deploy function Function Execution

slide-30
SLIDE 30

8

Route request

Cold Start

Trigger deployer

Warm Execution

Fetch function metadata Fetch function Deploy Pod Deploy function Function Execution Route request

slide-31
SLIDE 31

8

Route request

Cold Start

Trigger deployer

Warm Execution

Fetch function metadata Fetch function Deploy Pod Deploy function Function Execution Route request Function Execution

slide-32
SLIDE 32

Cold starts matter!

Wang, Liang, et al. "Peeking Behind the Curtains of Serverless Platforms." 2018 USENIX ATC, 2018.

Coldstart latency (in ms) over 168 hours

9

500 ms 3600 ms 180 ms

slide-33
SLIDE 33

How do FaaS platforms improve their performance?

  • 1. Function resource reusing
  • 2. Function runtime pooling
  • 3. Function prefetching
  • 4. Function prewarming

And, at what cost?

10

slide-34
SLIDE 34

Trigger deployer Fetch function metadata Deploy pod Deploy function Function Execution Route request

11

Function Resource Reusing

Optimization 1

Fetch function

slide-35
SLIDE 35

Function Isolation vs. Function Reuse

12

Full Isolation Full resource reuse

Function Instance Request Response Function Instance Request Response Function Instance Request Response Function Instance Requests Responses

slide-36
SLIDE 36

Function resource reusing in practice

  • Why performance isolation:
  • Performance variability
  • In practice: all FaaS platforms reuse resources
  • Per-user binpacking
  • Functions are isolated
  • Function executions share resources

13

slide-37
SLIDE 37

FaaS platform with function reusing

14

slide-38
SLIDE 38

Trade-off: how long to keep functions alive?

  • To reuse functions we have to keep them alive.
  • Keep-alive in practice:
  • AWS: ~6 hours
  • Google: ~6 hours
  • Azure: 1-4 days

short keep-alives Less idle resources Long keep-alive More warm executions

15

slide-39
SLIDE 39

16

Function Runtime Pooling

Optimization 2

Route request Trigger deployer Fetch function metadata Fetch function Function Execution Deploy function Deploy pod

slide-40
SLIDE 40

Resources Function Runtime Resources

Function Instance = Runtime + Function

17

  • Insight: function instances consist out of two parts
  • Function-specific code: user-provided business logic.
  • Runtime: operational logic, monitoring, health checks...
  • Divide the deployment process into 2 stages:
  • Deploy the runtime → unspecialized runtime or stem cell
  • Deploy the function to the runtime → specialized function

Function Instance Function Runtime Resources Runtime deployment Function deployment

slide-41
SLIDE 41

Resource Pooling

  • Common in many domains (e.g. thread pools)

Pool of 3 function runtimes Fn Runtime Fn Runtime Fn Runtime 2 function runtimes → function instances Pool rebalancing Fn Instance Fn Instance Fn Runtime Fn Runtime Fn Runtime Fn Runtime Fn Instance Fn Instance

18

slide-42
SLIDE 42

FaaS platform with function runtime pooling

19

slide-43
SLIDE 43

Trade-off: how big should the pool?

Performance Minimize cost Large pool Handle high concurrency Increases resource overhead Minimal pool Fast pool exhaustion Minimize pool; less idle resources

20

slide-44
SLIDE 44

Route request Trigger deployer Fetch function metadata Deploy pod Deploy function Function Execution Fetch function

21

Function Prefetching

Optimization 3

slide-45
SLIDE 45

Function prefetching

22

Fetch function sources proactively and place them near resources to reduce function transfer latency

  • Software flow has a big impact on cold start durations
  • Function sources (10s of MBs) have to be retrieved and transferred to the resources
  • Especially important for geo-distributed and edge use cases
  • AWS Lambda@edge
  • Cloudflare

Abad, Cristina L. et al. "Package-Aware Scheduling of FaaS Functions." Companion of the 2018 ACM/SPEC International Conference on Performance Engineering. ACM, 2018.

slide-46
SLIDE 46

Prefetching Rack/Machine-level Function-level Remote Storage Cluster-level

slide-47
SLIDE 47

Prefetching Rack/Machine-level Function-level Remote Storage Cluster-level

Higher latency Less storage costs Lower latency More storage costs

slide-48
SLIDE 48

FaaS platform with prefetching

25

slide-49
SLIDE 49

Route request Trigger deployer Fetch function metadata Fetch function Deploy pod Deploy function Function Execution

26

Function Prewarming

Optimization 4

slide-50
SLIDE 50

Function prewarming

Anticipate function executions by deploying functions predictively.

  • Prewarming or predictive scheduling in other domains:
  • CPU branch predictor
  • Proactive autoscalers
  • Predictive caches

27

van Eyk, Erwin, et al. "A SPEC RG CLOUD Group's Vision on the Performance Challenges of FaaS Cloud Architectures." Companion of the 2018 ACM/SPEC International Conference on Performance Engineering. ACM, 2018.

slide-51
SLIDE 51

28

slide-52
SLIDE 52

28

slide-53
SLIDE 53

Predicting function executions is hard...

Active field of research (autoscaling, predictive caches…) Common approaches

  • 1. Runtime analysis
  • Rule-based
  • Pattern recognition and machine learning
  • Artificial intelligence
  • 2. Exploit additional information of functions
  • Dependency knowledge in function compositions
  • Interval triggers

29

slide-54
SLIDE 54

... and involves a trade-off.

Optimistic prewarming Low threshold Misprediction: resources wasted Ping hack Pessimistic prewarming High threshold Misprediction: no prewarm

More performance due to prewarming Less costs due to less mispredicted prewarming

30

slide-55
SLIDE 55
  • Connect existing functions into complex function compositions
  • Workflow engine takes care of the plumbing and provides fully

monitorable, fault-tolerant function compositions with low overhead.

image-recognizer translate-text image-resizer

⼽戉弗

combine-image-text

Sequential execution Parallel execution

validate-image

31

Function composition...

slide-56
SLIDE 56

Fission Workflows supports horizon-based prewarming Not started Prewarmed Finished Started

32

...with prewarming

slide-57
SLIDE 57

Fission Workflows supports horizon-based prewarming Not started Prewarmed Finished Started

32

...with prewarming

slide-58
SLIDE 58

Fission Workflows supports horizon-based prewarming Not started Prewarmed Finished Started

32

...with prewarming

slide-59
SLIDE 59

Fission Workflows supports horizon-based prewarming Not started Prewarmed Finished Started

32

...with prewarming

slide-60
SLIDE 60

Fission Workflows supports horizon-based prewarming Not started Prewarmed Finished Started

32

...with prewarming

slide-61
SLIDE 61

Fission Workflows supports horizon-based prewarming Not started Prewarmed Finished Started

32

...with prewarming

slide-62
SLIDE 62

Fission Workflows supports horizon-based prewarming Not started Prewarmed Finished Started

32

...with prewarming

slide-63
SLIDE 63

Fission Workflows supports horizon-based prewarming Not started Prewarmed Finished Started

32

...with prewarming

slide-64
SLIDE 64

Fission Workflows supports horizon-based prewarming Not started Prewarmed Finished Started

32

...with prewarming

slide-65
SLIDE 65

Fission Workflows supports horizon-based prewarming Not started Prewarmed Finished Started

32

...with prewarming

slide-66
SLIDE 66

Fission Workflows supports horizon-based prewarming Not started Prewarmed Finished Started

32

...with prewarming

slide-67
SLIDE 67

Fission Workflows supports horizon-based prewarming Not started Prewarmed Finished Started

32

...with prewarming

slide-68
SLIDE 68

FaaS platform with workflow-based prewarming

33

slide-69
SLIDE 69

Conclusion

Four techniques key to performance in serverless:

  • 1. Function resource reusing
  • 2. Function runtime pooling
  • 3. Function prefetching
  • 4. Function prewarming

Each makes a trade-off between performance and cost. Serverless: Pay not just for what you use - pay for what you need.

34

slide-70
SLIDE 70

http://fission.io + https://github.com/fission http://fission.io/workflows Slack http://slack.fission.io/ Twitter @fissionio Thanks!

35

Erwin van Eyk Software Engineer, Platform9 Chair, SPEC CLOUD RG Serverless @erwinvaneyk erwin@platform9.com

slide-71
SLIDE 71

Additional Slides

36

slide-72
SLIDE 72

What is next?

  • Function and execution scheduling
  • Workload-based predictions
  • Comprehensive Benchmarks
  • Performance Overhead Reductions
  • Explicit Performance vs. Cost trade-offs

van Eyk, Erwin, et al. "A SPEC RG CLOUD Group's Vision on the Performance Challenges of FaaS Cloud Architectures." Companion of the 2018 ACM/SPEC International Conference on Performance Engineering. ACM, 2018.

37

slide-73
SLIDE 73

FaaS platform with optimizations

38

slide-74
SLIDE 74

Anatomy of a FaaS platform

Build time Developer creates, manages the functions Run time User and external systems events trigger function executions. van Eyk, E., Iosup, A., Seif, S., & Thömmes, M. (2017, December). The SPEC cloud group's research vision on FaaS and serverless architectures. In Proceedings

  • f the 2nd International Workshop on Serverless Computing (pp. 1-4). ACM.

39

slide-75
SLIDE 75

Fission Workflows supports initial horizon-based prewarming

Not started Prewarmed Finished Started

40

Function composition… (pdf version)

slide-76
SLIDE 76

Fission Workflows supports initial horizon-based prewarming

Not started Prewarmed Finished Started

40

Function composition… (pdf version)

slide-77
SLIDE 77

Fission Workflows supports initial horizon-based prewarming

Not started Prewarmed Finished Started

40

Function composition… (pdf version)