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 full-size 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 full-size slide

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

    View full-size slide

  4. Do not blindly
    trust me!
    4

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  8. Modern Compute Transactions
    June 2021 10

    View full-size slide

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

    View full-size slide

  10. 12
    ƒ
    Functions as a Service (FaaS)

    View full-size slide

  11. Functions as a Service (FaaS)
    13

    View full-size slide

  12. Functions as a Service (FaaS)
    14

    View full-size slide

  13. Functions as a Service (FaaS)
    15

    View full-size slide

  14. Functions as a Service (FaaS)
    16

    View full-size slide

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

    View full-size slide

  16. Functions as a Service (FaaS)
    18

    View full-size slide

  17. 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 full-size slide

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

    View full-size slide

  19. ● 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 full-size slide

  20. Execution Env Lifecycle
    22

    View full-size slide

  21. Workload Concerns
    23

    View full-size slide

  22. Workload Concerns
    24

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  25. 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 full-size slide

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

    View full-size slide

  27. ● 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 full-size slide

  28. 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 full-size slide

  29. 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 full-size slide

  30. AWS as a Framework
    32

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  34. ● 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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  48. 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 full-size slide

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

    View full-size slide

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

    View full-size slide