Harnessing the Cloud: Next-Level Serverless Patterns for Rapid Innovation
The Storage-First pattern is a design approach where the incoming requests or data are captured and stored using AWS-managed services. This pattern is ideal when no data needs to be returned from the API and helps to ensure that data is not lost in case of processing failures. For example, using Amazon API Gateway, incoming requests can be stored in Amazon S3, with the API implementation handling any losses using the Storage-First approach. The incoming request and data are stored in Amazon SQS using a service integration in API Gateway. This ensures the request is secure and can be processed later, even if the Lambda functions fail.
The Circuit Breaker pattern is used in distributed systems to fail fast if a downstream service becomes unavailable. This can be done by checking the circuit status from DynamoDB via a getItem call and then checking if the circuit is open or closed. If the course is available and the last update was over X seconds ago, the work is carried out to see if the service has healed. If the job fails after retries, the status of the circuit is updated to OPEN, leading to consecutive invocations falling fast. If the work is successful, the course is updated to CLOSED. Combining the Circuit Breaker with a health check can achieve an automatic circuit breaker. The health check result is sent to Amazon EventBridge, which invokes a StepFunction to open or close the circuit based on the health check.
Combining the Storage-First and Circuit Breaker patterns can be considered a “super pattern.” By storing the requests first, they can be processed later when the circuit is closed, and while the course is open, processing power is saved, and the recommendations remain in storage without any risk of loss.
Feature flags can also play an essential role in serverless architecture by allowing the control of new features and functionality. By flagging everything constantly, new features can be turned on or off without any impact on the existing system, making testing and deploying new functionality more accessible. This approach also helps to reduce risk by allowing features to be gradually rolled out and monitored without affecting the entire system.
The article is “Serverless Patterns.“