Register Now


Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Add question

You must login to ask a question.


Register Now

Lorem ipsum dolor sit amet, consectetur adipiscing elit.Morbi adipiscing gravdio, sit amet suscipit risus ultrices eu.Fusce viverra neque at purus laoreet consequa.Vivamus vulputate posuere nisl quis consequat.

What happens if Lambda is unable to process a message from SQS before the visibility timeout expires?

What happens if a Lambda function fails to process an SQS message before the visibility timeout

When an SQS message is received by a Lambda function, the message’s visibility timeout starts. This means the message is invisible to other consumers for that duration.

However, if the Lambda function fails to process the message before the visibility timeout expires, a few things will happen:

  1. The message will reappear in the SQS queue and become available for other consumers. This is to prevent messages from being lost if a Lambda function fails.
  2. By default, the message will be sent to the dead letter queue (DLQ) if it is not successfully processed within the visibility timeout plus the number of receive attempts specified in the redrive policy. The DLQ allows you to further inspect and handle failed messages.
  3. The Lambda function execution will result in an error, and you can use CloudWatch Logs to troubleshoot the issue. You may need to update your Lambda function code to properly handle the message.
  4. You have the option to extend the visibility timeout of a message from within the Lambda function using the ChangeMessageVisibility API. This can give your Lambda function more time to process the message before it reappears in the queue.
  5. If a message fails processing multiple times, you can either fix the underlying issue or delete the problematic message from the queue/DLQ.

In summary, it is important to set an appropriate visibility timeout for your use case. The timeout should be long enough to allow for normal processing but short enough to detect failures quickly and re-attempt message processing. Extending timeouts on a per-message basis from within the Lambda function can also help optimize throughput.

ALSO READ  top 10 AWS API Gateway interview questions and answers



About Abhay Singh

I'm Abhay Singh, an Architect with 9 Years of It experience. AWS Certified Solutions Architect.

Follow Me

Leave a reply

Table of Contents