Lambda reinitializes with EventBridge

0

Hi Everyone,

I use a lambda with an EventBridge set to 2 minutes to scan an FTP server where some files are stored. Every two minutes, my lambda goes and check if there are new files that have not been previoulsy uploaded to a target S3 bucket. If there is a such a file, it downloads it in the lambda tmp folder and then uploads it to the S3.

I never have a lot of files to download at once, but it may happen in the future. As a consequence, I am wondering what is happening after the 2 minutes set for the EventBridge. Does the same lambda stops and clears its tmp folder and restarts again? If It was in the middle of uploading a file to the S3 from its tmp folder, will it stop?

Many thanks

Antoine

已提问 2 年前217 查看次数
1 回答
0
已接受的回答

After the two minutes between executions, Lambda may reuse an existing container (execution context) or create a new one; you cannot rely on a new container always being created. If the container is reused, the /tmp folder will be populated already. That said, if a previous execution is still running, a new container will be created as to not interfere with the existing function execution (e.g. if you have 100 executions of a function running at the same time, there will be 100 separate containers for them).

AWS
已回答 2 年前
  • Thanks for replying so swiftly Justin!

    Ok so can I safely assume that a new container will be used if there is a upload from lambda's tmp to S3 ongoing by the time the 2minutes are reached?

    It may be smarter to have two separate lambdas, one that passes the download orders to a queue and that has an EventBridge and one that takes its time to download each item added to the queue (and so without a CRON for this second one). Does having multiple containers running for the same lambda mean higher costs as well? I mean compare to the alternative solution I mention just above.

    Cheers

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则