
Answer-first summary for fast verification
Answer: Move the Amazon S3 client initialization, out of your function handler
Move the Amazon S3 client initialization, out of your function handler - AWS best practices for Lambda suggest taking advantage of execution context reuse to improve the performance of your functions. Initialize SDK clients and database connections outside of the function handler, and cache static assets locally in the /tmp directory. Subsequent invocations processed by the same instance of your function can reuse these resources. This saves execution time and cost. To avoid potential data leaks across invocations, don’t use the execution context to store user data, events, or other information with security implications. Incorrect options: Use environment variables to pass operational parameters - This is one of the suggested best practices for Lambda. By using environment variables to pass operational parameters you can avoid hard-coding useful information. But, this is not the right answer for the current use-case, since it talks about reusing context. Assign more RAM to the function - Increasing RAM will help speed up the process. But, in the current question, the reviewer has specifically mentioned about reusing context. Hence, this is not the right answer. Enable X-Ray integration - You can use AWS X-Ray to visualize the components of your application, identify performance bottlenecks, and troubleshoot requests that resulted in an error. Your Lambda functions send trace data to X-Ray, and X-Ray processes the data to generate a service map and searchable trace summaries. This is a useful tool for troubleshooting. But, for the current use-case, we already know the bottleneck that needs to be fixed and that is the context reuse.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
Your team lead has requested a code review of your Python-written Lambda functions. These functions are designed to upload logs to an Amazon Simple Storage Service (S3) bucket. Following the review, your team lead has advised that you reuse the execution context to enhance the performance of the Lambda functions.
Which of the following actions will help you implement this recommendation?
A
Use environment variables to pass operational parameters
B
Move the Amazon S3 client initialization, out of your function handler
C
Enable X-Ray integration
D
Assign more RAM to the function
No comments yet.