首页 > 解决方案 > 我应该如何架构 aws lambda 以支持批处理模型中的并行进程?

问题描述

我有一个 aws lambda 函数,可以在收市后对超过 1k 的股票代码进行一些统计。我有一个像下面这样的选项。

我认为它应该运行良好,但如果有任何无服务器/PaaS 方法来触发任务,我将不胜感激

标签: amazon-web-servicesaws-lambda

解决方案


您可以使用 lambda 扇出选项。

您可以按照以下步骤使用无服务器方法处理 1k 或更多。

1.Store all the stock tickers in a S3 file. 
2.Create a master lambda which will read the s3 file and split the stocks in groups of 10. 
3. Create a child lambda which will make the async call to external http service and fetch the details. 
4. In the master lambda Loop through these groups and invoke 100 child lambdas passing in each group and return the results to the
Master lambda
5. Collect all the information returned from the child lambdas and continue with your processing here.

现在,您可以使用 CloudWatch 基于时间的规则调度程序在每天的市场结束时触发这个主 lambda。

这是一种完整的无服务器方法。


推荐阅读