10

AWS allows a Lambda function to be triggered by an SQS queue. With respect to the documentation, Lambda polls the queue and invokes the function synchronously with a batch of messages.

AWS takes the execution time into account while charging for a Lambda function. Does the polling time counted as the execution time and be charged? Or is it free?

1 Answer 1

22

It is not counted as the lambda execution time but it is not free either.

When there is no data to be pulled from your SQS queue, your lambda function is not executed, therefore there is no cost associated with lambda execution time.

But when lambda service polls SQS queue, it is a normal SQS API request and it is charged based on the SQS pricing. No matter how the SQS API request is made, whether manually via CLI, programatically via SDK or automatically via lambda service, it will be charged.

For example, you pay $0.0000004 per SQS API request (Standard queue) in US East region (or $0.40 per one million requests) and $0.0000005 per request (FIFO queue).

3
  • Hi Matus. Lambda uses long polling to get messages from the SQS queue. Suppose that Lambda started long polling and the first message arrived after 10 minutes. During this period, AWS will charge only 1 SQS request. Is this correct? Thanks :)
    – ovunccetin
    Dec 23, 2019 at 10:35
  • 12
    The maximum duration of a long-polling request is 20 seconds. Therefore, it will be making a minimum of 3 requests per minute. But don't panic -- that's only $0.001728 per day. Dec 23, 2019 at 10:39
  • 5
    Lambda uses five concurrent long polls so it makes 15 requests per minute when idle. But still don't worry - that's only $3.15 a year.
    – helloPiers
    Nov 17, 2021 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.