Resolving Lambda SQS Queue Visibility Timeout Errors
Overview
When Arpio replicates a Lambda function that uses an Amazon SQS queue as an event source, AWS requires that the queue’s visibility timeout be at least as long as the Lambda function’s configured timeout. If this requirement is not met in the recovery environment, Arpio will surface a Client Error Issue during recovery point creation. This document explains the root cause of this error and provides step-by-step guidance for resolving it in your primary AWS environment so that subsequent Arpio recovery points succeed cleanly.
Identifying the Error
This issue appears as a Client Error Issue on the affected Lambda function resource within your Arpio application. The error message will read:
|
Client Error Issue: An error occurred during a call to CreateEventSourceMapping Detailed message: Queue visibility timeout: <X> seconds is less than Function timeout: <Y> seconds |
Quick Fix
- In the Arpio console, note the Queue visibility timeout and Function timeout values from the error message.
- Open the Amazon SQS console in your primary AWS environment and select the affected queue.
- Choose Edit and increase the Visibility timeout to at least 6x the Lambda function’s timeout (e.g., if the function timeout is 900s, set the visibility timeout to 5,400s).
- Choose Save.
- Wait for Arpio to create a new recovery point and confirm the error has cleared.
|
✅ Tip: Alternatively, if the Lambda function’s timeout is higher than needed, you can reduce the function timeout instead. Both approaches resolve the mismatch. |
Detailed Explanation
When a Lambda function is triggered by an SQS queue, AWS creates an event source mapping that connects the two resources. AWS enforces a requirement that the SQS queue’s visibility timeout must be greater than or equal to the Lambda function’s execution timeout. AWS recommends setting the visibility timeout to at least six times the function timeout to allow for retries during throttling.
This validation is performed at the time the event source mapping is created. During an Arpio recovery or test, Lambda functions and SQS queues are both replicated into the recovery environment. When Arpio attempts to recreate the event source mapping between the replicated Lambda function and the replicated SQS queue, AWS will reject the request if the visibility timeout constraint is not satisfied.
|
ℹ️ Note: This error originates from your primary environment’s configuration. The most common cause is that the SQS queue’s visibility timeout was originally set to match or exceed the function timeout, but one of the two values was later changed independently without updating the other. |
Resolution Steps
To resolve this error, you must update the SQS queue’s visibility timeout in your primary AWS environment so that it meets or exceeds the Lambda function’s configured timeout. Once corrected, Arpio will replicate the updated configuration on the next recovery point and the event source mapping will be created successfully.
Step 1: Identify the Affected Resources
In the Arpio console, locate the Lambda function showing the Client Error Issue. The error message includes the current values for both timeouts:
- Queue visibility timeout — the current visibility timeout configured on the SQS queue (in seconds).
- Function timeout — the execution timeout configured on the Lambda function (in seconds).
For example, if the message reads Queue visibility timeout: 300 seconds is less than Function timeout: 900 seconds, this tells you the SQS queue has a 300-second (5-minute) visibility timeout, but the Lambda function is configured with a 900-second (15-minute) timeout.
Step 2: Update the SQS Queue Visibility Timeout
Navigate to the SQS queue in the AWS Management Console in your primary environment and increase its visibility timeout:
- Open the Amazon SQS console and select the queue that is referenced as the event source for the affected Lambda function.
- Choose Edit.
- Under Configuration, locate the Visibility timeout setting.
- Set the visibility timeout to a value that is at least six times the Lambda function’s timeout. For example, if your Lambda function timeout is 900 seconds, set the queue visibility timeout to at least 5,400 seconds.
- Choose Save.
Alternatively, if the Lambda function’s timeout is set higher than necessary for its workload, you may choose to reduce the function timeout instead of increasing the queue’s visibility timeout. Navigate to the Lambda function’s General configuration in the AWS console and lower the Timeout value so it no longer exceeds the queue’s visibility timeout.
Recommended Visibility Timeout Values
AWS recommends setting the SQS queue visibility timeout to at least six times the Lambda function timeout. The table below provides common examples:
|
Lambda Timeout |
Minimum Visibility Timeout |
Recommended (6x) |
|
60 seconds (1 min) |
60 seconds |
360 seconds (6 min) |
|
120 seconds (2 min) |
120 seconds |
720 seconds (12 min) |
|
300 seconds (5 min) |
300 seconds |
1,800 seconds (30 min) |
|
900 seconds (15 min) |
900 seconds |
5,400 seconds (90 min) |
Step 3: Verify in Arpio
After updating the configuration in your primary environment:
- Wait for Arpio to create a new recovery point. Arpio will pick up the updated SQS queue configuration during its next replication cycle.
- Once the new recovery point completes, confirm that the Client Error Issue on the Lambda function has been resolved.
- Optionally, run a recovery test to verify that the event source mapping is created successfully in the recovery environment.
Additional References
For more information on how AWS Lambda and Amazon SQS interact, and the specific requirements around queue configuration for Lambda triggers, refer to the following AWS documentation:
- Creating and configuring an Amazon SQS event source mapping — AWS Lambda Developer Guide
For more details on how Arpio replicates SQS and Lambda resources, refer to the Arpio documentation:
- Amazon Simple Queue Service (Amazon SQS) — Arpio AWS Resource Reference