Avoiding throttling issues altogether using asynchronous Lambda invocation

0

On an account that has a limit of 10 concurrent invocations limit, I have noticed that calling the Lambda function synchronously in short intervals can cause throttling issues (502 errors - some requests are simply rejected due to limit reach).

However, if the same function is called multiple times at very short intervals asynchronously (using InvocationType: Event), then all succeed.

My question, is this a feasible way to avoid all those throttling issues altogether ? Simply calling the function asynchronously ? Would this work always flawlessly,

Thank you.

WM
已提問 1 年前檢視次數 545 次
2 個答案
1
已接受的答案

It is possible that using the asynchronous InvocationType (Event) when calling a Lambda function can help to avoid throttling issues in cases where the concurrent invocations limit has been reached. This is because the Event invocation type allows multiple requests to be handled concurrently, whereas the default RequestResponse invocation type processes requests one at a time.

However, it is important to note that using the Event invocation type may not always work flawlessly to avoid throttling issues. This is because the Event invocation type is not guaranteed to deliver the results of the function in the order that the requests were made. Additionally, the Event invocation type may not be suitable for all use cases, as it does not provide a way to obtain the result of the function directly.

In general, it is a good practice to design your Lambda functions and the calling application in a way that avoids reaching the concurrent invocations limit. This can be done by using techniques such as batching requests, or by using a queueing service such as Amazon SQS to buffer requests before they are sent to the Lambda function.

profile pictureAWS
已回答 1 年前
profile picture
專家
已審閱 1 個月前
  • Thank you, that was very informative.

1

Any reason you want such a low limit on concurrent invocations when your question is about running more at once? You can request a quota increase? Am I missing something that makes you need a different solution?

I do agree with Dylan's answer that async behaves a bit differently and would be the preferred design pattern.

profile picture
已回答 1 年前
  • I understand that increasing the limit solves the issue for concurrent invocations (synchronously). Another solution, I understand, is to use asynchronous invocations, order does not matter. What matters is that all requests will be processed. And there is also the dead lock feature, which can notify about failed ones. Amazon SQS or batching from my side can also be a third solution. Thank you, your input is valuable.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南