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

Getting started w/ Serverless @ AWS UG

Driss Amri
April 02, 2022
12

Getting started w/ Serverless @ AWS UG

Driss Amri

April 02, 2022
Tweet

Transcript

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

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

    Load testing Changing requirements Procurement new software Security testing Customer
  3. AWS

  4. • First invocation • After deployment or configuration change •

    Instances killed due to age • Scaling out and existing instances busy Cold start frequency
  5. • 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
  6. • 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
  7. • 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
  8. • 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
  9. • 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
  10. Infrastructure-as-code AWS • Serverless Framework • Terraform • Pulumi •

    CloudFormation • Serverless Application Model (SAM) • Cloud Development Kit (CDK) 3th party
  11. 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
  12. AWS SAM • Official AWS deployment framework • Released in

    2016 • Built on top of CloudFormation - Deployed as CloudFormation Stack
  13. 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
  14. Resources ServerlessDays Belgium - Meetup Edition #1 YouTube - Join

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