Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Case for Rails on Lambda v1

The Case for Rails on Lambda v1

What started as Function as a Service (FaaS) for many is quickly becoming a fulfilled promise on the future of a commoditized cloud-compute platform. Event-driven and deeply integrated within AWS, Lambda allows your Rails architecture to be completely reimagined (without change) atop fully managed infrastructure resources like API Gateway, SQS, S3, CloudWatch, IAM, and much more. Come find out how Lamby can help your engineering teams learn to "program the cloud".

F0b14b7dbae1e90259eb946d1c841a17?s=128

Ken Collins

July 15, 2021
Tweet

Transcript

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

    Collins
  2. • 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
  3. 🐙 Cloud Story 🌦 Custom Ink’s Servers => Cloud =>

    Cloud-Native 3
  4. Do not blindly trust me! 4

  5. Technology solutions are highly coupled to your business. 5

  6. 6

  7. 7

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

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

  10. Modern Compute Transactions June 2021 10

  11. 🧰 Work on Lambda How Does Rails Super High Level

    11
  12. 12 ƒ Functions as a Service (FaaS)

  13. Functions as a Service (FaaS) 13

  14. Functions as a Service (FaaS) 14

  15. Functions as a Service (FaaS) 15

  16. Functions as a Service (FaaS) 16

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

  18. Functions as a Service (FaaS) 18

  19. 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
  20. API Gateway is your managed web server proxy in the

    Cloud! 20
  21. • 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
  22. Execution Env Lifecycle 22

  23. Workload Concerns 23

  24. Workload Concerns 24

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

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

  27. 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

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

    of this works. 28
  29. • 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/
  30. 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.
  31. 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
  32. AWS as a Framework 32

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

  34. 🚅 Rails 🥸 Cloud-Native Helpful Tools and Projects 34

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

  36. • 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
  37. ActiveJob on SQS & Lambda 37 https://github.com/customink/lambdakiq

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

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

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

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

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

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

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

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

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

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

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

    48
  49. Scalable compute should be easy. Not about Lambda v. Kubernetes.

    Easy compute will be our future. Firecracker is still leading. 49
  50. Do not try to out-engineer AWS Partner with them. Apply

    minimal spackle to fill any process/tech gaps. Happily delete your workarounds. 50
  51. 51 Lambda works for existing frameworks! If Express (JavaScript) or

    Bref (PHP) can do it, so can Rails.
  52. Try Lamby out. Use our quick start guide. 52 https://lamby.custominktech.com/docs/quick_start

  53. 53