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

How does AWS Lambda determine if messages are still in SQS queue?


When using AWS Lambda with a SQS queue (as event source), it is written in the doc

If messages are still available, Lambda increases the number of processes that are reading batches by up to 60 more instances per minute. https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html

My question here is how does the Lambda service determine "If messages are still available" ?


Solution

  • Answering the "how" question in a slightly different way:

    Behind the scenes, Lambda operates a "State Manager" control-plane service that discovers work from the queue. State Manager also manages scaling of the fleet of "Poller" workers that do the actual retrieving, batching, invoking, and deleting.

    These implementation details are from the Event Source Mapping section of the re:Invent 2022 video A closer look at AWS Lambda (SVS404-R). Here is a screenshot:

    enter image description here