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

Ein Jahr serverless - the good, the bad and the ugly

Ein Jahr serverless - the good, the bad and the ugly

Ein Jahr Serverlessentwicklung mit der AWS. Da erlebt man viel Neues was Spaß macht, interessant ist und was einen in den Wahnsinn treibt. Alte Überzeugungen über Architektur und Testautomatisierung greifen plötzlich nicht mehr und es entsteht Komplexität wo man sie nicht erwartet hätte.

Dieser Talk zeigt, wo und wie wir serverless eingesetzt haben, wo die Erwartungen sich erfüllt haben, aber auch wo es nicht so gut lief und serverless nicht die beste Wahl war. Daraus hervorgegangen sind Schwerpunkte und Best Practises über Staging, Testautomatisierung, Architektur und Komplexitätsbewältigung die vorgestellt und gerne diskutiert werden können.

Christian Schmidt

March 17, 2021
Tweet

More Decks by Christian Schmidt

Other Decks in Technology

Transcript

  1. Wer bin ich? Christian Schmidt (35) Softwareentwickler / IT-Consultant Dipl-Inf.

    (FH) - FH Köln Steckenpferde: • JVM / Node / Go • Architekturen • Verteilte Systeme • Domain Driven Design • Cloud-Stuff Seit 2010 bei tarent Solutions in Bonn
  2. Serverless - the good, the bad and the ugly Komplexität

    Technologiewahl Testkonzept Architektur Staging Frustbewältigung. Photo: https://www.kinolorber.com/product/the-good-the-bad-and-the-ugly-50th-anniversary-single-disc-edition-dvd
  3. Architektur - Stacks - CloudFormation AWSTemplateFormatVersion : '2010-09-09' Transform :

    'AWS::Serverless-2016-10-31' Parameters : loglevel : Type: String Stage: Type: String Resources : PutHandler : Type: 'AWS::Serverless::Function' Properties : CodeUri: / Handler: index.handlePut Runtime: nodejs10.x Role: !GetAtt AwsTechTalkRole.Arn Environment : Variables : LOG_FORMAT : json LOG_LEVEL : !Ref loglevel KEY_STORE_REF : !Ref KeyStore Events: Put: Type: Api Properties : Path: /store/{key} Method: put KeyStore : Type: 'AWS::DynamoDB::Table' Properties : TableName : !Sub "${Stage}-KeyStore" AttributeDefinitions : - AttributeName : 'key' AttributeType : 'S' KeySchema : - AttributeName : 'key'
  4. Architektur - Stacks - Outputs Resources: UpdateTopic: Type: AWS::SNS::Topic ...

    Outputs: UpdateTopicRef : Description: update topic Export: Name: "UpdateTopicRef" Value: !Ref UpdateTopic Parameters: UpdateTopicArn : Type: String ... Resources: UpdateQueue: Type: AWS::SQS::Queue TopicSubscription : Type: 'AWS::SNS::Subscription' Properties: TopicArn: !Ref UpdateTopicArn Endpoint: !GetAtt UpdateQueue.Arn Protocol: sqs RawMessageDelivery : 'true'
  5. Technologiewahl Java • relativ langer cold start > 2s •

    hoher Speicherverbrauch • gute SDK Unterstützung NodeJS • schneller Coldstart • optimiert auf single thread • gute SDK Unterstützung Go • schneller Coldstart • gute SDK Unterstützung • kaum Erfahrung im Team
  6. CI/CD - Staging Transform: 'AWS::Serverless-2016-10-31' Parameters: Stage: Type: String Resources:

    HelloWorld: Type: 'AWS::Serverless::Function' Properties: Runtime: java8 Handler: de.tarent.hrs.HelloWorldHandler::handleRequest CodeUri: ./build/libs/aws-lambda-tryout-1.0-SNAPSHOT-all.jar Tags: Application: HelloWorld Environment: !Ref Stage Name: HelloWorld RepoURL: https://gitlab.tarent.de/dynamo-duisdorf/aws-lambda-tryout TestDynamoDb: Type: 'AWS::Serverless::SimpleTable' TableName: 'dynamoe' PrimaryKey: Name: id Type: String ProvisionedThroughput : ReadCapacityUnits : 5 WriteCapacityUnits : 5 Tags: - Key: "Application" Value: "HelloWorld" - Key: "Environment" Value: !Ref Stage - Key: "Name" Value: "dynamoe"
  7. CI/CD - Staging Transform: 'AWS::Serverless-2016-10-31' Parameters: Stage: Type: String Resources:

    HelloWorld: Type: 'AWS::Serverless::Function' Properties: Runtime: java8 Handler: de.tarent.hrs.HelloWorldHandler::handleRequest CodeUri: ./build/libs/aws-lambda-tryout-1.0-SNAPSHOT-all.jar Tags: Application: HelloWorld Environment: !Ref Stage Name: HelloWorld RepoURL: https://gitlab.tarent.de/dynamo-duisdorf/aws-lambda-tryout TestDynamoDb: Type: 'AWS::Serverless::SimpleTable' TableName: 'dynamoe' PrimaryKey: Name: id Type: String ProvisionedThroughput : ReadCapacityUnits : 5 WriteCapacityUnits : 5 Tags: - Key: "Application" Value: "HelloWorld" - Key: "Environment" Value: !Ref Stage - Key: "Name" Value: "dynamoe" sam build -m package.json -t template.yaml sam package --s3-bucket ${S3_BUCKET} --output-template-file packaged.yaml sam deploy --template-file ./packaged.yaml \ --stack-name ${STAGE}-techtalk \ --capabilities CAPABILITY_IAM \ --parameter-overrides \ Stage=${STAGE} \ ...
  8. CI/CD Checkout Repo / Stack Komponenten- test - ƛ2 Komponenten-

    test - ƛ1 Komponenten- test - ƛ3 Deploy dev-stage systemtest integrationt est Deploy prd-stage integration test
  9. The good Rapid development Fokussierung auf die eigentliche Logik “mal

    eben gemacht” Coding zu Deployment in unter 5min SDK provisioniert zur Laufzeit Sehr gute Dokumentation Live-Editor
  10. The good Rapid development viel out of the box Skalierung,

    Logging, etc. viel Kontrolle en Detail
  11. The ugly Referenzen Die “ARN” identifiziert jedes Element arn:aws:lambda:eu-central-1:XXXXX817YYY:function:aws-techtalk-PutHandler-DQWHPYDYRP2B arn:aws:iam::XXXXX817YYY:role/aws-techtalk-AwsTechTalkRole-EHMCF9COU57L

    arn:aws:dynamodb:eu-central-1:XXXXX817YYY:table/aws-KeyStore KeyStore: Type: 'AWS::DynamoDB::Table' GetHandler: Type: 'AWS::Serverless::Function' Properties: ... Environment: Variables: KEY_STORE_REF: !Ref KeyStore
  12. The ugly Referenzen Cheatsheet: https://theburningmonk.com/cloudformation-ref-and-getatt-cheatsheet/ !Ref gibt immer die ARN

    zurück? → Nein… • !Ref AWS::SQS::Queue → QueueURL • !Ref AWS::SNS::Topic → ARN • !Ref AWS::ApiGateway::RestApi → ID (hat keine ARN) • !GetAtt MyQueueRef.Arn → Arn GetHandler: Type: 'AWS::Serverless::Function' Properties: CodeUri: / Handler: index.handleGet Runtime: nodejs10.x Role: !GetAtt AwsTechTalkRole.Arn Environment: Variables: LOG_FORMAT: json LOG_LEVEL: !Ref loglevel KEY_STORE_REF: !Ref KeyStore
  13. Fazit sehr viel out of the box keine Komplexitätsreduktion! kann

    teuer werden schnelle Entwicklung Domainfokus lohnt sich nicht bei • viel IO • Funktionskaskaden einheitliches Environment
  14. Vielen Dank! tarent solutions GmbH Rochusstraße 2-4 53123 Bonn Telefon:

    0228 54881-0 Telefax: 0228 54881-235 [email protected] www.tarent.de Christian Schmidt Softwareentwickler IT-Consultant [email protected] @chris__schmidt github.com/DarkToast christian-schmidt-9644a91b2