0%

ZooKeeper 客户端连接数

配置参数将限制连接到 ZooKeeper 的客户端的数量,限制并发连接的数量


前言

Zookeeper 容易出现连接数暴增事件,因此可以通过相应的配置来限制某 IP 的连接数

配置

maxClientCnxns

Limits the number of concurrent connections (at the socket level) that a single client, identified by IP address, may make to a single member of the ZooKeeper ensemble. This is used to prevent certain classes of DoS attacks, including file descriptor exhaustion. The default is 60. Setting this to 0 entirely removes the limit on concurrent connections.

翻译过来就是将单个客户端(通过IP地址标识)可以与ZooKeeper集成中的单个成员建立的并发连接数(在套接字级别)受到限制。 这用于防止某些类的DoS攻击,包括文件描述符耗尽。 默认值为60。将其设置为0将完全消除并发连接的限制。

需要明确地是这个限制的使用范围,仅仅是单台客户端机器与单台ZK服务器之间的连接数限制,不是针对指定客户端ID,也不是ZK集群的连接数限制,也不是单台ZK对所有客户端的连接数限制。

如果某 IP 连接数过多会报如下错误

1
2011-10-28 09:39:44,856 – WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:5858:NIOServerCnxn$Factory@253] – Too many connections from /172.*.*.* – max is 60

参考链接