讲Flink async IO时的'capacity'参数是什么?

What is 'capacity' parameter when talking about Flink async IO?

使用Flink AsyncDataStream#unorderedWait时,有一个参数叫'capacity',引自flink官方文档,

Capacity: This parameter defines how many asynchronous requests may be in progress at the same time. Even though the async I/O approach leads typically to much better throughput, the operator can still be the bottleneck in the streaming application. Limiting the number of concurrent requests ensures that the operator will not accumulate an ever-growing backlog of pending requests, but that it will trigger backpressure once the capacity is exhausted.

我不太明白,是针对整个工作,还是针对子任务?

假设我的玩具 flink 应用程序使用一个 kafka,并且对于每个 kafka 消息,它都会发出一个 http 请求,当它收到 http 响应时,它会将其下沉到另一个 kafka 主题。

而在这个例子中,kafka 源的并行度为 50,如果我将 'capacity' 设置为 10,那是什么意思?是不是整个app最多同时发出10个http请求?或者,每个子任务 10 个 http 请求(即同时最多 500 个 http 请求)?

另一个问题是,在这种情况下设置 'capacity' 的最佳做法是什么?

非常感谢!

容量是异步 i/o 运算符的每个实例。因此,在您的示例中,最多会有 500 个并发 http 请求。

您可能需要进行一些基准测试实验,以了解在哪些方面对您的用例进行权衡取舍是有意义的。如果容量太小,那么在负载下你可能会过早地产生背压;如果容量太大,那么在负载下您可能会压垮外部服务,导致超时或其他错误。