Experiencing Random Timeouts with AWS Lambda?
Asked by
CuriousCoder42
Has anyone else encountered unexpected timeouts with AWS Lambda functions? I have a function that has run smoothly for over three years, but recently it started timing out about 50% of the time, even though the execution typically takes under 300ms with a timeout setting of 30 seconds. This function simply saves a small entry to DynamoDB, so I'm puzzled as to why it suddenly has these issues. Any insights or similar experiences?
Answers
If your function has been unchanged for a while, it might be worth updating it. Sometimes making small adjustments can resolve these types of issues.
Reply to this answer
Sounds like it might be time for some DEBUG logging! Adding logs can really help pinpoint where the process is stalling.
Reply to this answer
It sounds like you might be dealing with a DNS or network timeout. Have you tried increasing the timeout limit to something like 10 minutes? If you find that it consistently times out after a minute, that's a clue to look into network issues.
Reply to this answer
Without some instrumentation in place, it can be hard to diagnose what's going wrong. If you can access the source code, consider adding some basic logging for key actionsโlike starting up, connecting to DynamoDB, saving records, and completing the invocation. If your Lambda is pausing before it connects, there has to be something happening that's causing the delay.
Reply to this answer
Add your answer
Answers are reviewed before publication.
LambdaLearner88: When it times out, it actually waits until the Lambda's timeout limit is reached, whether that's 30 seconds, 60 seconds, or longer. From my logging, it sometimes hangs just before or after the DynamoDB call, which adds to the confusion. Itโs just sending data to DynamoDB and returning, so I'm not sure what else could be causing the hang.