0 votes
in AWS by

A developer has recently deployed an AWS Lambda function that computes a Fibonacci sequence using recursive Lambda invocations.

A pre-defined AWS IAM policy is being used for this function, and only the required dependencies were packaged.

A few days after deployment, the Lambda function is being throttled. What should the Developer have done to prevent this, according to best practices?

1 Answer

0 votes
by

Answer - B.

The question's focus is on the best practice methods for Lambda functions.

Since the question asks us to choose the best option that the developer might have done to prevent this throttling issue, he should have written a code that avoids the recursive call of the function within itself as it is not recommended as a best practice.

For the "Lambda function code" best practice, it is recommended that we should avoid recursive code in the Lambda function.

"Avoid using recursive code in your Lambda function, wherein the function automatically calls itself until some arbitrary criteria are met.

This could lead to an unintended volume of function invocations and escalated costs.

If you do accidentally do so, set the function concurrent execution limit to '0' (Zero) immediately to throttle all invocations to the function, while you update the code."

Option A is incorrect since using IAM Policies will not help in resolving the issue.

Option C is incorrect since this is about concurrency on the number of AWS Lambda executions.

Option D is incorrect since the issue here is with the number of executions and not on the amount of memory used for the executions.

For more information, please refer to the below Link-

https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html

The correct answer is C. Request a concurrency service limit increase.

Explanation:

AWS Lambda uses a concurrency model to limit the number of simultaneous function executions. Each function instance requires a certain amount of memory, and AWS Lambda allocates CPU power in proportion to the memory allocation. By default, AWS limits the number of concurrent executions across all functions within an AWS account.

In this scenario, the Lambda function is being throttled because it has exceeded the concurrency limit. The developer could request a concurrency service limit increase to prevent this from happening in the future.

Option A, using more restrictive IAM policies, would not address the issue of concurrency throttling. IAM policies control access to AWS resources, but they do not affect the concurrency model.

Option B, avoiding recursive Lambda invocations, is not always possible or practical. While it is generally a best practice to avoid recursion in Lambda functions, there may be cases where it is necessary or beneficial to use recursion.

Option D, increasing the memory allocation range, would not directly address the issue of concurrency throttling. While increasing the memory allocation range may provide more CPU power to each function instance, it would not increase the overall concurrency limit.

...