Search code examples
amazon-web-servicesaws-lambdaamazon-sqs

Are messages in an AWS SQS batch processed in parallel by Lambda function?


I have a question that I can't seem to find the answer to online.

I'll ask the question in the form of an example as follows:

Let's say I have a FIFO Queue. The Queue receives 10 messages. I have a Lambda function that is subscribed to said Queue that is pulling from the Queue with batch size of 5.

Now, are my understandings of SQS correct when I say...

  1. The Lambda function will be invoked twice.
  2. The second invocation will start running after the first is complete.
  3. Each invocation will process 5 messages, each of which will be processed at the same time (in parallel).

Are all of these statements correct? If not, which are incorrect and why?

I have read the SQS documentation but not seeing anything that mentions all of the above statements.


Solution

  • With the help of comments, I now understand what I need for my solution.

    Assuming batch size of 5.

    Assuming that all messages have the same Message Group ID, the messages will be consumed in batches (of 5) from SQS. This means 2 invocations of the Lambda function.

    Each message in batch will be processed one after the other, hence FIFO.