You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently upgrading from AWS SDK v2 to AWS SDK v3 and importing @aws-sdk/client-xxx is slower than I would expect and is causing very slow cold starts (close to 1 second).
Test run the code, this returns something like this:
Response
{
"statusCode": 200,
"body": "\"Hello from Lambda!\""
}
Function Logs
START RequestId: 12248941-44db-4e8c-93fa-458c0080ad45 Version: $LATEST
END RequestId: 12248941-44db-4e8c-93fa-458c0080ad45
REPORT RequestId: 12248941-44db-4e8c-93fa-458c0080ad45 Duration: 2.66 ms Billed Duration: 3 ms Memory Size: 1024 MB Max Memory Used: 67 MB Init Duration: 172.79 ms
Init duration (cold start) here is 172.79 ms which is expected.
Now add a few imports to the top of the file so it looks like this:
import { DynamoDBClient, GetItemCommand } from "@aws-sdk/client-dynamodb"
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
import { SSMClient, GetParameterCommand } from "@aws-sdk/client-ssm";
export const handler = async (event) => {
// TODO implement
const response = {
statusCode: 200,
body: JSON.stringify('Hello from Lambda!'),
};
return response;
};
Deploy and test. This will return something like this:
Response
{
"statusCode": 200,
"body": "\"Hello from Lambda!\""
}
Function Logs
START RequestId: fa753048-9567-4836-b9e7-278df1a9767f Version: $LATEST
END RequestId: fa753048-9567-4836-b9e7-278df1a9767f
REPORT RequestId: fa753048-9567-4836-b9e7-278df1a9767f Duration: 2.56 ms Billed Duration: 3 ms Memory Size: 1024 MB Max Memory Used: 115 MB Init Duration: 917.74 ms
Request ID
fa753048-9567-4836-b9e7-278df1a9767f
The cold start time is now 917.74 ms. This seems quite large (and this is before creating any clients (and definately more than AWS SDK v2). Is this expected?
Observed Behavior
Slow cold start time when importing AWS SDK clients.
Expected Behavior
A bit faster?
Possible Solution
No response
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered:
@mk0sojo I am glad to hear that bundling the SDK helped you in reducing the cold start times. It is actually what we recommend as @kuhe said. I am going to resolve this issue now, but please if you have anything else that we can help you with, feel free of opening a new issue.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.
Checkboxes for prior research
Describe the bug
Currently upgrading from AWS SDK v2 to AWS SDK v3 and importing @aws-sdk/client-xxx is slower than I would expect and is causing very slow cold starts (close to 1 second).
SDK version number
@aws-sdk/client-dynamodb@latest, @aws-sdk/client-s3, @aws-sdk/client-ssm
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
Node 18 lambda
Reproduction Steps
Init duration (cold start) here is 172.79 ms which is expected.
The cold start time is now 917.74 ms. This seems quite large (and this is before creating any clients (and definately more than AWS SDK v2). Is this expected?
Observed Behavior
Slow cold start time when importing AWS SDK clients.
Expected Behavior
A bit faster?
Possible Solution
No response
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered: