Spark控制消费速率

69 篇文章 8 订阅

spark.streaming.backpressure.initialRate

spark2.0版本以上

这是启用背压机制时每个接收器将接收第一批数据的初始最大接收速率。限制第一次批处理应该消费的数据,因为程序冷启动 队列里面有大量积压,防止第一次全部读取,造成系统阻塞

This is the initial maximum receiving rate at which each receiver will receive data for the first batch when the backpressure mechanism is enabled.

默认值为空,没有设置

spark.streaming.kafka.maxRatePerPartition

设置每秒每个分区最大获取日志数,控制处理数据量,保证数据均匀处理。使用新的Kafka Direct Stream API时,将从每个Kafka分区读取数据的最大速率(每秒的记录数)。

spark.streaming.backpressure.enabled

启用或禁用Spark Streaming的内部背压机制(自1.5开始)。 这使Spark Streaming能够基于当前的批处理调度延迟和处理时间来控制接收速率,以便系统仅接收与系统可处理的速度一样的速度。 在内部,这可以动态设置接收器的最大接收速率。 如果设置了该值,则上限为spark.streaming.receiver.maxRatespark.streaming.kafka.maxRatePerPartition值。

Enables or disables Spark Streaming’s internal backpressure mechanism (since 1.5). This enables the Spark Streaming to control the receiving rate based on the current batch scheduling delays and processing times so that the system receives only as fast as the system can process. Internally, this dynamically sets the maximum receiving rate of receivers. This rate is upper bounded by the values
spark.streaming.receiver.maxRate and spark.streaming.kafka.maxRatePerPartition if they are set.

默认是false,就是没有开启.

spark.streaming.receiver.maxRate

每个接收器接收数据的最大速率(每秒的记录数)。 实际上,每个流每秒最多消耗此数量的记录。 将此配置设置为0或负数将不限制速率。

总结

通过以上几个参数可以控制spark Streaming的消费速度

参考

Configuration - Spark 3.0.1 Documentation:
SparkStreaming-Kafka数据的消费_窗外的屋檐-CSDN博客

flink和spark Streaming中的Back Pressure - 云+社区 - 腾讯云

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值