A developer is designing an AWS Lambda function that processes incoming images. The function requires a static machine learning model file of , which is stored in a private Amazon S3 bucket. This model file is read-only and rarely updated. To process the images, the function also needs to write metadata to an Amazon DynamoDB table. The developer wants to optimize the Lambda function's performance by minimizing execution time and avoiding unnecessary API calls during cold starts and warm invocations. Which of the following actions should the developer take to meet these requirements? (Select TWO.)
- Initialize the Amazon S3 and Amazon DynamoDB SDK client objects outside of the Lambda handler function.Cevap
- Download the model file to the `/tmp` directory during the initialization phase, checking for its existence in `/tmp` before downloading it on subsequent invocations.Cevap
- CDownload the model file directly to the `/tmp` directory inside the handler function on every invocation.
- DInitialize the AWS SDK clients using hardcoded access keys and secret keys inside the handler function.
- EConfigure the Lambda function to run inside a private VPC subnet without an internet gateway or NAT gateway, and access Amazon S3 using the public S3 endpoint.
Cevap
The correct actions are to initialize the Amazon S3 and Amazon DynamoDB SDK client objects outside of the Lambda handler function, and to download the model file to the `/tmp` directory during the initialization phase while checking for its existence in `/tmp` before downloading on subsequent invocations.
The correct options specify initializing SDK clients outside the Lambda handler function and downloading the large static model file to `/tmp` during the initialization phase while checking for its presence first. These techniques take full advantage of AWS Lambda's execution context reuse, avoiding redundant connections and high-volume data transfers on subsequent warm invocations, which dramatically improves performance.
Adım Adım Çözüm
Anahtar Kavram
AWS Lambda execution context reuse, client initialization, and ephemeral storage optimization.
Tahmini Süre:2m 0s