scala - akka 流 throttle 如何工作?

标签 scala akka akka-stream

def throttle(elements: Int, per: FiniteDuration, maximumBurst: Int, mode: ThrottleMode): Repr[Out]

是否maximumBurst意味着可以同时处理的元素数量?

最佳答案

来自 scaladoc :

Throttle implements the token bucket model. There is a bucket with a given token capacity (burst size or maximumBurst). Tokens drops into the bucket at a given rate and can be 'spared' for later use up to bucket capacity to allow some burstiness. Whenever stream wants to send an element, it takes as many tokens from the bucket as number of elements. If there isn't any, throttle waits until the bucket accumulates enough tokens. Bucket is full when stream just materialized and started.


maximumBurst是上述模型中的 token 桶大小。
假设我们启动了一个节流的流,并且接收器开始要求元素。 throttle 级会发出maximumBurst在背压(使用整形模式)或失败(使用强制模式)之前,它们。

所以我会说这是可以在不限制的情况下处理的最大元素数。 “同时”处理永远不会是流中的精确定义:)

关于scala - akka 流 throttle 如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44797214/

相关文章:

json - 如何在Spark上将JSON字符串转换为数据帧

scala - Akka流通过限流并行/处理流的吞吐量

scala - 如何始终保持传入的 websocket 连接打开?

scala - Akka-http 流使用 Slick 3.0 Databasepublisher

Scala 伴生对象不是单例

scala - 创建一个自定义 Scala 集合,其中 map 默认返回自定义集合?

scala - Play Framework 中指定的基础 docker 镜像在哪里?

scala - `extrapolate` 中 `Akka-Streams` 的用例是什么?

java - 无法使用 Jackson 解码 LocalDate 和 LocalTime 类

serialization - akka 远程处理中的 "max allowed size 128000 bytes, actual size of encoded class scala"错误