I'm using S3 client in lambda function, this is my code:
public class SomeLambdaFunction
{
public async Task<string> Handler(string input, ILambdaContext context)
{
var client = new AmazonS3Client();
// begin stop watch
await client.GetObjectAsync("<bucket-name>", "<object-key>");
//end stopwatch and see took ~5s
}
}
when I deploy and invoke in the first time, it took ~5s to execute client.GetObjectAsync
, when I run later (reuse lambda instance), it is complete instantly.
PS: I'm aware of cold start issue of lambda function, but I thought it happen before lambda's handler actually run, does cold start really happen inside lambda's handler?