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

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

sebastianhesse

April 08, 2019
Tweet

More Decks by sebastianhesse

Other Decks in Programming

Transcript

  1. Going Serverless Sebastian Hesse · K15t · @seeebiii Tips &

    tricks for developing a serverless cloud app
  2. Work on the same issue data, in different projects, on

    different Jira instances. Keeping your data in sync Backbone Issue Sync for Jira
  3. Local Execute, test and debug your code on your local

    machine. Cloud Upload your code to the cloud and execute it there. Development
  4. Local Cloud - Serverless Framework - Serverless Application Model (SAM)

    with
 SAM CLI - LocalStack - AWS Cloud9 - Upload & execute - No debugging possible* * bit.ly/debugging-lambda-dotnet
  5. 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
  6. 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
  7. 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}}" } ]
  8. 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
  9. Response Times Response Time in ms 0 250 500 750

    1000 # Request 1 2 3 4 5 Cold Start Function is "warm"
  10. Response Times Response Time in ms 0 250 500 750

    1000 # Request 1 2 3 4 5 Cold Start Function is "warm"
  11. Response Times Response Time in ms 0 250 500 750

    1000 # Request 1 2 3 4 5 Cold Start is always there!
  12. 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
  13. - Retrieve data: 350 ms - Process data: 300 ms

    - Update data: 350 ms Example: Synchronize 1000 Issues 1 sec / issue => ~16 min.
  14. 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
  15. Outsource Move bigger workloads to EC2 or other services. Best

    Practices Recursion Before timing out, store current state and call yourself again.
  16. 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.
  17. 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 } } }
  18. 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
  19. Examples - Shut down resources in your developer stacks -

    Clean up Lambda log groups - Analyze logs for keywords
  20. 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