session timeout
在生产环境中如何避免Kafka不必要的rebalance?
我们知道,触发Kafka发送Rebalance的条件一共有4种:
① 消费者组成员个数发生变化
第一种场景:如果有新的 consumer 实例加入该消费组或者离开组,这种情况无法避免。
有一种场景:当消费者组完成Rebalance之后,每个Consumer都会定期向Coordinator发送心跳数据,如果某个Consumer超过(session.timeout.ms)的值(默认30秒),就会被Coordinator认为这个Consumer已经死了,从而将Group中踢出,此时需要开启新一轮的Rebalance。此外还有一个heartbeat.interval.ms,这个值设置的越小,Consumer实例发送心跳的频率越高,越容易尽快让Coordinator通知Rebalance。通常建议一起设置session.timeout.ms 和 heartbeat.interval.ms 的值,来尽量避免rebalance的出现,经验值:
session.timeout.ms=10000
heartbeat.interval.ms=2000
② 订阅的 Topic 个数发生变化。
需要人为提前设计好,避免造成不必要的变更。
③ 订阅 Topic 的分区数发生变化。
需要人为提前设计好,避免造成不必要的变更。
④ 某条消息的处理时长超过30秒(默认)。
这类情况是消费消息时间过长导致的,此时如何max.poll.interval.ms的参数值非常重要,如果要避免非必要的Rebalance,可以考虑把这个参数值设置的大一些,尽量比下游的消费时间要长。
Home work:
Topic: Genetic mutation
The session today is talking about the genetic mutation. We all have common features that result in common genetics. However, if our genetics vary even slightly, we can develop different traits that make us extremely unique.
Today we learned some cases of the genetic mutation, unbreakable bones, heterochromia( 异色,异瞳) oxygen tolerances, pain tolerances.
Free talk, the teacher gave out some questions.
What would you do if you had unbreakable bones? Do some adventures? Or carry your life>
#历史上的今天# 过渡时期总路线的提出
[太阳]红杉树小课堂:历史上的今天





