Development with AWS Services
A Lambda handler creates a new AWS SDK client for DynamoDB on every invocation. How should the developer reduce repeated client initialization across warm invocations?
Show the answer
Correct answerA. Initialize the client outside the handler.
AWhy this is right: Initialization outside the handler allows the SDK client to be reused when Lambda reuses the execution environment.
BWhy not this: Batch size changes records per invocation, not client reuse across warm invocations.
CWhy not this: A longer timeout allows more execution time but does not eliminate repeated client construction.
DWhy not this: A layer changes dependency packaging, not how often the handler constructs an SDK client.
Initializing the SDK client outside the handler allows warm invocations in the same execution environment to reuse it. A layer can package the SDK, but it does not prevent code inside the handler from constructing a new client each time.