- 最新
- 投票最多
- 评论最多
With Lambda Functions you have to consider:
-
Maximum amount of run duration time. (15 min). Make sure when creating the lambda function you set the timeout value. In the console look at the configuration and if you are creating the lambda function with code, "client.create_function", set the Timeout value to 15 min (900 sec)
-
How are you invoking the function? Make sure you are using the "RequestResponse" invocationType for Synchronous and Event for Async.
response = client.invoke(
FunctionName='string',
InvocationType='Event'|'RequestResponse'|'DryRun',
LogType='None'|'Tail',
ClientContext='string',
Payload=b'bytes'|file,
Qualifier='string'
)
- Make sure you handle the Error in Try Except else. depending on error type, lambda executes up to two more times.
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda/client/invoke.html
- Your logic. is the function looping until all the files are downloaded? How about if there are 10, 100, or 1000 files to download? The time required to download all the files may exceed the 15 min limit.
Not sure about your use-case. But, Keeping socket connections open for that long is not a good thing unless there is a good reason like real-time telemetry.
I would think you would want to send a message per file to a process SQS queue and have the lambda pickup file and process the file. Then when done processing, have the lambda send a message to a completed SQS queue.
In you calling app, just waits until there is something in the completed queue. Once all the files are done, you can continue.
相关内容
- AWS 官方已更新 1 年前
- AWS 官方已更新 1 年前
- AWS 官方已更新 1 年前
Hello,
Lambda is not reaching 15 mins, it's not timing out, code works perfectly. I updated the question with my further findings and my assumptions for the blockers.
Thank you.
Adas.