场景 - 有一个主lambda正在拆分工作并将其交给多个其他lambda( Worker ) . 第一个lambda迭代并异步调用其他lambdas
如果产生的lambda数量超过1000,它会失败吗?
两个lambdas之间是否应该有一个SNS ...以便SNS重试?
或者是一种更复杂的方法,将消息放入队列,然后发送“X”号工作者lambda的通知以开始轮询队列?
有没有更好的办法?
是的, 生产环境 者和消费者之间应该存在某种脱钩 . 最明显的方法是让 生产环境 者在SNS主题上创建1000条消息,让AWS处理需要多少消费者(也许它可以重用消费者lambda) . 其他方式包括从插入DynamoDB的记录中触发 .
如果您希望侦听器从SQS队列中提取消息,您需要自己触发它们,您可以使用CloudWatch进行触发(每分钟最多1次触发)
If the number of lambdas which are getting spawned are more than 1000 Qn: Will it fail?
是的,它会失败 . 但你可以 increase the default limits(1000) to n numbers based on region by requesting AWS Customer Support.
http://docs.aws.amazon.com/lambda/latest/dg/limits.html
http://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html
我不确定你的具体要求 . 根据您的要求,您需要 make sure spawning 1000 lambdas is required in your design .
我的建议如下
建议1: -
AWS Step Functions
通过AWS Step Functions,您可以使用状态机语言从master调用您的子lambda . 基于你的主lambda如何调用 . (例如:Cloudwatch规则,触发器) . 有关更多信息,请访问: -
https://aws.amazon.com/step-functions/
https://states-language.net/spec.html
建议2: -
AWS ECS Container
从Master Lambda发送消息到SQS . 启动您的子计划作为ECS容器服务 . 在Program中,您可以使用SQS消息并解决业务逻辑 .
http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_services.html
2 回答
是的, 生产环境 者和消费者之间应该存在某种脱钩 . 最明显的方法是让 生产环境 者在SNS主题上创建1000条消息,让AWS处理需要多少消费者(也许它可以重用消费者lambda) . 其他方式包括从插入DynamoDB的记录中触发 .
如果您希望侦听器从SQS队列中提取消息,您需要自己触发它们,您可以使用CloudWatch进行触发(每分钟最多1次触发)
If the number of lambdas which are getting spawned are more than 1000 Qn: Will it fail?
是的,它会失败 . 但你可以 increase the default limits(1000) to n numbers based on region by requesting AWS Customer Support.
http://docs.aws.amazon.com/lambda/latest/dg/limits.html
http://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html
我不确定你的具体要求 . 根据您的要求,您需要 make sure spawning 1000 lambdas is required in your design .
我的建议如下
建议1: -
AWS Step Functions
通过AWS Step Functions,您可以使用状态机语言从master调用您的子lambda . 基于你的主lambda如何调用 . (例如:Cloudwatch规则,触发器) . 有关更多信息,请访问: -
https://aws.amazon.com/step-functions/
https://states-language.net/spec.html
建议2: -
AWS ECS Container
从Master Lambda发送消息到SQS . 启动您的子计划作为ECS容器服务 . 在Program中,您可以使用SQS消息并解决业务逻辑 .
http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_services.html