由SQS触发的AWS Lambda会增加SQS请求数量 [英] AWS Lambda Triggered by SQS increases SQS request count

查看:85
本文介绍了由SQS触发的AWS Lambda会增加SQS请求数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由SQS触发的AWS Lambda函数.每天大约触发100次此功能,但是每天向SQS队列发出的请求计数大约为20.000次.我不明白为什么对SQS提出的请求数量太多.我的期望是,对SQS的请求数量应与Lambda调用相同.

I have a AWS Lambda function which is triggered by SQS. This function is triggered approximately 100 times daily, but request count to the SQS queue is approximately 20.000 times daily. I don't understand why the number of requests made to the SQS is too high. My expectation is that the number of requests made to the SQS should be same with the Lambda invocation.

我的帐户中只有一个Lambda函数和一个SQS队列.

I have only one Lambda function and one SQS queue in my account.

可以与SQS队列的轮询相关吗?我试图从队列配置中更改SQS的轮询间隔,但未进行任何更改.另一种可能性是从Lambda函数配置更改轮询间隔.但是,我找不到任何相关参数.

Can be related with polling of SQS queue? I tried to change the polling interval of SQS from the queue configuration but nothing changed. Another possibility is to change polling interval from Lambda function configuration. However, I cannot find any related parameter.

简而言之,我想减少SQS请求的数量,同时使用SQS调用Lmabda函数时该怎么做?

Briefy, I want to reduce number of SQS request, how can i do that while invoking Lmabda function with SQS?

推荐答案

将SQS用作AWS Lambda的事件源时,AWS Lambda会定期轮询已配置的SQS队列以获取新消息.尽管官方文档对此并不十分清楚,但

When using SQS as an event source for AWS Lambda, AWS Lambda regularly polls the configured SQS queue to fetch new messages. While the official documentation isn't clear really about that, the blog post announcing that feature goes into the details:

最初创建并启用SQS事件源映射时,或者在一段时间没有通信后首次出现消息时,Lambda服务将开始使用五个并行的长轮询连接来轮询SQS队列.

When an SQS event source mapping is initially created and enabled, or when messages first appear after a period with no traffic, then the Lambda service will begin polling the SQS queue using five parallel long-polling connections.

根据 AWS文档,从AWS Lambda到SQS的长时间轮询的默认持续时间为20秒.

According to the AWS documentation, the default duration for a long poll from AWS Lambda to SQS is 20 seconds.

这会导致AWS Lambda函数每20秒向SQS发出五次请求,而没有明显的负载,每天总计约为21600,接近您遇到的20000.

That results in five requests to SQS every 20 seconds for AWS Lambda functions without significant load, which sums up to the ~21600 per day, which is close to the 20000 you're experiencing.

虽然增加长轮询持续时间似乎是减少请求数量的一种简便方法,但这是不可能的,因为默认情况下,AWS Lambda使用的20秒已经是

While increasing the long poll duration seems like an easy way to decrease the number of requests, that's not possible, as the 20 seconds AWS Lambda is using by default is already the maximum possible duration for an SQS queue. I'm afraid there is no easy way to decrease the requests to SQS, when using it as event source for AWS Lambda. Instead depending it could be worth evaluating if another event source, like SNS, would fit your use case as well.

这篇关于由SQS触发的AWS Lambda会增加SQS请求数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆