Which solution will meet these requirements?
Configure a provisioned concurrency of two on the Lambda function.
Configure a batch size of two on the Amazon SQS event source mapping for the Lambda function.
Configure Lambda event filtering to process two messages from Amazon SQS at every invocations.
Configure a maximum concurrency of two on the Amazon SQS event source mapping for the Lambda function.
Explanations:
Configuring provisioned concurrency of two allows up to two instances of the Lambda function to run concurrently, but it does not control the rate of incoming messages from the SQS queue. If more than two messages are received, they could still overwhelm the third-party API unless other throttling is in place.
Setting a batch size of two means that the Lambda function will process two messages at a time, but it doesn’t limit the number of concurrent requests being made to the third-party API. If multiple batches are processed, it could still exceed the two concurrent requests requirement.
Lambda event filtering is used to selectively process messages based on certain attributes. It does not control the number of concurrent requests being sent to the third-party API and will not limit the processing of messages to just two at a time.
Configuring a maximum concurrency of two on the Amazon SQS event source mapping directly limits the number of concurrent executions of the Lambda function to two. This ensures that no more than two requests are sent to the third-party API at the same time, thereby preventing it from being overwhelmed.