多个 AWS Lambda 执行完成的回调

Callback for Multiple AWS Lambda execution completion

这是我的问题:

I have to compare a candidate object with some criteria with millions of other candidates in db. Since lambda allows only 5 minutes of execution so it causes timeout.

我的解决方案:

I planned to do this comparison with 10,000 chunks of candidates so I have to call 10 lambda functions (through SNS) to process 100,000 candidates and then save results of each lambda in some DynamoDB table. But how to get a callback when all lambda functions are done processing so that I can collect those results for individual lambdas and then calculate final results. How to achieve this or is there any better way to acheive my goal. Any help is most appreciated.

我不确定 AWS Lambda 是否真的适合您的用例。但是,只关注问题的主要部分,您可以使用 DynamoDB Atomic Counters 来确定所有处理何时完成。您将执行以下操作:

  • 最初在 DynamodB 中插入一条记录,其中 numberOfLambdaCalls 属性设置为您正在启动的并发执行数,completedLambdaCalls 属性设置为 0
  • 当每个函数完成时,作为更新 DynamoDB 记录的一部分,它们将自动增加 completedLambdaCalls 属性。
  • 每个函数都可以检查更新的返回结果,看看它们是否完成了像 if numberOfLambdaCalls == completedLambdaCalls 这样的处理,如果是,则执行任何必要的操作来触发您的响应。