functional programming in serverless world · 2019-05-20 · 5. container reuse in aws lambda,...

35
Functional Programming in Serverless World Big Data Moscow 2018 (11.10.2018)

Upload: others

Post on 22-May-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Functional Programming in Serverless World

Big Data Moscow 2018 (11.10.2018)

Page 2: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

~ # whoami (afronski)

✓ Co-founder and Functional Aficionadoat Pattern Match

Erlang, Elixir, Node.jsAWS (3 certificates)

✓ Co-organizer of Functional Miners

Page 3: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:
Page 4: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

What is serverless?

Page 5: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:
Page 6: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

There are servers

Page 7: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

There are ops

Page 9: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Serverless

Back-end as a Service (BaaS)

Function as a Service (FaaS)

Page 10: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Incoming Event

Source Code Package Configuration

Function (Execution Unit)

RAM: 512 MB

RAM: 512 MB 0.5 GB

Real time: 120 msBill time: 200 ms (buckets by 100 ms)

Price: 0.00001667 GB * seconds

Cost: 0.00001667 * 0.5 GB * 0.2 s = 0.000001667 USD = 1.7 μUSD

Response

Page 11: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Whyserverless?

Page 12: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

www.doc.ic.ac.uk/~rbc/papers/fse-serverless-17.pdf

Gojko Adzic - Designing for the Serverless Age (GOTO 2017)

Page 13: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Costs

Page 14: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Architecture[...] breaking the monolith into functions that could be independently deployed, meant that they were better able to split the team up to work on more things in parallel, and to deploy each feature separately.

Page 15: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Operations[…] so their estimate is that moving to Lambda gave an operational cost reduction of greater than 95% for a comparable amount of compute.

Page 16: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:
Page 17: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Technology

Page 18: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:
Page 19: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:
Page 20: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Shims

Using Node.js process API to spawn an

executable

Handling events reported by subprocess and passing results to

the AWS Lambda handler

Sending input arguments to the

spawned subprocess

Page 21: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:
Page 22: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Measurements

Page 23: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Test Scenarios1. Two endpoints:

a. Echoing incoming body.

b. Sieve of Eranthoses (naive implementation).

2. Package Size.

3. Memory Usage (dependent on input argument).

4. Execution Time (dependent on input argument).

5. Startup Time (cold start, no work done).

Page 24: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:
Page 25: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:
Page 26: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

"Situated" Programs (from Rich Hickey's keynote at Clojure/Conj 2017)

Page 28: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Constraints

Page 29: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Constraints1. No knowledge about container and its reuse.

2. New approach requires new paths.

3. Limits everywhere!

4. Provider limitations.

5. VM optimizations required from the get go.

6. Beware the toolchain!

Page 30: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Summary

Page 31: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Safe default:F# on Azure or AWS

(.NET Core 2.0)

Page 32: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Tooling is King

Page 33: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Context is King

Page 34: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

Thank you!Questions?

Page 35: Functional Programming in Serverless World · 2019-05-20 · 5. Container Reuse in AWS Lambda, Serverless: Cold Start War. 6. Running Executables in AWS Lambda. 7. Serverless Computing:

References

1. Our company - Pattern Match and my talks.2. Functional Miners meet-up (facebook, twitter, github, email, website).3. Serverless Architecture, Serverless (Martin Fowler’s articles).4. AWS Lambda, Google Cloud Functions, Azure Functions.5. Container Reuse in AWS Lambda, Serverless: Cold Start War.6. Running Executables in AWS Lambda.7. Serverless Computing: Economic and Architectural Impact.8. Why the JVM is a Good Choice for Serverless Computing.9. Droplr Serverless Revolution.

10. Optimizing Enterprise Economics with Serverless.11. Should I use AWS Lambda or EC2?12. AWS Lambda support for .NET Core 2.0.13. Repository with examples, scripts, and measurements.