Slide 1

Slide 1 text

Custom AWS lambda runtimes ...and a crystal demo Alexander Reelsen @spinscale [email protected]

Slide 2

Slide 2 text

There is no serverless architecture. It's just someone else's execution environment. Alex R. THE TRUTH[TM]

Slide 3

Slide 3 text

WHO DAT? About me ▸ Working distributed at Elastic since 2013 ▸ Elasticsearch developer ▸ Dislikes running own infrastructure ▸ Basketball & JVM fan, husband, dad

Slide 4

Slide 4 text

AND NOW FOR A LESSON IN... Agenda ▸ Custom AWS Lambda runtimes ▸ Introduction into crystal lang ▸ A crystal based runtime

Slide 5

Slide 5 text

AWS Lambda

Slide 6

Slide 6 text

FAAS

Slide 7

Slide 7 text

node.js

Slide 8

Slide 8 text

python

Slide 9

Slide 9 text

go

Slide 10

Slide 10 text

java

Slide 11

Slide 11 text

JVM

Slide 12

Slide 12 text

startup time

Slide 13

Slide 13 text

dependencies

Slide 14

Slide 14 text

JIT

Slide 15

Slide 15 text

2015: custom runtime?

Slide 16

Slide 16 text

node shim https://aws.amazon.com/blogs/compute/running-executables-in-aws-lambda/

Slide 17

Slide 17 text

2018: custom runtime!

Slide 18

Slide 18 text

all the languages!

Slide 19

Slide 19 text

runtime flow

Slide 20

Slide 20 text

CUSTOM RUNTIME

Slide 21

Slide 21 text

CUSTOM RUNTIME AWS_LAMBDA_RUNTIME_API=localhost:12345 _HANDLER="my_handler" /bin/bootstrap

Slide 22

Slide 22 text

AWS ENDPOINT CUSTOM RUNTIME AWS_LAMBDA_RUNTIME_API=localhost:12345 _HANDLER="my_handler" /bin/bootstrap

Slide 23

Slide 23 text

AWS ENDPOINT CUSTOM RUNTIME GET /2018-06-01/runtime/invocation/next AWS_LAMBDA_RUNTIME_API=localhost:12345 _HANDLER="my_handler" /bin/bootstrap

Slide 24

Slide 24 text

AWS ENDPOINT CUSTOM RUNTIME GET /2018-06-01/runtime/invocation/next Lambda-Runtime-Aws-Request-Id: 123 { "body": "{ \"foo\": \"bar\" }", "requestContext": "{ ... }", "headers" : { ... } } AWS_LAMBDA_RUNTIME_API=localhost:12345 _HANDLER="my_handler" /bin/bootstrap

Slide 25

Slide 25 text

AWS ENDPOINT CUSTOM RUNTIME POST /2018-06-01/runtime/invocation/123/response { "body": "{ \"foo\": \"bar\" }", "headers" : { ... } } AWS_LAMBDA_RUNTIME_API=localhost:12345 _HANDLER="my_handler" /bin/bootstrap

Slide 26

Slide 26 text

AWS ENDPOINT CUSTOM RUNTIME POST /2018-06-01/runtime/invocation/123/response { "body": "{ \"foo\": \"bar\" }", "headers" : { ... } } HTTP OK 202 AWS_LAMBDA_RUNTIME_API=localhost:12345 _HANDLER="my_handler" /bin/bootstrap

Slide 27

Slide 27 text

AWS ENDPOINT CUSTOM RUNTIME POST /2018-06-01/runtime/invocation/123/error { "statusCode": 500, "body" : "..." } AWS_LAMBDA_RUNTIME_API=localhost:12345 _HANDLER="my_handler" /bin/bootstrap

Slide 28

Slide 28 text

AWS ENDPOINT CUSTOM RUNTIME POST /2018-06-01/runtime/init/error { "errorMessage" : "...", "errorType" : "..." } AWS_LAMBDA_RUNTIME_API=localhost:12345 _HANDLER="my_handler" /bin/bootstrap

Slide 29

Slide 29 text

crystal

Slide 30

Slide 30 text

readable

Slide 31

Slide 31 text

fast

Slide 32

Slide 32 text

statically typed

Slide 33

Slide 33 text

batteries included

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

testing

Slide 36

Slide 36 text

benchmarks

Slide 37

Slide 37 text

metaprogramming

Slide 38

Slide 38 text

fibers

Slide 39

Slide 39 text

channels

Slide 40

Slide 40 text

boehm gc

Slide 41

Slide 41 text

c bindings

Slide 42

Slide 42 text

dependency mgmt

Slide 43

Slide 43 text

web frameworks

Slide 44

Slide 44 text

binaries

Slide 45

Slide 45 text

static binaries

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

demo

Slide 50

Slide 50 text

summary

Slide 51

Slide 51 text

easy

Slide 52

Slide 52 text

$$$

Slide 53

Slide 53 text

static binaries

Slide 54

Slide 54 text

aws library

Slide 55

Slide 55 text

examples

Slide 56

Slide 56 text

static sites, dynamic

Slide 57

Slide 57 text

slack hook

Slide 58

Slide 58 text

github hook

Slide 59

Slide 59 text

location tracking

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

scheduled jobs

Slide 62

Slide 62 text

emails

Slide 63

Slide 63 text

reverse geocoder

Slide 64

Slide 64 text

thank you

Slide 65

Slide 65 text

HYPER HYPER Links ▸ https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html ▸ https://docs.aws.amazon.com/lambda/latest/dg/runtimes-walkthrough.html ▸ https://crystal-lang.org ▸ https://github.com/spinscale/crystal-aws-lambda ▸ AWS Lambda Under the Hood: https://www.youtube.com/watch?v=QdzV04T_kec ▸ Firecracker: https://firecracker-microvm.github.io/ ▸ Boehm GC: http://www.hboehm.info/gc/ ▸ FaastRuby: https://faastruby.io/getting-started-crystal/ ▸ Google Cloud Functions: https://github.com/sam0x17/gcf.cr ▸ Crystal on OpenFaas: https://github.com/TPei/crystal_openfaas

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

@spinscale [email protected]

Slide 68

Slide 68 text

questions?