Slide 1

Slide 1 text

Going Serverless: AWS Lambda Martin Smith, DevOps Engineer [email protected]

Slide 2

Slide 2 text

Martin B. Smith, DevOps Engineer @ Rackspace @martinb3 - http://martinb3.io - [email protected] - github:martinb3 15 years of infrastructure automation, software development, systems administration. Unhealthy obsession with acquiring new hobbies: Memes in presentations, Photography, Knitting, Baking, Kayaking, Languages, Travel…

Slide 3

Slide 3 text

The Plan What is Lambda. Why it matters. Demo. Limits.

Slide 4

Slide 4 text

I lied. Here’s what I want you to know.

Slide 5

Slide 5 text

The Plan What is Lambda. Why it matters. Demo. Limits.

Slide 6

Slide 6 text

AWS ‘Services’ Compute: EC2, ECS, EMR, Lambda* Net: Route53, VPC, DirectConn., ELB CDN: CloudFront Storage: S3, Glacier, EBS, EFS DB: Dynamo, RDS, Kinesis, SimpleDB Deployment: CF, ElasticBeanstalk, OpsWorks, CodeDeploy Mgmt: IAM, Directory Services, CloudWatch, KMS App Mgmt: API Gateway, Search, SES, SQS, SNS, SWF, ad nauseam. Mechanical turk...

Slide 7

Slide 7 text

AWS ‘Services’ Compute: EC2, ECS, EMR, Lambda* Net: Route53, VPC, DirectConn., ELB CDN: CloudFront Storage: S3, Glacier, EBS, EFS DB: Dynamo, RDS, Kinesis, SimpleDB Deployment: CF, ElasticBeanstalk, OpsWorks, CodeDeploy Mgmt: IAM, Directory Services, CloudWatch, KMS App Mgmt: API Gateway, Search, SES, SQS, SNS, SWF, ad nauseam. Mechanical turk...

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Lambda “AWS Lambda lets you run code without provisioning or managing servers.” Like the calculus.

Slide 10

Slide 10 text

Lambda exports.myHandler = function(event, context) { console.log("value1 = " + event.key1); console.log("value2 = " + event.key2); context.succeed("some message"); } NodeJS

Slide 11

Slide 11 text

Lambda package example; import com.amazonaws.services.lambda.runtime. Context; public class Hello { public String myHandler(String name, Context context) { return String.format("Hello %s.", name); } } Java

Slide 12

Slide 12 text

Lambda def my_handler(event, context): message = 'Hello {} {}!'.format (event ['first_name'], event['last_name']) return {'message' : message} Python

Slide 13

Slide 13 text

$ (requests) * (GB*seconds)

Slide 14

Slide 14 text

1M requests 400k GB-seconds

Slide 15

Slide 15 text

$0.00001667 per GB*s $0.0000002 per req.

Slide 16

Slide 16 text

Pricing Example 1 If you allocated 512MB of memory to your function, executed it 3 million times in one month, and it ran for 1 second each time, your charges would be calculated as follows: Monthly compute charges The monthly compute price is $0.00001667 per GB-s and the free tier provides 400,000 GB-s. Total compute (seconds) = 3M * (1s) = 3,000,000 seconds Total compute (GB-s) = 3,000,000 * 512MB/1024 = 1,500,000 GB-s Total compute – Free tier compute = Monthly billable compute GB- s 1,500,000 GB-s – 400,000 free tier GB-s = 1,100,000 GB-s Monthly compute charges = 1,100,000 * $0.00001667 = $18.34 Monthly request charges The monthly request price is $0.20 per 1 million requests and the free tier provides 1M requests per month. Total requests – Free tier requests = Monthly billable requests 3M requests – 1M free tier requests = 2M Monthly billable requests Monthly request charges = 2M * $0.2/M = $0.40 Total monthly charges Total charges = Compute charges + Request charges = $18.34 + $0.40 = $18.74 per month

Slide 17

Slide 17 text

Pricing Example 2 If you allocated 128MB of memory to your function, executed it 30 million times in one month, and it ran for 200ms each time, your charges would be calculated as follows: Monthly compute charges The monthly compute price is $0.00001667 per GB-s and the free tier provides 400,000 GB-s. Total compute (seconds) = 30M * (0.2sec) = 6,000,000 seconds Total compute (GB-s) = 6,000,000 * 128MB/1024 = 750,000 GB-s Total Compute – Free tier compute = Monthly billable compute seconds 750,000 GB-s – 400,000 free tier GB-s = 350,000 GB-s Monthly compute charges = 350,000 * $0.00001667 = $5.83 Monthly request charges The monthly request price is $0.20 per 1 million requests and the free tier provides 1M requests per month. Total requests – Free tier request = Monthly billable requests 30M requests – 1M free tier requests = 29M Monthly billable requests Monthly request charges = 29M * $0.2/M = $5.80 Total compute charges Total charges = Compute charges + Request charges = $5.83 + $5.80 = $11.63 per month

Slide 18

Slide 18 text

The Plan What is Lambda. Why it matters. Demo. Limits.

Slide 19

Slide 19 text

So much integration potential.

Slide 20

Slide 20 text

Could easily replace crontab or batch workloads. Scaling is a non-issue. Parallel-friendly workloads. Already seeing backup jobs for S3 built in Lambda. Could replace Heroku. Could replace FastCGI & workers. Single page apps... Event driven infrastructure

Slide 21

Slide 21 text

Image processing app

Slide 22

Slide 22 text

Squirrelbin

Slide 23

Slide 23 text

Deploy Lambda w/ Lambda

Slide 24

Slide 24 text

CI/CD or Load Testing Pipeline

Slide 25

Slide 25 text

CRISPR: edit genomes with unprecedented precision, efficiency, and flexibility.

Slide 26

Slide 26 text

The list goes on - Architectures - Event-driven computing - Startups - Microservices - Testing - Analytics - Stream processing - ETL / Batch - Statistics / metrics - Machine learning Serverless...

Slide 27

Slide 27 text

The New Normal - EC2 & S3 replaced VMs & File Storage - Immutable infrastructure, cattle not pets. Automated provisioning. Self-healing. - Will Lambda replace these? All the right constraints for another revolution.

Slide 28

Slide 28 text

Next?

Slide 29

Slide 29 text

Cost dominated by CDN

Slide 30

Slide 30 text

The Plan What is Lambda. Why it matters. Demo. Limits.

Slide 31

Slide 31 text

I lied. These demos aren’t live.

Slide 32

Slide 32 text

Sending Slack messages

Slide 33

Slide 33 text

Validating Chef configurations

Slide 34

Slide 34 text

Fanout jobs

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

The Plan What is Lambda. Why it matters. Demo. Limits.

Slide 37

Slide 37 text

Language Choice C++, Ruby, Golang, etc

Slide 38

Slide 38 text

Identity & Access Management $$$$$$$$$$$$$$$$$$$$$$$

Slide 39

Slide 39 text

Performance Options Many more EC2 instance sizes.

Slide 40

Slide 40 text

Return Values Uneven. Mapping to HTTP errors is hard.

Slide 41

Slide 41 text

Dependency packaging OpenSSL? PyCrypto? :redflag:

Slide 42

Slide 42 text

Testing Local environments != Production

Slide 43

Slide 43 text

No Structure Huge List only gets bigger.

Slide 44

Slide 44 text

Regions in AWS. Not available everywhere.

Slide 45

Slide 45 text

Latency Around 1s for initial call, 100ms after

Slide 46

Slide 46 text

Never-catch-up Problem > 300s ad infinitum.

Slide 47

Slide 47 text

Vendor Lockin Perhaps. Perhaps not.

Slide 48

Slide 48 text

Competitors? Facebook: Parse, Firebase

Slide 49

Slide 49 text

Fin.