aws / aws-lambda-dotnet

Libraries, samples and tools to help .NET Core developers develop AWS Lambda functions.
Apache License 2.0
1.57k stars 479 forks source link

Timeout doesn't seem to be respected #1160

Closed TommyN closed 5 months ago

TommyN commented 2 years ago

Describe the bug

We have a net6.0 Lambda function (512MB Memory) with a timeout set to 2 seconds. For some reason the timeout value doesn't seem to be respected:


@message
Task timed out after 2.53 seconds
Task timed out after 4.00 seconds
Task timed out after 2.54 seconds
Task timed out after 4.00 seconds
Task timed out after 2.54 seconds
Task timed out after 4.00 seconds
Task timed out after 2.52 seconds
Task timed out after 4.00 seconds
Task timed out after 2.54 seconds
Task timed out after 4.00 seconds
Task timed out after 2.53 seconds
Task timed out after 4.00 seconds
Task timed out after 2.53 seconds
Task timed out after 4.00 seconds
Task timed out after 2.58 seconds
Task timed out after 4.00 seconds

Expected Behavior

I expected the function to time out after 2 seconds

Current Behavior

Function times out after 4 seconds. Billing is limited to 2 seconds.

Duration: 4003.89 ms Billed Duration: 2000 ms Memory Size: 512 MB Max Memory Used: 512 MB

Reproduction Steps

N/A

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

Amazon.Lambda.Core Version="1.1.0"

Targeted .NET Platform

NET 6

Operating System and version

.NET 6 (C#/PowerShell)

ashishdhingra commented 2 years ago

Hi @TommyN,

Good afternoon.

Thanks for reporting the issue. Please share the sample code to help reproduce the issue ay our end.

Regards, Ashish

TommyN commented 2 years ago

This happened 16 times over the last 4 days. The Lambda function was invoked 25M times, so I don't have a sample that will easily provoke the issue.

image

ryanwilliams83 commented 10 months ago

You may wish to consder var cts = new CancellationTokenSource(TimeSpan.FromSeconds(2)); and then passing cts.Token into your async methods to get a more precise timeout.

normj commented 5 months ago

I'm gonna close this ticket because it is pretty old and probably not actionable anymore. Lambda has changed quite a bit since this issue first reported but I wonder if the original issue was the 4 second timeouts where the cold starts and I don't think the init part counts towards the timeout.

github-actions[bot] commented 5 months ago

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.