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 Answers
1
Accepted Answer

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
EXPERT
Uri
answered 6 months ago
profile picture
EXPERT
reviewed a month ago
  • 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.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions