Going Serverless on AWS - Jannis Schaefer, Cosee

6e3ea86995d93d35c0fadf2694bca773?s=47 GoDays
January 30, 2019

Going Serverless on AWS - Jannis Schaefer, Cosee

Going Serverless on AWS. A journey through AWS’ serverless world - Jannis Schaefer, Cosee

6e3ea86995d93d35c0fadf2694bca773?s=128

GoDays

January 30, 2019
Tweet

Transcript

  1. Going serverless on AWS A journey through AWS’ serverless world

  2. None
  3. Cloud Backend Mobile Frontend DevOps Agile Marketing Design Team cosee

  4. Going serverless on AWS Chapter 0: Serverless prologue

  5. serverless TL;DR Just me, my code and I

  6. serverless TL;DR Just me, my code and I no more

    http.Serve(), deployment,
 credit card bills, code changes, YAML,
 AWS knowledge, fun with handling state…
  7. serverless TL;DR ! Don’t need to manage servers Scales with

    usage / credit card Only costs when being used Availability and fault tolerance by design
  8. Heard of FaaS? • Function as a Service • Short

    running piece of customer owned code • Pay per use (RAM+CPU) * ms Used as glue between other Managed Services & www Hi, I am AWS Lambda!
  9. Confused? Hi, I am AWS Lambda! ¡Hola, soy AWS Glue!

  10. https://twitter.com/yogthos/status/1083226362993872897 λ in a nutshell Function triggers on Event Event

    can either be HTTP Request or from other AWS Services Lambda is executed in a sandbox
  11. Warm-up functions? Starting a new Lambda Runner creates a new

    Instance One Instance handles one request at a time Instances keep warm for about 5 - 10 Minutes with no traffic Startup ~200ms overhead
  12. Warm-up functions? https://medium.com/@zaccharles/what-happens-to-running-threads-when-a-lambda-finishes-executing-312a6f5757b4

  13. curl http:!//mylambda You HTTPS RPC

  14. curl http:!//mylambda You HTTPS RPC

  15. Hello λ-World! package main import ( "fmt" "github.com/aws/aws-lambda-go/events" "github.com/aws/aws-lambda-go/lambda" )

    func main() { lambda.Start(Handler) } func Handler(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { return events.APIGatewayProxyResponse{ Body: fmt.Sprintf("Hello, %v", request.QueryStringParameters["name"]), StatusCode: 200, }, nil }
  16. package main import ( "fmt" "github.com/aws/aws-lambda-go/events" "github.com/aws/aws-lambda-go/lambda" ) func main()

    { lambda.Start(Handler) } func Handler(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { return events.APIGatewayProxyResponse{ Body: fmt.Sprintf("Hello, %v", request.QueryStringParameters["name"]), StatusCode: 200, }, nil }
  17. API Gateway • Entrypoint to Serverless Applications • Proxies HTTP

    Paths to Lambdas and other AWS Services • Terminates SSL • Helps handling auth • Provides documentation for APIs • Logging, Monitoring, Caching
  18. serverless Framework • Open Source Framework • Now officially backed

    by AWS • No CloudFormation • Supports other platforms as well • Takes care of nasty deployment things
  19. AWS SAM https://github.com/awslabs/serverless-application-model

  20. Going serverless on AWS Chapter 1: Introducing Pete Pete

  21. Introducing Pete • Pete likes to take photos • Wants

    to add filters to them so they look uber fancy • Wants to run it for cheap in the cloud Pete
  22. Demo

  23. Chapter 2: Building a Platform Going serverless on AWS Investor

    Still Pete
  24. λ DB S3 MQ Public Services Internal Services λ λ

  25. S3, a Cloud Native Dropbox • Amazon S3 - Simple

    Storage Service • Can save PBs of files in a single AWS Region • No direct File System Access • S3 FileTransfer Protocol also used by Google Cloud, Minio etc.
  26. Serverless Aurora • Part of AWS RDS • Behaves just

    like normal MySQL Server • Schedules workers on demand • Scale down to Zero • DB connections can keep open
  27. DynamoDB - NoSQL at scale • REST like Database Interface

    • Document Storage with Global Replication • Sometimes tricky indexing
 
 • Storage for product inforation at amazon.com
  28. Queues and notifications Simple Queue Service • Trigger Lambdas with

    1-10 Messages • Lambda ACKs successful processed msg
 Simple Notification Service • Message gets delivered to different subscribers • No monitoring of successful execution
  29. Chapter 3: What’s next? Going serverless on AWS Still Pete

  30. package main import ( ##... ) var db *sql.DB func

    main() { conn, _ #:= db.Conn(…) lambda.Start(Handler) } func Handler(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { return ##... } Optimize Lambdas
  31. λ Layers • Provide Docker like Read-Only layers • Up

    to 250 MB of additional usable storage • Keeps deployment package small • Also used to provide new runtimes Your code Some libraries Cobol runtime?
  32. Chapter 4: Takeaways Going serverless on AWS

  33. Chapter 4: You. Going serverless on AWS DEAL WITH IT

  34. Try out serverless! • Download AWS SAM / Serverless Framework

    CLI • Most important Tools have free tier • Or just paste code inside AWS Lambda Console
  35. No AWS account? • Nearly every mayor Cloud Provider has

    FaaS solution • Most with free Trial Credits / free-tier • OpenFaaS runs anywhere* and anything • Many serverless platforms based on docker available * on Kubernetes & Docker Swarm including RaspberryPi
  36. Jannis Schaefer | cosee GmbH jannis.schaefer@cosee.biz | @jannisschaefer > blog.cosee.biz

    > jobs.cosee.biz > cosee.biz github.com/ashleymcnamara/gophers Me