Slide 1

Slide 1 text

jameseastham.co.uk loige.co Serverless Rust: Your Low-Risk Entry Point to Rust in Production James Eastham (he/him) Talking Serverless Datadog Luciano Mammino (he/him) Senior Architect Four Theorem

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

ÒYou CAN have it all. You just canÕt have it all at once. Oprah Winfrey

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

James Eastham Serverless Advocate

Slide 8

Slide 8 text

Plant Based Pizza

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

ÒSomething, something, trade- offsÉÓ

Slide 12

Slide 12 text

ÒIt DependsÉÓ

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

Make it safe

Slide 17

Slide 17 text

Application Infrastructure

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

Infrastructure

Slide 21

Slide 21 text

Serverless What does it even mean?

Slide 22

Slide 22 text

ÒServerless is a spectrum, not a binary decision. James Eastham

Slide 23

Slide 23 text

Operational Overhead Less More Infrastructure Flexibility

Slide 24

Slide 24 text

Technology Cost Human Cost

Slide 25

Slide 25 text

AWS Lambda Azure Functions GCP Cloud Run AWS Fargate ECS Azure Container Apps EKS AKS GKE EC2 Azure VM Compute Engine Cloudflare Workers

Slide 26

Slide 26 text

ÒIf you think Ôserverless firstÕ you aim to reduce your operational overhead as much as possible James Eastham

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

AWS Lambda AWS Fargate ECS EKS EC2

Slide 29

Slide 29 text

AWS Lambda AWS Fargate ECS EKS EC2

Slide 30

Slide 30 text

AWS Lambda AWS Fargate ECS EKS EC2

Slide 31

Slide 31 text

AWS Lambda AWS Fargate ECS EKS EC2

Slide 32

Slide 32 text

AWS Fargate ECS

Slide 33

Slide 33 text

Blog

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

What about sustainability?

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

AWS Lambda

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

Your Application

Slide 48

Slide 48 text

Your Application

Slide 49

Slide 49 text

How Lambda Works?

Slide 50

Slide 50 text

Create Execution Environment Download Code Initialise Runtime & Code Handle Request Initialisation Invoke

Slide 51

Slide 51 text

1 2 3

Slide 52

Slide 52 text

Caller Sync Invoke

Slide 53

Slide 53 text

Lambda poller Internal Queue Caller Async Invoke

Slide 54

Slide 54 text

Lambda poller Poll Invoke

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

Requests per month

Slide 66

Slide 66 text

ÒOk James. I’m convinced! How do I get started? All of you In the audience

Slide 67

Slide 67 text

Luciano Mammino Senior Cloud Architect

Slide 68

Slide 68 text

How does a Lambda function execute Rust code?

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

The magic of Custom Runtimes!

Slide 73

Slide 73 text

The magic of Custom Runtimes!

Slide 74

Slide 74 text

The magic of Custom Runtimes! Runtime Handler (logic) Runtime API Poll for events Event (JSON) Execute (event) Response or Error Response or Error (JSON)

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

Load the handler code

Slide 78

Slide 78 text

Infinite loop

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

LetÕs now write this in Rust!

Slide 83

Slide 83 text

Just kiddingÉ AWS has already done that! 😜

Slide 84

Slide 84 text

📝 Our first Lambda function in Rust - Create a new project - Install the lambda runtime - Write init code - Write handler code - deserialise event - add the biz logic - serialise response - Build it (Amazon Linux x86/arm64) - Zip it - Ship it

Slide 85

Slide 85 text

A (much) better way: Cargo Lambda

Slide 86

Slide 86 text

Our first HTTP Lambda

Slide 87

Slide 87 text

Our first HTTP Lambda

Slide 88

Slide 88 text

Our first HTTP Lambda

Slide 89

Slide 89 text

Our first HTTP Lambda

Slide 90

Slide 90 text

Our first HTTP Lambda

Slide 91

Slide 91 text

Our first HTTP Lambda

Slide 92

Slide 92 text

Our first HTTP Lambda

Slide 93

Slide 93 text

Our first HTTP Lambda

Slide 94

Slide 94 text

Our first HTTP Lambda

Slide 95

Slide 95 text

Our first HTTP Lambda

Slide 96

Slide 96 text

Our first HTTP Lambda

Slide 97

Slide 97 text

Local testing

Slide 98

Slide 98 text

Local testing Full list of example events: loige.link/rust-lambda-events

Slide 99

Slide 99 text

Our first HTTP Lambda

Slide 100

Slide 100 text

Our first HTTP Lambda

Slide 101

Slide 101 text

Our first HTTP Lambda

Slide 102

Slide 102 text

Local testing

Slide 103

Slide 103 text

Local testing

Slide 104

Slide 104 text

Building and shipping 🚢

Slide 105

Slide 105 text

Building and shipping 🚢

Slide 106

Slide 106 text

Building and shipping 🚢

Slide 107

Slide 107 text

Building and shipping 🚢

Slide 108

Slide 108 text

Building and shipping 🚢

Slide 109

Slide 109 text

Building and shipping 🚢

Slide 110

Slide 110 text

HTTP É Great! But what about consuming from Kafka?

Slide 111

Slide 111 text

You know the drillÉ

Slide 112

Slide 112 text

You know the drillÉ

Slide 113

Slide 113 text

You know the drillÉ

Slide 114

Slide 114 text

You know the drillÉ

Slide 115

Slide 115 text

Our first HTTP Lambda

Slide 116

Slide 116 text

Our first HTTP Lambda

Slide 117

Slide 117 text

Our first HTTP Lambda

Slide 118

Slide 118 text

Our first HTTP Lambda

Slide 119

Slide 119 text

Our first HTTP Lambda

Slide 120

Slide 120 text

Our first HTTP Lambda

Slide 121

Slide 121 text

No content

Slide 122

Slide 122 text

No content

Slide 123

Slide 123 text

Cargo Lambda supports tons of AWS events

Slide 124

Slide 124 text

Éand you can have your custom ones too!

Slide 125

Slide 125 text

Éand you can have your custom ones too!

Slide 126

Slide 126 text

Éand you can have your custom ones too!

Slide 127

Slide 127 text

Cargo Lambda is cool! But I want to use Terraform CDK SAM Something else!

Slide 128

Slide 128 text

And you should! 😉 Cargo Lambda is fantastic for: - Scaffolding - Local Testing - Compiling (and cross-compiling!) But for deploying your Lambda Functions (with the rest of your infrastructure) You MUST use a proper IaC tool! Check out the Docs to learn how: loige.link/cargo-lambda-iac

Slide 129

Slide 129 text

A case study! A Lambda Authorizer in Rust! Authenticated Request Your backend Custom Authorizer Lambda API Gateway

Slide 130

Slide 130 text

A case study! A Lambda Authorizer in Rust! - The original version was written in Python - Since it was one of the most invoked functions we rewrote it in Rust - The change lead to: - 30% less cold starts - 90% decrease Init time - 60% decrease Execution time - 70% less memory - 50% cost reduction

Slide 131

Slide 131 text

A case study! A Lambda Authorizer in Rust! - This project is now open-source: github.com/lmammino/oidc-authorizer - And the benchmarks are available too!

Slide 132

Slide 132 text

Summary - Rust and Serverless is a perfect combo! - It gives you - Great performance - Safety - Cost reduction - Environmentally friendly applications - Serverless applications are small: Minimum risk / investment - If you are on AWS: use Cargo Lambda - Now go build your next Serverless app, with Rust!

Slide 133

Slide 133 text

jameseastham.co.uk loige.co We are writing a book! rust-lambda.com