Search code examples
amazon-web-servicessam

AWS Lambda function: Timeout after 900 secs


I am invoking an AWS Lambda function locally using aws-sam cli command and I have set the Timeout property to 900 seconds but still it shows function timeout error. However, when I was invoking this function in lambda handler in AWS Console these 900 seconds were enough for the inferencing.

Please help me figure out a solution for this issue and what is the maximum limit I can go for Timeout?

Error


Solution

  • AWS Lambda functions (as at July 2021) can only run for a maximum of 15 minutes (which is 900 seconds).

    Some people do 'interesting' things like:

    • Call another Lambda function to continue the work, or
    • Use AWS Step Functions to orchestrate multiple AWS Lambda functions

    However, it would appear that your use-case is Machine Learning, which does not like to have operations stopped in the middle of processing. Therefore, AWS Lambda is not suitable for your use-case.

    Instead, I would recommend using Amazon EC2 spot instances, which will likely be lower-cost for your use-case. While spot instances might occasionally be terminated, your use-case can probably handle the need to re-run some processing if this happens.