aws / aws-sdk-net

The official AWS SDK for .NET. For more information on the AWS SDK for .NET, see our web site:
http://aws.amazon.com/sdkfornet/
Apache License 2.0
2.07k stars 862 forks source link

AWSSDK.DynamoDbV2 adds 2 seconds to Lambda cold starts #1445

Closed scionwest closed 2 years ago

scionwest commented 5 years ago

If I bring the AWSSDK.DynamoDbV2 package into a netcoreapp3.0 project and deploy it to Lambda I'm seeing it increase my cold start times by 2 seconds.

I have an example project that can be used to reproduce this. You just need to deploy it using dotnet lambda deploy-serverless, insert the following JSON object into the DynamoDb table it generated and make a request to /accounts/838d18ec-127d-4c96-af67-0556a346c114

{
  Email = "foo@bar.com",
  Password = "f00",
  Id = "838d18ec-127d-4c96-af67-0556a346c114"
}

Expected Behavior

When adding your package to an existing project I would expect it to not increase cold-start times of my Lambda by 2 full seconds.

Current Behavior

I'm using the Convey Microservice framework instead of Microsoft's MVC framework for Rest services. Launching a Lambda with a Convey endpoint returning in-memory generated data takes 4.4 seconds on average for a cold-start. If I add the AWSSDK.DynamoDbV2 package and run a GetItem request against a DynamoDB table the cold-start increases from 4.4 seconds to between 6.5 and 7.1 seconds from my tests.

Warm starts don't seem to be an issue. I see an increase of about 15ms on warm starts which isn't bad.

Steps to Reproduce (for bugs)

Context

It's generally known the aspnetcore and Lambda are rough when it comes to cold-starts for public facing APIs. I've seen a lot of this being related to how aspnetcore handles it's dependency tree. Moving to another middleware framework for http request processing that is lighter weight helps with the cold-start. The point of this however is defeated when Amazon's SDK packages severely impact the cold-starts on their own.

Your Environment

.NET Core Info

Runtime Environment: OS Name: Windows OS Version: 10.0.17763 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.0.100\

Host (useful for support): Version: 3.0.0 Commit: 7d57652f33

.NET Core SDKs installed: 2.1.802 [C:\Program Files\dotnet\sdk] 2.2.402 [C:\Program Files\dotnet\sdk] 3.0.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

* Contents of project.json/project.csproj: 
netcoreapp3.0 true Lambda
klaytaybai commented 5 years ago

Thanks for the feedback on this issue. We would like to continue improving the modularity of our packages and improving build/cold start times. In this area, DynamoDB is certainly a high priority.

github-actions[bot] commented 2 years ago

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.