Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Microservices patterns in Serverless

141 views

Published on

For a lot of people serverless = lambda! That's a good start, compute is where everything started for the cloud. But serverless goes beyond just using a bunch of Lambdas in the backend. I & my friend Adithya used to get frustrated at answering repetitive questions from other friends challenging serverless. So we thought, instead of talking about low hanging fruits which can be done in serverless, let's challenge ourselves into trying to implement what 'we think' would be hard to do on serverless.

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

Microservices patterns in Serverless

  1. 1. Refactoring to Serverless Translating common application architecture patterns to serverless on AWS Adithya Reddy & Prashanth HN
  2. 2. Adithya Reddy Who Are We? @TheTallpants github.com/tallpants SDE, Branch Insurance Prashanth HN @prashanth github.com/hnprashanth CTO, WheelsBox
  3. 3. Source: AWS
  4. 4. • External / Centralized Configuration • Circuit Breakers & Retries • Real time / web-sockets • Asynchronous background tasks Just Another Serverless talk? Hell No!
  5. 5. Circuit Breakers & Retries
  6. 6. What’s a Circuit Breaker? Circuit breaker is a design pattern used in modern software development. It is used to detect failures and encapsulates the logic of preventing a failure from constantly recurring, during maintenance, temporary external system failure or unexpected system difficulties
  7. 7. Circuit Breakers • Allow systems to "open" the circuit when constant failures happen repeatedly giving immediate failure responses instead of loading the system. It can later try "half open" and see if the system is functioning fine now and "close" in case things are back to normal, making it self-healing. • Allow us to contain failures and stop them from creating a cascading effect of other parts.
  8. 8. Circuit Breaker Using Lambda Source: https://www.jeremydaly.com/serverless-microservice-patterns-for-aws/
  9. 9. Circuit Breaker Using Step Functions Source: https://tech.trivago.com/2019/04/09/circuit-breaker-with-aws-step-functions/
  10. 10. External / Centralized Configuration
  11. 11. Configuration is immutable for each published version 1. 2.
  12. 12. Config Servers
  13. 13. Source: gocd.org
  14. 14. • Refresh config values while your app is still running. • Your app can choose when to refetch configuration • Per request • Time-based refetch • Etc.
  15. 15. SSM Parameter Store
  16. 16. • Secure hierarchical storage for configuration and secrets • Store as plain text / KMS encrypted strings • Reference by unique name • Version history, access control at key / hierarchy level • Configurable on-change triggers via CloudWatch Events • CloudWatch + CloudTrail • Reference-able asTerraform data source (and CloudFormation – but only specific versions of keys) • Generous free limits (1000TPS free, $0.05 per 10,000TPS)
  17. 17. Hierarchical configuration
  18. 18. Access Control Standard ABAC /Tag based
  19. 19. github.com/tallpants/ssm-parameter-store Safer, nicer abstraction over SSM parameter store with built-in caching, idempotent preloading, TypeScript compile time checks, and handy autocompletion
  20. 20. Asynchronous BackgroundTasks
  21. 21. Limitations of Lambda • Resource limitations of Lambda: storage etc • Lambdas will timeout after 15 minutes • Limitations in tech stack & stack customisation
  22. 22. Amazon ECS
  23. 23. AWS Fargate
  24. 24. Example Architecture – Resize image to multiple sizes
  25. 25. Advantages • SQS can be integrated with almost any kind of service allowing wide set of triggers • Auto-scale without hassle • No infrastructure to manage • Per second billing (min 1 minute) for the resources used, vCPU & memory • Easy to handle failures and retries
  26. 26. RealTime / Web- Sockets
  27. 27. Source: AWS
  28. 28. API Gateway Websocket Endpoint URL wss://… connectionId connectionId
  29. 29. API Gateway Websocket Endpoint URL 4. Body sent to client 3. HTTP POST to /connectionId 2. Get active connectionIds 1. Score update event wss://…
  30. 30. Questions?
  31. 31. Adithya Reddy Who Are We? @TheTallpants github.com/tallpants SDE, Branch Insurance Prashanth HN @prashanth github.com/hnprashanth CTO, WheelsBox

×