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

Up, up and away - Serverless on AWS

Up, up and away - Serverless on AWS

Intro to AWS & Serverless

4f58cc9aea7be8afbeede693832984c8?s=128

Driss Amri

July 08, 2020
Tweet

Transcript

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

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

    Traveler & Diver
  3. Idea Customer

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

  5. Idea Request Servers Setup VMWares Customer Setup Network Security Functional

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

    Load testing Changing requirements Procurement new software Security testing Customer
  7. Physical Servers Virtual Machines Containers Serverless Code Runtime OS Hardware

  8. “The Cloud”

  9. AWS

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

  11. Code Runtime OS Hardware Container as a Service Containers

  12. Serverless Code/Data Runtime OS Hardware Serverless

  13. None
  14. None
  15. None
  16. Technology is not the point

  17. Services are not the point

  18. Code is not the point

  19. Code is a liability

  20. None
  21. AWS Lambda?

  22. Example: Favorite Service

  23. None
  24. None
  25. • First invocation • After deployment or configuration change •

    Instances killed due to age • Scaling out and existing instances busy Cold start frequency
  26. The Burning Monk - I’m afraid you’re thinking about AWS

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

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

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

    Lambda cold starts all wrong
  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
  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
  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
  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
  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
  35. None
  36. Infrastructure-as-code

  37. Infrastructure-as-code AWS • Serverless Framework • Terraform • Pulumi •

    CloudFormation • Serverless Application Model (SAM) • Cloud Development Kit (CDK) 3th party
  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
  39. Serverless Framework

  40. None
  41. AWS SAM • Official AWS deployment framework • Released in

    2016 • Built on top of CloudFormation - Deployed as CloudFormation Stack
  42. AWS SAM

  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
  44. Cost control

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

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

  47. Determining the Total Cost of Ownership of Serverless Technologies when

    compared to Traditional Cloud
  48. Resources ServerlessDays Belgium - Meetup Edition #1 YouTube - Join

    the meetup Presentations - Serverless - Lessons Learned - Nike Brown Bag