Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws-lambda-event-sources: SQS receiveMessageWaitTime's default value is incorrect #24795

Closed
sarisia opened this issue Mar 27, 2023 · 6 comments · Fixed by #26882
Closed

aws-lambda-event-sources: SQS receiveMessageWaitTime's default value is incorrect #24795

sarisia opened this issue Mar 27, 2023 · 6 comments · Fixed by #26882
Labels
@aws-cdk/aws-lambda-event-sources @aws-cdk/aws-sqs Related to Amazon Simple Queue Service bug This issue is a bug. documentation This is a problem with documentation. effort/small Small work item – less than a day of effort p2

Comments

@sarisia
Copy link
Contributor

sarisia commented Mar 27, 2023

Describe the issue

Docs for aws-lambda-event-sources says SQS Queue's receiveMessageWaitTime property is default to 20 seconds,
but according to CDK aws-sqs docs and CloudFormation AWS::SQS::Queue docs, it's 0 seconds by default, not 20 seconds.

Links

@sarisia sarisia added documentation This is a problem with documentation. needs-triage This issue or PR still needs to be triaged. labels Mar 27, 2023
@pahud
Copy link
Contributor

pahud commented Mar 27, 2023

Yes this is confusing. But it's unclear to me what the default duration is from the CFN document while according to this document, the default value seems to be 0. Are you interested to create a PR for this?

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Mar 27, 2023
@sarisia
Copy link
Contributor Author

sarisia commented Mar 27, 2023

Are you interested to create a PR for this?

Yeah I'm happy to take care of it!

BTW, I suspect that SQS's receiveMessageWaitTime won't affect the Lambda's internal SQS poller's behaviour. I saw some users pointed out that Lambda's poller ignores receiveMessageWaitTime and always does long-polling:

https://stackoverflow.com/questions/53372107/aws-sqs-long-polling-doesnt-reduce-empty-receives#comment93651661_53379640

WDYT?

@pahud
Copy link
Contributor

pahud commented May 2, 2023

@sarisia

From what I see in the CFN doc

ReceiveMessageWaitTimeSeconds
Specifies the duration, in seconds, that the ReceiveMessage action call waits until a message is in the queue in order to include it in the response, rather than returning an empty response if a message isn't yet available. You can specify an integer from 1 to 20. Short polling is used as the default or when you specify 0 for this property. For more information, see Consuming messages using long polling in the Amazon SQS Developer Guide.

It is unclear to me if the default is 0 but short polling is the default behavior if undefined and the effect is just as setting this value to 0.

In terms of Lambda's internal SQS poller's behavior, we probably need to look up other document but I support to have a PR to update the default from 20 to 0.

@pahud pahud added bug This issue is a bug. effort/small Small work item – less than a day of effort @aws-cdk/aws-sqs Related to Amazon Simple Queue Service response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed effort/medium Medium work item – several days of effort labels May 2, 2023
@github-actions
Copy link

github-actions bot commented May 4, 2023

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 4, 2023
@sarisia
Copy link
Contributor Author

sarisia commented May 4, 2023

I'll submit a PR later, thanks!

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels May 4, 2023
@mergify mergify bot closed this as completed in #26882 Aug 25, 2023
mergify bot pushed a commit that referenced this issue Aug 25, 2023
…ceiveMessageWaitTime (#26882)

Currently, the document for aws_lambda_event_sources module includes the following description.
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda_event_sources-readme.html#sqs
> receiveMessageWaitTime: Will determine long poll duration. The default value is 20 seconds.

However, from SQS perspective, the default value is 0. So, the above description is incorrect.
https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SetQueueAttributes.html
> ReceiveMessageWaitTimeSeconds – The length of time, in seconds, for which a ReceiveMessage action waits for a message to arrive. Valid values: An integer from 0 to 20 (seconds). Default: 0.

Also, when we use SQS queue as Lambda's source, Lambda uses long polling regardless of the queue's ReceiveMessageWaitTimeSeconds setting. 
https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#events-sqs-scaling
> For standard queues, Lambda uses long polling to poll a queue until it becomes active.

So, in this context, `receiveMessageWaitTime` prop for Queue construct does not affect the behavior of Lambda EventSource. To avoid confusion, this PR remove the description regarding `receiveMessageWaitTime` from document.

Closes #24795

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda-event-sources @aws-cdk/aws-sqs Related to Amazon Simple Queue Service bug This issue is a bug. documentation This is a problem with documentation. effort/small Small work item – less than a day of effort p2
Projects
None yet
2 participants