简体   繁体   English

解决 AWS Step Function Map 并发限制

[英]Working around AWS Step Function Map concurrency limit

I have a Map task in an AWS Step Function which executes 100-200 lambdas in parallel, each running for a few minutes, then collects the results.我在 AWS Step Function 中有一个Map任务,它并行执行 100-200 个 lambda,每个运行几分钟,然后收集结果。 However, I'm running into throttling where not all lambdas are started for some time.但是,我遇到了节流问题,在一段时间内并非所有 lambda 都已启动。 The relevant AWS documentation says you may experience throttling with more than ~40 items, which is what I believe I'm running into. 相关的 AWS 文档说您可能会遇到超过 40 个项目的限制,我相信我正在遇到这种情况。

Does anyone have any experience with working around this concurrency limitation?有没有人有解决此并发限制的经验? Can i have nested Maps, or could I bucket my tasks into several Maps I run in parallel?我可以嵌套地图吗,或者我可以将我的任务分到几个并行运行的地图中吗?

Use nested state machine inside your map state, so you can have ~40 child state machines executing in parallel.在您的 map state 中使用嵌套的 state 机器,这样您就可以让 ~40 台子 Z9ED39E2EA9315825B6A98 机器并行执行。 Then inside each child state machine use a map state to process ~40 items in parallel.然后在每个子 state 机器内部使用 map state 并行处理约 40 个项目。 This way you can reach processing ~1600 items in parallel.通过这种方式,您可以并行处理约 1600 个项目。

But before reaching that you will reach AWS Step Functions Quotas:但在达到之前,您将达到 AWS Step Functions Quotas:

https://docs.aws.amazon.com/step-functions/latest/dg/limits.html https://docs.aws.amazon.com/step-functions/latest/dg/limits.html

I ended up working around this 40 item limit by creating 10 copies of the Map task in a Parallel , and bucketing up the task information to split tasks between these 10 copies.我最终通过在Parallel中创建 10 个Map任务的副本来解决这 40 个项目的限制,并将任务信息存储起来以在这 10 个副本之间拆分任务。 This means I can now run ~400 tasks before running into throttling issues.这意味着我现在可以在遇到限制问题之前运行约 400 个任务。 My state machine looks something like this:我的 state 机器看起来像这样:

状态机

AWS now offers a direct solution to this, called "distributed map state", announced at re:invent 2022 https://docs.aws.amazon.com/step-functions/latest/dg/concepts-asl-use-map-state-distributed.html AWS 现在为此提供了一个直接的解决方案,称为“分布式 map 状态”,在 re:invent 2022 https 上宣布://docs.aws.amazon.com/step-functions/latest/dg/concepts-asl-use-map-状态分布式.html

It allows you to perform 10,000 concurrent map state tasks.它允许您执行 10,000 个并发 map state 任务。 Under the hood, it runs them as child step function workflows, which can be specified to run as either standard or express workflows在引擎盖下,它将它们作为子步骤 function 工作流运行,可以将其指定为作为标准或快速工作流运行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM