How to calculate cost of SQS queue when consumed by a batched Lambda?

0

I need to estimate the cost of an SQS queue but I couldn't find documentation on how many SQS API requests are made by the Lambda for each invocation.

Assuming Lambda batch size is set to 300, how many receive, delete (and other?) SQS actions will be executed during one invocation assuming a successful processing?

Based on the permissions the Lambda requires, it seems like messages deleted one by one as it doesn't need permission for the DeleteMessageBatch action. This seems quite wasteful. As for receiving messages there is no separate batch action, it's difficult to say how many requests could be used in that case.

2개 답변
1
수락된 답변

It is a little difficult to predict, but I can provide some information. The Lambda service starts with 5 pollers reading from the queue using Long Polling. Each such API call can wait up to 20 seconds. This means that an empty queue will cost you: 5 pollers * 3 API calls/min * 60 minutes/hour * 24 hours/day * 30 days/month * $0.40/1,000,000 req = $0.259/month.

On top of that you will need to add the actual processing of messages. If you do not use batch, for each message you will probably get another Read request and Delete request. If the load on the queue is high, we increase the number of pollers, up to 1250.

profile pictureAWS
전문가
Uri
답변함 6달 전
profile picture
전문가
검토됨 한 달 전
  • Can you confirm that AWS deletes messages one by one even in case of batching?

  • I do not have a definite answer, but I am pretty sure that we use Delete Batch (when you use a batch of messages of course).

  • The reason I slightly doubt that is that the Lambda doesn't require permission to the DeleteMessageBatch operation. Wouldn't that be necessary?

  • If you check the list of IAM actions for SQS, you will see that there is no Batch action. Not for Delete and not for Receive.

  • Ah you're right, I was just looking at SDK methods, not the actual actions. In that case it's a fair assumption that messages are deleted in batches. Thank you for all your help!

0
  • Although, the blog post provides a nice summary for Lambda, it doesn't cover SQS cost as described in the post itself: "The costs for the polling and dequeue operations using SQS APIs are not included as part of the estimations. The internal SQS dequeue portion is outside the control of the Lambda developer and the cost estimates only cover the message processing using Lambda."

    The SQS cost part is the one I'm interested in.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인