0 votes
in AWS by

You've created a local Java-based Lambda function. You then package and upload the function to AWS. You try to run the function with the default settings. But the function does not run as expected.

Which of the following could be the reasons for the issue? Choose 2 answers from the options given below.

1 Answer

0 votes
by

Answer - C and D.

Since the function is created with the default settings, the timeout for the function would be 3 seconds and the memory would default to 128 MB.

For a Java-based function, this would be too less.

Hence you need to ensure that the right settings are put in place for the function.

Q: How are compute resources assigned to an AWS Lambda function?

In the AWS Lambda resource model, you choose the amount of memory you want for your function, and are allocated proportional CPU power and other resources.

For example, choosing 256MB of memory allocates approximately twice as much CPU power to your Lambda function as requesting 128MB of memory and half as much CPU power as choosing 512MB of memory.

You can set your memory from 128 MB to 3,008 MB, in 64 MB increments.

Option A is invalid since the name is not a reason for the function not working.

Option B is invalid since the CPU is allocated by AWS automatically.

For more information on creating a function, please refer to the below URL-

https://docs.aws.amazon.com/lambda/latest/dg/get-started-create-function.html

When a local Java-based Lambda function is packaged and uploaded to AWS, it is important to ensure that the configuration settings are correct for the function to run as expected. If the function does not run as expected, there could be several reasons for the issue. Here are the possible reasons:

A. The name assigned to the function is not correct: It is possible that the function is not running as expected because the name assigned to the function is incorrect. The function name must match the name specified in the handler class. If there is a mismatch between the function name and the handler class name, the function will not run.

B. The amount of CPU assigned to the function is not enough: Lambda functions are executed in a containerized environment that is isolated from other functions. The amount of CPU allocated to a function depends on the size of the container and the amount of memory allocated to the function. If the function is running slow, it could be because the allocated CPU is not enough to handle the workload.

C. The amount of memory assigned to the function is not enough: Lambda functions are executed in a containerized environment, and the amount of memory allocated to the function determines the amount of CPU allocated. If the function does not have enough memory allocated, it may not be able to handle the workload, resulting in slow execution times or unexpected behavior.

D. The timeout specified for the function is too short: The timeout specified for a function determines how long AWS waits for the function to complete its execution. If the function takes longer than the specified timeout, AWS will terminate the function. If the timeout specified for the function is too short, the function may not have enough time to complete its execution, resulting in unexpected behavior.

In summary, the possible reasons why a local Java-based Lambda function may not run as expected after packaging and uploading to AWS include incorrect function name, inadequate CPU and memory allocation, and short function timeout.

...