スキップしてコンテンツを表示

Question on SQS Behavior added as Trigger to Lambda

0

Hello AWS Team, We have a cloudwatch alarm breach on an SQS queue for "NumberOfEmptyReceives" metric greater than the threshold limit which was set to 10. We have 3 SQS queues added as triggers to the lambda, so if i receive a message from upstream system in one of those three SQS queues, and when the lambda is invoked does the lambda also try to poll from other two queues added as triggers to check if there are messages available and hence causing the alarm breach for the those other 2 queues as there are no messages published yet from upstream systems ?

1回答
0

When you have multiple SQS queues added as triggers to a Lambda function, the behavior you're describing doesn't occur. Each SQS queue trigger operates independently, and Lambda doesn't automatically poll other queues when it's invoked by one specific queue.

Here's how it works:

  1. When a message arrives in one of your SQS queues, it triggers the associated Lambda function for that specific queue.

  2. Lambda processes the messages from the queue that triggered it, but it doesn't automatically check or poll the other queues that are set up as triggers.

  3. Each SQS queue trigger has its own event source mapping, which is responsible for polling its specific queue and invoking the Lambda function when messages are available.

The "NumberOfEmptyReceives" metric indicates the number of ReceiveMessage API calls that did not return any messages. This metric increasing doesn't necessarily mean your Lambda function is polling empty queues. Instead, it could indicate that:

  1. The SQS service itself is polling the queue but not finding messages.
  2. There might be other consumers of the queue besides your Lambda function.
  3. The Lambda service is scaling down and checking for messages less frequently when the queue is empty for a while.

To troubleshoot the alarm breach:

  1. Check if there are other consumers of the queue besides your Lambda function.
  2. Review your Lambda function's concurrency settings and scaling behavior.
  3. Examine the message processing patterns and ensure messages aren't being deleted before they can be processed.
  4. Consider adjusting your alarm threshold if the current setting is too sensitive for your use case.

Remember, Lambda's behavior with SQS is designed to be efficient, only invoking the function when there are actual messages to process. The alarm breach you're seeing is likely not caused by Lambda unnecessarily polling empty queues.
Sources
Using Lambda with Amazon SQS - AWS Lambda
Understanding SQS retries - AWS Lambda
Simple Queue Service (SQS) - Incident Detection and Response Alarming Best Practices | AWS re:Post

回答済み 1年前
エキスパート
レビュー済み 1年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

関連するコンテンツ