What is the Lambda invocation priority when dealing with different triggers?


Say I have a lambda handler that is able to process sqs queue invocations and also lambda-to-lambda invocations.

The lambda has a max concurrency limit of 10.

Let's say there is a period of time where the concurrency of the lambda is maxed out due to the high volume of sqs queue messages that are processing.

What happens where there is a lambda-to-lambda invocation in the middle of sqs queue messages being processed and maxing out the concurrency limit? Is the AWS CLI invocation handled after all the messages in the queue are processed? Or does the lambda try to process that invocation at the next available instance?

1 Answer

There is no specific priority. The behavior depends on invocation type.

For Asynchronous invocation, the invocation event is added to an internal queue. We then process all the messages in the internal queue. If we try to invoke a function and it already at its limit, we will retry the invocation.

For synchronous invocations (e.g., CLI), if we are at the limit, we return an error. It is up to the client to retry.

For poll based invocations (e.g., SQS), there is a fleet of pollers reading from the queue and trying to invoke the function synchronously. If at the limit, the pollers will retry.

In your case, we can't really tell. It is really timing.

profile pictureAWS
answered a year ago
  • Hey Uri. I'm hoping you can confirm my understanding of what you said here. You say that Lambda has an internal queue. Is that internal queue always prioritized over other source (e.g. SQS). So if I make an Asynchronous invocation and the function is below its limit, that event starts immediately? If I make an Asynchronous invocation and the function is already at its limit, it will be run before events from SQS when a concurrency unit becomes available?

  • No. There is no notion of priority. If you have a message in the internal queue (async invocation) and a message in an SQS queue, and maybe also some sync invocation from API gateway, and let's assume that one instance becomes available, the first to catch it wins.

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