Going Serverless: Tips & tricks for developing a serverless cloud app

Going Serverless: Tips & tricks for developing a serverless cloud app

Are you planning to develop a new cloud app? If so, serverless might be the right fit for you!

Serverless makes it possible to write small functions and platform providers like AWS are taking care about the deployment and scalability. However, this new concept comes with its own drawbacks when used in production, e.g. long startup times or scaling limitations.

Hence, we will show you what it takes to run a cloud app using a serverless architecture based on AWS Lambda. We will go beyond the basics to show best practices and explain why serverless might be a good fit for you. You'll learn which setup options you have for your development and deployment environment, how to develop solid serverless functions and where the limits are.

Using these learnings you'll know how you can easily scale your app for a growing number of users and be successful on the marketplace.

Links from the slides:
https://bit.ly/debugging-lambda-dotnet
https://bit.ly/test-lambda-functions
https://bit.ly/aws-appsync-blog
https://bit.ly/lambda-triggers
https://bit.ly/secure-aws-lambda
https://bit.ly/migrating-to-lambda
https://bit.ly/caching-in-lambda

023594dc361cab87c8e40d03ba0f3b18?s=128

sebastianhesse

April 08, 2019
Tweet

Transcript

  1. 1.
  2. 2.

    Going Serverless Sebastian Hesse · K15t · @seeebiii Tips &

    tricks for developing a serverless cloud app
  3. 3.

    Work on the same issue data, in different projects, on

    different Jira instances. Keeping your data in sync Backbone Issue Sync for Jira
  4. 12.

    Local Execute, test and debug your code on your local

    machine. Cloud Upload your code to the cloud and execute it there. Development
  5. 13.

    Local Cloud - Serverless Framework - Serverless Application Model (SAM)

    with
 SAM CLI - LocalStack - AWS Cloud9 - Upload & execute - No debugging possible* * bit.ly/debugging-lambda-dotnet
  6. 14.

    Considerations Tests You should always write tests which can already

    identify bugs. Quick Updates Local code updates are faster. But you can optimize your cloud code updates. Real Environment Local code execution always needs to simplify something: services, access policies or more. bit.ly/test-lambda-functions
  7. 17.

    Infrastructure as Code Use a tool to describe your infrastructure

    as code. This helps you to keep track of all your Lambda functions. CI/CD Pipeline Automate your deployment as much as possible. Use tools like Bitbucket Pipelines, AWS CodePipeline or similar. Deployment
  8. 18.

    Versioning Not all customers update your app at the same

    time. Be prepared! Preprocess your app descriptor. "webhooks": [ { "event": "jira:issue_updated", "url": "/webhook?v={{version}}" } ]
  9. 23.

    Focus Focus on one task and do it well. Reusability

    Reuse functions within your app. Performance Keep a high performance, because every millisecond costs you money. Considerations
  10. 24.

    Response Times Response Time in ms 0 250 500 750

    1000 # Request 1 2 3 4 5 Cold Start Function is "warm"
  11. 25.

    Response Times Response Time in ms 0 250 500 750

    1000 # Request 1 2 3 4 5 Cold Start Function is "warm"
  12. 33.

    Response Times Response Time in ms 0 250 500 750

    1000 # Request 1 2 3 4 5 Cold Start is always there!
  13. 34.

    API Gateway Built resilient APIs backed by Lambda functions. AWS

    AppSync Build your own serverless backend using AWS AppSync which is powered by GraphQL. Serverless REST API bit.ly/aws-appsync-blog
  14. 54.

    - Retrieve data: 350 ms - Process data: 300 ms

    - Update data: 350 ms Example: Synchronize 1000 Issues 1 sec / issue => ~16 min.
  15. 56.

    Lambda Recursion module.exports = function(e, ctx, cb) { while (ctx.getRemainingTimeInMillis()

    > 1000) { // do something } // store state & call yourself again } 1.) Same instance problem 2.) Threshold uncertainty
  16. 57.

    Outsource Move bigger workloads to EC2 or other services. Best

    Practices Recursion Before timing out, store current state and call yourself again.
  17. 59.

    Step Functions Manage the execution workflow and work around the

    time limit. Outsource Move bigger workloads to EC2 or other services. Best Practices Recursion Before timing out, store current state and call yourself again.
  18. 60.

    Step Functions Example { "StartAt": "Wait for Timestamp", "States": {

    "Wait for Timestamp": { "Type": "Wait", "SecondsPath": "$.seconds", "Next": "Send SNS Message" }, "Send SNS Message": { "Type": "Task", "Resource": "$LAMBDA_ARN", "Retry":[...], "End": true } } }
  19. 69.

    Clean Up Clean up data or make sure your data

    is still up-to-date. Log Collection Collect CloudWatch logs and store them somewhere else, e.g. in a file on S3. Monitoring Do health checks of your own services and send alarms to Slack. Maintenance
  20. 70.

    Examples - Shut down resources in your developer stacks -

    Clean up Lambda log groups - Analyze logs for keywords
  21. 74.
  22. 75.

    Focus Keep your functions small. Find a good use case

    for your function. Scale Automatic scalability needs responsibility. Be Flexible Expand your functions as necessary. Takeaways