Amazon EventBridge to AWS Lambda with feedback control by Amazon CloudWatch Alarms

AWS Lambda → Amazon EventBridge → AWS Lambda

Create a closed-Loop (feedback) control mechanism for throttle-handling of 3rd party calls on AWS Lambda with Amazon CloudWatch Alarms and Amazon EventBridge

This sample project demonstrates an ON/OFF control implementation on AWS Lambda with a closed-loop (feedback) control mechanism. This is useful when your application is dependent on third-party calls and you need to handle any throttling or a performance issue on the third-party service.
Using the feedback control mechanism, AWS Lambda performs the third-party call and uses Amazon CloudWatch custom metrics feature to store call metrics like response time and status code. This pattern deploys two AWS Lambda functions, one Amazon EventBridge rule, two Amazon CloudWatch alarms and one Amazon CloudWatch composite alarm.
A set of CloudWatch Alarms monitors these custom metrics produced after the third-party call and decides if the third-party service call is healty. If not, the event planner Lambda function stops feeding messages to EventBridge to drop third-party calls temporarly to avoid additional load on the third-party service. It also brings cost benefits and concurrency savings on AWS Lambda by avoiding the lambda invocations for the unhealthy 3rd party service.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/cdk-closed-loop-serverless-control

Deploy

cdk deploy


Testing

See README.md file in the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: cdk destroy.

Created by:

Emir Ayar

Emir Ayar

Emir Ayar is a Tech Lead Solutions Architect on the AWS Prototyping Team to help customers build IoT, Edge AI, and Industry 4.0 solutions and implement architectural best practices.