amazon-web-services - 我应该如何架构 aws lambda 以支持批处理模型中的并行进程?
问题描述
我有一个 aws lambda 函数,可以在收市后对超过 1k 的股票代码进行一些统计。我有一个像下面这样的选项。
- 在 ec2 实例中设置 cron 作业并触发 cron 作业以异步提交 1k http 请求(例如http://xxxxx.lambdafunction.xxxx?ticker=以触发 aws lambda 函数(或向 SNS 提交 1k 请求并让 lambda 拾取.
我认为它应该运行良好,但如果有任何无服务器/PaaS 方法来触发任务,我将不胜感激
解决方案
您可以使用 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。
这是一种完整的无服务器方法。
推荐阅读
- asp.net-core-mvc - 页面显示数据库中的所有内容
- rabbitmq - 为什么创建微服务时需要定义队列名称?
- python - Given an integer, add operators between digits to get n and return list of correct answers
- spring - 如何从@many-to-many 创建的基础中获取用户
- javascript - JavaScript RegEx 不匹配斜杠
- swift - 将带有 AM/PM 的字符串转换为 UserNotificationCenter 显示值
- python - xlsxwriter:同一工作簿中的重复工作表
- r - 在 r 中的向量边界处填充 NA
- azure - 导入 3D 模型以表示 Azure 数字孪生中的物理设备
- mysql - 在选择子查询中使用 AVG 结果