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

Getting started w/ Serverless @ AWS UG

Driss Amri
April 02, 2022
6

Getting started w/ Serverless @ AWS UG

Driss Amri

April 02, 2022
Tweet

Transcript

  1. Up, up and away
    Serverless on AWS
    Driss Amri
    @drissamri88

    View Slide

  2. Who is Driss Amri?
    Blogger at drissamri.com
    Co-Founder ServerlessDays Belgium
    Traveler & Diver

    View Slide

  3. Idea
    Customer

    View Slide

  4. Idea
    Dude, Where’s my feature?
    Customer

    View Slide

  5. Idea
    Request Servers
    Setup VMWares
    Customer
    Setup Network Security
    Functional testing
    Load testing
    Changing requirements
    Procurement new software
    Security testing

    View Slide

  6. Idea
    Request Servers
    Setup VMWares
    Setup Network Security
    Functional testing
    Load testing
    Changing requirements
    Procurement new software
    Security testing
    Customer

    View Slide

  7. Physical
    Servers
    Virtual
    Machines
    Containers Serverless
    Code
    Runtime
    OS
    Hardware

    View Slide

  8. “The Cloud”

    View Slide

  9. AWS

    View Slide

  10. Virtual
    Machines
    Code
    Runtime
    OS
    Hardware
    Infrastructure as a Service

    View Slide

  11. Code
    Runtime
    OS
    Hardware
    Container as a Service
    Containers

    View Slide

  12. Serverless
    Code/Data
    Runtime
    OS
    Hardware
    Serverless

    View Slide

  13. View Slide

  14. View Slide

  15. View Slide

  16. Technology is not the point

    View Slide

  17. Services are not the point

    View Slide

  18. Code is not the point

    View Slide

  19. Code is a liability

    View Slide

  20. View Slide

  21. AWS Lambda?

    View Slide

  22. Example: Favorite Service

    View Slide

  23. View Slide

  24. View Slide

  25. ● First invocation
    ● After deployment or configuration change
    ● Instances killed due to age
    ● Scaling out and existing instances busy
    Cold start frequency

    View Slide

  26. The Burning Monk - I’m afraid you’re thinking about AWS Lambda cold starts all wrong

    View Slide

  27. The Burning Monk - I’m afraid you’re thinking about AWS Lambda cold starts all wrong

    View Slide

  28. The Burning Monk - I’m afraid you’re thinking about AWS Lambda cold starts all wrong

    View Slide

  29. The Burning Monk - I’m afraid you’re thinking about AWS Lambda cold starts all wrong

    View Slide

  30. ● NO: Most likely not when using Node.js, Go, Python, …
    ● MAYBE: Java (JVM) / .NET
    Are cold starts a big deal?
    * When used and optimized correctly

    View Slide

  31. ● NO: Asynchronous architectures
    - Event-Driven architectures are a best practise
    ● NO: Batch processing
    ● NO: User facing service with normal traffic patterns*
    - No problem for 99th percentile
    ● MAYBE: User facing service with occasional traffic*
    ● MAYBE: User facing service with lots of spread spiky traffic*
    Are cold starts a big deal? (Java/.NET edition)
    * When used and optimized correctly

    View Slide

  32. ● Keep function single purposed*
    ● Minimize dependencies
    - webpack, serverless-optimizer-plugin, …
    ● Use lightweight alternatives
    - Spring vs Dagger, Apache HTTP vs HttpUrlConnection
    ● Prefer low overhead runtime (Go, node.js, Python)
    - Consider GraalVM
    - … possibly consider Provisioned Concurrency
    Minimize bootstrap

    View Slide

  33. ● Initialize as much as you can during startup
    - Static fields, constructor
    ● Move state to global
    - But keep your invocations stateless
    ● Avoid reflection
    ● Fail fast
    ● Right size memory usage
    - 1792 MB = 1 vCPU
    Optimize execution time

    View Slide

  34. ● AWS re:Invent 2019: [REPEAT 1] Best practices for AWS Lambda and Java
    (SVS403-R1)
    @sapessi
    ... more on AWS Lambda and Java
    ● How to minimize AWS Lambda Java cold starts
    @drissamri88
    ● Programming AWS Lambda by John Chapin, Mike Roberts
    ● Analyzing Cold Start latency of AWS Lambda
    @mikebroberts

    View Slide

  35. View Slide

  36. Infrastructure-as-code

    View Slide

  37. Infrastructure-as-code
    AWS
    ● Serverless Framework
    ● Terraform
    ● Pulumi
    ● CloudFormation
    ● Serverless Application Model (SAM)
    ● Cloud Development Kit (CDK)
    3th party

    View Slide

  38. Serverless Framework
    ● Most widely used Serverless toolkit
    ● Released in 2015
    ● Simple Developer Experience
    ● Focus on Functions, not Cloud Infrastructure
    ● Cloud-agnostic
    - AWS provider:
    - Compiles to CloudFormation
    - deployed as CloudFormation Stack

    View Slide

  39. Serverless Framework

    View Slide

  40. View Slide

  41. AWS SAM
    ● Official AWS deployment framework
    ● Released in 2016
    ● Built on top of CloudFormation
    - Deployed as CloudFormation Stack

    View Slide

  42. AWS SAM

    View Slide

  43. AWS SAM CLI
    sam init --runtime java11
    sam package \
    --output-template-file packaged.yaml \
    --s3-bucket bucketname
    sam deploy \
    --template-file packaged.yaml \
    --stack-name sam-app \
    --capabilities CAPABILITY_IAM \
    --region eu-west-1
    aws cloudformation delete-stack --stack-name sam-app

    View Slide

  44. Cost control

    View Slide

  45. https://theburningmonk.com/2019/01/you-are-thinking-about-serverless-costs-all-wrong/
    “You are thinking about serverless costs all wrong” - @theburningmonk

    View Slide

  46. https://forrestbrazeal.com/2020/01/05/code-wise-cloud-foolish-avoiding-bad-technology-choices/
    “Code-wise, cloud-foolish: avoiding bad technology choices” - @forrestbrazeal

    View Slide

  47. Determining the Total Cost of Ownership of Serverless Technologies when compared to Traditional Cloud

    View Slide

  48. Resources
    ServerlessDays Belgium
    - Meetup Edition #1 YouTube
    - Join the meetup
    Presentations
    - Serverless - Lessons Learned - Nike Brown Bag

    View Slide