Slide 1

Slide 1 text

1 The Case for Rails on Lambda 2021-07-14 by Ken Collins

Slide 2

Slide 2 text

● Custom Ink’s Cloud Story. Servers to Serverless. ● How does Rails work on Lambda? High level intro. ● Why the hell would we, or should you, do this? ● Cloud-Native Rails. Helpful tools and projects. ● Closing thoughts on our future with the Cloud. 2 Today’s Topics

Slide 3

Slide 3 text

🐙 Cloud Story 🌦 Custom Ink’s Servers => Cloud => Cloud-Native 3

Slide 4

Slide 4 text

Do not blindly trust me! 4

Slide 5

Slide 5 text

Technology solutions are highly coupled to your business. 5

Slide 6

Slide 6 text

6

Slide 7

Slide 7 text

7

Slide 8

Slide 8 text

Using Lambda since 2017 https://aws.amazon.com/lambda/resources/customer-testimonials/ 8

Slide 9

Slide 9 text

Rails on Lambda with Lamby https://lamby.custominktech.com 9

Slide 10

Slide 10 text

Modern Compute Transactions June 2021 10

Slide 11

Slide 11 text

🧰 Work on Lambda How Does Rails Super High Level 11

Slide 12

Slide 12 text

12 ƒ Functions as a Service (FaaS)

Slide 13

Slide 13 text

Functions as a Service (FaaS) 13

Slide 14

Slide 14 text

Functions as a Service (FaaS) 14

Slide 15

Slide 15 text

Functions as a Service (FaaS) 15

Slide 16

Slide 16 text

Functions as a Service (FaaS) 16

Slide 17

Slide 17 text

Functions as a Service (FaaS) https://github.com/rack/rack 17

Slide 18

Slide 18 text

Functions as a Service (FaaS) 18

Slide 19

Slide 19 text

Lamby is as a Rack adapter that converts AWS Lambda integration events into native Rack Environment objects which are sent directly to your application. Lamby can do this when using either API Gateway REST API, API Gateway HTTP API's v1/v2 payloads, or even Application Load Balancer (ALB) integrations. 19 https://lamby.custominktech.com

Slide 20

Slide 20 text

API Gateway is your managed web server proxy in the Cloud! 20

Slide 21

Slide 21 text

● Container Packages. Up to 10 GB Size. ECR or DIY. ● Up to 6 vCPU and 10 GB Memory. Zip or Container. ● Usage of a VPC has no performance penalties. ● API Gateway HTTP API fast & cheap for public apps. ● The AWS SAM CLI (CloudFormation) is easy IaC. ● CloudWatch Logs, Insights, and Metrics are built in. ● Integrate CodeDeploy Blue Green Rollouts. ● Provisioned Concurrency can kill cold starts for $$$. Lambda Highlights 21

Slide 22

Slide 22 text

Execution Env Lifecycle 22

Slide 23

Slide 23 text

Workload Concerns 23

Slide 24

Slide 24 text

Workload Concerns 24

Slide 25

Slide 25 text

25 1792: (1) vCPU 3008: (2) vCPU Memory & Virtual CPUs

Slide 26

Slide 26 text

26 ~80/~80 (p50) ~270/~260 (p95) ~470/~435 (p99) Transaction %’tiles (before/after)

Slide 27

Slide 27 text

DIY Lambda Containers (RIC/RIE) https://hichaelmart.medium.com/using-container-images-with-aws-lambda-7ffbd23697f1 https://github.com/aws/aws-lambda-ruby-runtime-interface-client 27

Slide 28

Slide 28 text

🤷 Do This? Why Would Anyone That’s not how any of this works. 28

Slide 29

Slide 29 text

● Our first workload was ~90% EC2 cost savings. Years later, others could be 70%, 30%, or 130%. Depends on your current right sizing and infrastructure. ● Private Applications cost more. REST API w/ALB via VPC Endpoint easily consumes EC2 cost savings. ● Factor in capability unlocks. Could be technical ones like using cloud-native integrations. Could be process like building DevOps experience. Cost Savings (Efficiency Dilemma) 29 https://aws.amazon.com/lambda/resources/customer-testimonials/

Slide 30

Slide 30 text

Infrastructure as Code (IaC) 30 ● Project-based IaC is a game changer for dev velocity. Great example is IAM Roles with Lambda. ● SAM/CloudFormation is a great start and always getting better. Like modules & the public directory. ● Graduate later to CDK or Terraform which can express existing resources.

Slide 31

Slide 31 text

AWS as a Framework 31 ● Lambda is deeply integrated into AWS’ event model. ● Lambda can help your path to Cloud Modernization. ● Managed tooling/pipelines. CodeBuild blue/green. ● Lambda unlocks new architecture capabilities. https://medium.com/galvanize/aws-as-a-framework-9abd2b1f6dc1

Slide 32

Slide 32 text

AWS as a Framework 32

Slide 33

Slide 33 text

It Works. Really Well. 33 https://www.customink.com/products

Slide 34

Slide 34 text

🚅 Rails 🥸 Cloud-Native Helpful Tools and Projects 34

Slide 35

Slide 35 text

35 ActiveJob on SQS & Lambda https://github.com/customink/lambdakiq

Slide 36

Slide 36 text

● Distinct web & jobs Lambda functions. ● AWS fully managed polling. Event-driven. ● Maximum 12 retries. Per job configurable. ● Mirror Sidekiq's retry backoff timing. ● Last retry is at 11 hours 30 minutes. ● Supports ActiveJob's wait/delay. Up to 15 minutes. ● Dead messages are stored for up to 14 days. ActiveJob on SQS & Lambda https://github.com/customink/lambdakiq 36

Slide 37

Slide 37 text

ActiveJob on SQS & Lambda 37 https://github.com/customink/lambdakiq

Slide 38

Slide 38 text

ActiveJob on SQS & Lambda 38 https://github.com/customink/lambdakiq

Slide 39

Slide 39 text

ActiveJob on SQS & Lambda 39 https://github.com/customink/lambdakiq

Slide 40

Slide 40 text

ActiveJob on SQS & Lambda https://github.com/customink/lambdakiq 40

Slide 41

Slide 41 text

ActiveJob on SQS & Lambda https://github.com/customink/lambdakiq 41

Slide 42

Slide 42 text

ActiveJob on SQS & Lambda https://github.com/customink/lambdakiq 42

Slide 43

Slide 43 text

ActiveJob on SQS & Lambda https://github.com/customink/lambdakiq 43

Slide 44

Slide 44 text

Async Processing using Extensions https://github.com/customink/lambda_punch 44

Slide 45

Slide 45 text

Async Processing using Extensions 45 https://github.com/customink/lambda_punch

Slide 46

Slide 46 text

Async Processing using Extensions 46 https://github.com/customink/lambda_punch

Slide 47

Slide 47 text

Async Processing using Extensions 47 https://github.com/customink/lambda_punch

Slide 48

Slide 48 text

😎 Cloud Future Closing Thoughts What are we headed towards? 48

Slide 49

Slide 49 text

Scalable compute should be easy. Not about Lambda v. Kubernetes. Easy compute will be our future. Firecracker is still leading. 49

Slide 50

Slide 50 text

Do not try to out-engineer AWS Partner with them. Apply minimal spackle to fill any process/tech gaps. Happily delete your workarounds. 50

Slide 51

Slide 51 text

51 Lambda works for existing frameworks! If Express (JavaScript) or Bref (PHP) can do it, so can Rails.

Slide 52

Slide 52 text

Try Lamby out. Use our quick start guide. 52 https://lamby.custominktech.com/docs/quick_start

Slide 53

Slide 53 text

53