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

Ken Collins

July 15, 2021
Tweet

More Decks by Ken Collins

Other Decks in Technology

Transcript

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

    View Slide

  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

    View Slide

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

    View Slide

  4. Do not blindly
    trust me!
    4

    View Slide

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

    View Slide

  6. 6

    View Slide

  7. 7

    View Slide

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

    View Slide

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

    View Slide

  10. Modern Compute Transactions
    June 2021 10

    View Slide

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

    View Slide

  12. 12
    ƒ
    Functions as a Service (FaaS)

    View Slide

  13. Functions as a Service (FaaS)
    13

    View Slide

  14. Functions as a Service (FaaS)
    14

    View Slide

  15. Functions as a Service (FaaS)
    15

    View Slide

  16. Functions as a Service (FaaS)
    16

    View Slide

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

    View Slide

  18. Functions as a Service (FaaS)
    18

    View Slide

  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

    View Slide

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

    View Slide

  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

    View Slide

  22. Execution Env Lifecycle
    22

    View Slide

  23. Workload Concerns
    23

    View Slide

  24. Workload Concerns
    24

    View Slide

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

    View Slide

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

    View Slide

  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

    View Slide

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

    View Slide

  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/

    View Slide

  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.

    View Slide

  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

    View Slide

  32. AWS as a Framework
    32

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  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

    View Slide

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

    View Slide

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

    View Slide

  53. 53

    View Slide