Spark streaming - reduceByKeyAndWindow() 是否使用常量内存?
Spark streaming - Does reduceByKeyAndWindow() use constant memory?
我正在考虑进行长时间 运行 聚合(可能是一天 window)。我意识到该站点上的其他解决方案说您应该为此使用批处理。
不过我特别想了解这个函数。听起来它会使用常量 space 对 window 进行聚合,一次一个间隔。如果那是真的,那么为期一天的聚合听起来是可行的(特别是因为它在失败的情况下使用检查点)。
有谁知道是不是这样?
此函数记录为:https://spark.apache.org/docs/2.1.0/streaming-programming-guide.html
A more efficient version of the above reduceByKeyAndWindow() where the reduce value of each window is calculated incrementally using the reduce values of the previous window. This is done by reducing the new data that enters the sliding window, and “inverse reducing” the old data that leaves the window. An example would be that of “adding” and “subtracting” counts of keys as the window slides. However, it is applicable only to “invertible reduce functions”, that is, those reduce functions which have a corresponding “inverse reduce” function (taken as parameter invFunc). Like in reduceByKeyAndWindow, the number of reduce tasks is configurable through an optional argument. Note that checkpointing must be enabled for using this operation.
在 MapR 论坛上对此进行研究后,它似乎肯定会使用恒定级别的内存,假设您可以在分配的资源中容纳一天的数据,则每天 window 成为可能。
两个缺点是:
- 每日汇总可能只需要 20 分钟。一天执行 window 意味着您永久使用所有这些集群资源,而不是每天只使用 20 分钟。因此,独立批处理聚合的资源效率要高得多。
- 当您流式传输整整一天时,很难处理延迟数据。如果您的数据标有日期,那么您需要等到所有数据都到达。仅当您实际上只是对过去 24 小时的数据进行分析而不管其内容如何时,流式传输 1 天 window 才是好的。
我正在考虑进行长时间 运行 聚合(可能是一天 window)。我意识到该站点上的其他解决方案说您应该为此使用批处理。
不过我特别想了解这个函数。听起来它会使用常量 space 对 window 进行聚合,一次一个间隔。如果那是真的,那么为期一天的聚合听起来是可行的(特别是因为它在失败的情况下使用检查点)。
有谁知道是不是这样?
此函数记录为:https://spark.apache.org/docs/2.1.0/streaming-programming-guide.html
A more efficient version of the above reduceByKeyAndWindow() where the reduce value of each window is calculated incrementally using the reduce values of the previous window. This is done by reducing the new data that enters the sliding window, and “inverse reducing” the old data that leaves the window. An example would be that of “adding” and “subtracting” counts of keys as the window slides. However, it is applicable only to “invertible reduce functions”, that is, those reduce functions which have a corresponding “inverse reduce” function (taken as parameter invFunc). Like in reduceByKeyAndWindow, the number of reduce tasks is configurable through an optional argument. Note that checkpointing must be enabled for using this operation.
在 MapR 论坛上对此进行研究后,它似乎肯定会使用恒定级别的内存,假设您可以在分配的资源中容纳一天的数据,则每天 window 成为可能。
两个缺点是:
- 每日汇总可能只需要 20 分钟。一天执行 window 意味着您永久使用所有这些集群资源,而不是每天只使用 20 分钟。因此,独立批处理聚合的资源效率要高得多。
- 当您流式传输整整一天时,很难处理延迟数据。如果您的数据标有日期,那么您需要等到所有数据都到达。仅当您实际上只是对过去 24 小时的数据进行分析而不管其内容如何时,流式传输 1 天 window 才是好的。