admin管理员组文章数量:1416625
So Kafka client's for consuming messages uses poll()
which along with the heartbeat is what makes the broker decide if a client is still alive.
What is not clear to me is if the poll()
and heartbeat are sent over persistent network connections or each poll()
or heartbeat are creating a new tcp connection each time.
I would assume the connections would be persistent but would that mean that for a broker with several thousands of consumers there would be several thousands of open tcp connections (most of them potentially idle if the consumer is doing some event processing)?
So Kafka client's for consuming messages uses poll()
which along with the heartbeat is what makes the broker decide if a client is still alive.
What is not clear to me is if the poll()
and heartbeat are sent over persistent network connections or each poll()
or heartbeat are creating a new tcp connection each time.
I would assume the connections would be persistent but would that mean that for a broker with several thousands of consumers there would be several thousands of open tcp connections (most of them potentially idle if the consumer is doing some event processing)?
1 Answer
Reset to default 1Consumers keep persistent connections to all brokers they are fetching data and keep a separate connection to their consumer group coordinator, even if it's also a broker they are already fetching data from. In the node metrics the connection to the coordinator has the node attribute set to -1
.
In most cases establishing a new connection is expensive, so Kafka clients try to reuse existing connections and keep connections they are actively using.
Connections that are idle are automatically closed after connections.max.idle.ms
which is 9 minutes by default.
Consumers use the coordination connection to send their heartbeats. While heartbeats are small, they happen every heartbeat.interval.ms
which is 3 seconds by default.
So yes, if you have thousands of consumers (or other Kafka clients) connected to your cluster, each broker can have thousands of network connections.
It's often recommended to monitor the number of connections (and the creation, closure rate) of your clusters. Both Kafka clients and brokers expose these metrics. See https://kafka.apache./documentation/#selector_monitoring
本文标签:
版权声明:本文标题:Does a kafka broker keep persistent tcp connections with all of the consumers in all the groups? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745256554a2650138.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论