Search code examples
amazon-web-servicesaws-lambdaamazon-cloudwatchsystem-design

How to manage burst of AWS Cloud Watch events triggering an AWS Lambda function


I have a service which generates a burst of Cloud Watch Events once every hour. These Cloud Watch events (which could be in thousands) each will trigger an AWS Lambda function and ultimately number of concurrent lambdas running can cross the maximum limit. How can I modify my system such that these cloud watch events will be handled gracefully by Lambda functions or if possible somehow I can distribute all these cloud watch events over the rest period of the first service.

P.S. I do not want to modify the limit on concurrent running lambdas.


Solution

  • have you thought about adding these events to SQS instead of consuming Lambda directly and then configure the SQS to call the Lambda function?

    This is how you can trigger a Lambda function by SQS queue

    https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-lambda-function-trigger.html

    and you can define the delay in queue consumption by using this article

    https://cloudaffaire.com/how-to-configure-delay-queue-in-sqs/