如果你使用消费者,那么一定会接触这几个参数:

session.timeout.ms、heartbeat.interval.ms、max.poll.interval.ms,先让我们看看分别代表什么含义吧!

session.timeout.ms:

The timeout used to detect worker failures. The worker sends periodic heartbeats to indicate its liveness to the broker. If no heartbeats are received by the broker before the expiration of this session timeout, then the broker will remove the worker from the group and initiate a rebalance. Note that the value must be in the allowable range as configured in the broker configuration bygroup.min.session.timeout.msandgroup.max.session.timeout.ms.

名称:会话超时时间

作用:检测消费者是否超时故障的超时时间

机制:消费者 定期发送心跳证明自己的存活,如果在这个时间之内broker没收到,那broker就将此消费者从group中移除,进行一次reblance。

注意:此值的配置需要在group.min.session.timeout.ms 和 group.max.session.timeout.ms 范围内。

heartbeat.interval.ms:

The expected time between heartbeats to the consumer coordinator when using Kafka's group management facilities. Heartbeats are used to ensure that the consumer's session stays active and to facilitate rebalancing when new consumers join or leave the group. The value must be set lower thansession.timeout.ms, but typically should be set no higher than 1/3 of that value. It can be adjusted even lower to control the expected time for normal rebalances.

名称:心跳间隔时间

作用:当消费者使用group时,用于确保消费者存活,并在消费者加入或离开group时促进reblance

注意:必须小于session.timeout.ms,但通常又不能大于session.timeout.ms的1/3,越小重新平衡的时间越短

max.poll.interval.ms:

The maximum delay between invocations of poll() when using consumer group management. This places an upper bound on the amount of time that the consumer can be idle before fetching more records. If poll() is not called before expiration of this timeout, then the consumer is considered failed and the group will rebalance in order to reassign the partitions to another member.

名称:最大拉取间隔时间

作用:检测消费者是否pull超时或失败

机制:如果消费者两次pull的时间超过了此值,那就认为此消费者能力不足,将此消费者的commit标记为失败,并将此消费者从group移除,触发一次reblance,将该消费者消费的分区分配给其他人。

注意:该值越大,reblance的时间越长。

所以这三个参数的目的是保证group中都是能正常消费的消费者:

1、通过心跳判断:消费者隔heartbeat.interval.ms向broker汇报一次心跳,broker计算消费者多久没有向自己发心跳了,如果超过了session.timeout.ms,那么就认为该消费者不可用了,将其移除。

2、通过pull()时间间隔判断:broker如果发现max.poll.interval.ms没有调用pull()方法,那么就将此消费者移除。

那么有同学可能会问了:如果通过心跳判断消费者没有死,但是通过pull超时的,那么会移除么?

虽然从0.10.1以后session.timeout.ms 和 max.poll.interval.ms 解耦了,可以在处理消息的同时发送心跳,在处理消息的时候不被移除,但是当处理完毕再次调用pull方法时发现此消费者的两次pull是超时的,仍然会将其做失败的重试处理,销毁旧线程,从线程池取新线程,所以答案是会移除。

session.timeout.ms、heartbeat.interval.ms、max.poll.interval.ms的含义及联系的更多相关文章

  1. Kafka session.timeout.ms heartbeat.interval.ms参数的区别以及对数据存储的一些思考

    Kafka session.timeout.ms heartbeat.interval.ms参数的区别以及对数据存储的一些思考 在计算机世界中经常需要与数据打交道,这也是我们戏称CURD工程师的原因之 ...

  2. How to configue session timeout in Hive

    This article explains how to configure the following settings in Hive:hive.server2.session.check.int ...

  3. Zookeeper中Session Timeout的那些事

    前言: RDS系统致力于MySQL数据的高可用,高可靠,高性能以及在线扩展功能,实现这些特性的主要逻辑功能都运行在管理服务器上,一旦管理服务器宕机,数据库的在线扩展功能/备份功能/故障恢复功能等都无从 ...

  4. MS SQL数据批量备份还原(适用于MS SQL 2005+)

    原文:MS SQL数据批量备份还原(适用于MS SQL 2005+) 我们知道通过Sql代理,可以实现数据库的定时备份功能:当数据库里的数据库很多时,备份一个数据库需要建立对应的定时作业,相对来说比较 ...

  5. Tomcat connection & session timeout settings

    # connection timeout for globle web application cat /home/soft/apache-tomcat-7.0.92/conf/server.xml ...

  6. 关于无线的Idle Timeout和Session Timeout

    1.Session Timeout Session Timer的默认值为1800s,也就是30min.Session Timeout:当该计时器超时时,使得客户端强制发生重认证,这个时间是从客户端认证 ...

  7. 项目server中设置session timeout遇到的问题

    RT:在项目server中的web.xml设置session timeout=10,当10分钟后,继续右键执行jsp文件,运行失败,如下图所示: 但是单独启动tomcat server后,在浏览器中输 ...

  8. Oracle 11g 的bug?: aix 上,expdp 11.2.0.1 导出,impdp 11.2.0.3 导入,Interval 分区的 【Interval】 分区属性成了【N】

    如题: Oracle 11g 的bug?: aix 上,expdp 11.2.0.1 导出,impdp 11.2.0.3 导入,Interval 分区的 [Interval] 分区属性成了[N] 谨记 ...

  9. ASP.NET Misconfiguration: Excessive Session Timeout

    Abstract: An overly long authentication timeout gives attackers more time to potentially compromise ...

  10. Session Timeout 与 $.ajaxSetup

    对于session过期跳转的问题,很简单,就是一个过滤器,然后判断session为空?跳转:继续.但是对于ajax的请求,需要做特殊处理,见下面代码中的 // 此处考虑ajax操作session过期的 ...

随机推荐

  1. Windows10使用WSL(Windows Subsystem for Linux)

    官方页面地址:https://docs.microsoft.com/zh-cn/windows/wsl/ 查看WSL的IP地址:ip addr | grep eth0 下面是一个示例 PowerShe ...

  2. 用tkinter编写一个获取图片资源的GUI工具

    目录 效果展示 导入tkinter库 窗口属性 按钮和输入框 文本输入框Text 运行 打包成exe文件 源码地址 本文可以学习到以下内容: 使用tkinter的Entry功能获取本地文件夹 使用tk ...

  3. VUE3+VITE 常见问题解决

    reactive解构最深的一层,失去响应性问题 pinia创建的store,使用结构失去响应性 reactive包裹后的对象 重新赋值失去响应性 无法动态引入图片 在computed中传参数 vue3 ...

  4. XMind8破解,详细版(亲测)

    废话不多说,直接上料: 一.资源 百度网盘XMind8: 链接:https://pan.baidu.com/s/1h2DXkni4-POEpHyBqLxjwA 提取码:kqgy 破解补丁: 链接:ht ...

  5. LocalDateTime与LocalDate

    时间新特性 新生事物出现,必定是对旧事物的完善或者是缺陷的弥补. 本文章介绍LocalDate.LocalDateTime.在多线程的情况,相比较于Date.Calendar.SimpleDateFo ...

  6. selenium执行下载多个文件操作,谷歌浏览器弹出"xxx想要下载多个文件"的处理方法

    背景:   使用selenium框架,批量下载多个目录的不同文件,而下载多个文件时,浏览器会弹出如下窗口 解决方案有2个:1.代码定位到元素并点击[允许].2.修改浏览器的设置,使其能够拥有自动下载的 ...

  7. Java高级助教工作总结

    一.助教工作的具体职责和任务 1.帮助老师在云班课上发布作业 2.解答同学们的问题 3.批改同学们的作业,并了解同学们的学习情况 4.在qq群中发布通知,收集同学们的一些意见 二.助教工作的每周时长和 ...

  8. noi 45 金币

    noi 45 金币 1.描述 国王将金币作为工资,发放给忠诚的骑士.第一天,骑士收到一枚金币:之后两天(第二天和第三天)里,每天收到两枚金币:之后三天(第四.五.六天)里,每天收到三枚金币:之后四天( ...

  9. Android移动端性能测试工具mobileperf

    简介:mobileperf是阿里开源的一个python PC 工具,可以收集Android性能数据: cpu.内存.流畅度.fps.logcat日志.流量.进程线程数.进程启动日志,mobileper ...

  10. 滚动 Scroller OverScroller

    原文:https://www.baidu.com/link?url=26iKhqGV7w87fqTiCTCwQc3VPcCbedUpAlddWm3uHsEXAGaeH47xY8QCZNGcORGBAU ...