Slide 1

Slide 1 text

Up, up and away Serverless on AWS Driss Amri @drissamri88

Slide 2

Slide 2 text

Who is Driss Amri? Blogger at drissamri.com Co-Founder ServerlessDays Belgium Traveler & Diver

Slide 3

Slide 3 text

Idea Customer

Slide 4

Slide 4 text

Idea Dude, Where’s my feature? Customer

Slide 5

Slide 5 text

Idea Request Servers Setup VMWares Customer Setup Network Security Functional testing Load testing Changing requirements Procurement new software Security testing

Slide 6

Slide 6 text

Idea Request Servers Setup VMWares Setup Network Security Functional testing Load testing Changing requirements Procurement new software Security testing Customer

Slide 7

Slide 7 text

Physical Servers Virtual Machines Containers Serverless Code Runtime OS Hardware

Slide 8

Slide 8 text

“The Cloud”

Slide 9

Slide 9 text

AWS

Slide 10

Slide 10 text

Virtual Machines Code Runtime OS Hardware Infrastructure as a Service

Slide 11

Slide 11 text

Code Runtime OS Hardware Container as a Service Containers

Slide 12

Slide 12 text

Serverless Code/Data Runtime OS Hardware Serverless

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

Technology is not the point

Slide 17

Slide 17 text

Services are not the point

Slide 18

Slide 18 text

Code is not the point

Slide 19

Slide 19 text

Code is a liability

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

AWS Lambda?

Slide 22

Slide 22 text

Example: Favorite Service

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

● First invocation ● After deployment or configuration change ● Instances killed due to age ● Scaling out and existing instances busy Cold start frequency

Slide 26

Slide 26 text

The Burning Monk - I’m afraid you’re thinking about AWS Lambda cold starts all wrong

Slide 27

Slide 27 text

The Burning Monk - I’m afraid you’re thinking about AWS Lambda cold starts all wrong

Slide 28

Slide 28 text

The Burning Monk - I’m afraid you’re thinking about AWS Lambda cold starts all wrong

Slide 29

Slide 29 text

The Burning Monk - I’m afraid you’re thinking about AWS Lambda cold starts all wrong

Slide 30

Slide 30 text

● NO: Most likely not when using Node.js, Go, Python, … ● MAYBE: Java (JVM) / .NET Are cold starts a big deal? * When used and optimized correctly

Slide 31

Slide 31 text

● NO: Asynchronous architectures - Event-Driven architectures are a best practise ● NO: Batch processing ● NO: User facing service with normal traffic patterns* - No problem for 99th percentile ● MAYBE: User facing service with occasional traffic* ● MAYBE: User facing service with lots of spread spiky traffic* Are cold starts a big deal? (Java/.NET edition) * When used and optimized correctly

Slide 32

Slide 32 text

● Keep function single purposed* ● Minimize dependencies - webpack, serverless-optimizer-plugin, … ● Use lightweight alternatives - Spring vs Dagger, Apache HTTP vs HttpUrlConnection ● Prefer low overhead runtime (Go, node.js, Python) - Consider GraalVM - … possibly consider Provisioned Concurrency Minimize bootstrap

Slide 33

Slide 33 text

● Initialize as much as you can during startup - Static fields, constructor ● Move state to global - But keep your invocations stateless ● Avoid reflection ● Fail fast ● Right size memory usage - 1792 MB = 1 vCPU Optimize execution time

Slide 34

Slide 34 text

● AWS re:Invent 2019: [REPEAT 1] Best practices for AWS Lambda and Java (SVS403-R1) @sapessi ... more on AWS Lambda and Java ● How to minimize AWS Lambda Java cold starts @drissamri88 ● Programming AWS Lambda by John Chapin, Mike Roberts ● Analyzing Cold Start latency of AWS Lambda @mikebroberts

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

Infrastructure-as-code

Slide 37

Slide 37 text

Infrastructure-as-code AWS ● Serverless Framework ● Terraform ● Pulumi ● CloudFormation ● Serverless Application Model (SAM) ● Cloud Development Kit (CDK) 3th party

Slide 38

Slide 38 text

Serverless Framework ● Most widely used Serverless toolkit ● Released in 2015 ● Simple Developer Experience ● Focus on Functions, not Cloud Infrastructure ● Cloud-agnostic - AWS provider: - Compiles to CloudFormation - deployed as CloudFormation Stack

Slide 39

Slide 39 text

Serverless Framework

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

AWS SAM ● Official AWS deployment framework ● Released in 2016 ● Built on top of CloudFormation - Deployed as CloudFormation Stack

Slide 42

Slide 42 text

AWS SAM

Slide 43

Slide 43 text

AWS SAM CLI sam init --runtime java11 sam package \ --output-template-file packaged.yaml \ --s3-bucket bucketname sam deploy \ --template-file packaged.yaml \ --stack-name sam-app \ --capabilities CAPABILITY_IAM \ --region eu-west-1 aws cloudformation delete-stack --stack-name sam-app

Slide 44

Slide 44 text

Cost control

Slide 45

Slide 45 text

https://theburningmonk.com/2019/01/you-are-thinking-about-serverless-costs-all-wrong/ “You are thinking about serverless costs all wrong” - @theburningmonk

Slide 46

Slide 46 text

https://forrestbrazeal.com/2020/01/05/code-wise-cloud-foolish-avoiding-bad-technology-choices/ “Code-wise, cloud-foolish: avoiding bad technology choices” - @forrestbrazeal

Slide 47

Slide 47 text

Determining the Total Cost of Ownership of Serverless Technologies when compared to Traditional Cloud

Slide 48

Slide 48 text

Resources ServerlessDays Belgium - Meetup Edition #1 YouTube - Join the meetup Presentations - Serverless - Lessons Learned - Nike Brown Bag