在测试设置中(单个客户端服务器 - 运行Gatling的localhost,在测试期间创建和关闭连接)我的单个节点Zookeeper会保持所有TCP连接处于打开状态,直到测试运行完成。
在前2分钟的测试运行期间,我重复创建多达10个并行的客户端连接,这些连接活动大约30秒,然后再次关闭它们的连接。因此,在任何一个时刻,前2分钟内最多有10个连接处于活动状态。 然后测试继续进行另外8分钟,在此期间只有1个客户端连接处于活动状态。
客户端:使用Curator 2.9.1和Zookeeper 3.4.6
Zookeeper节点:3.4.8-1--1
AFAIK客户端正确关闭其连接(证据:我看到它的短暂节点在执行ls / path / to / ephemerals时被删除,zookeeper日志也表示已关闭的连接)
但是,当将 cons 命令发送到zookeeper节点时,TCP连接数在前2分钟内持续上升,最多为126个。然后保持该数字直到testrun已经完成,此时所有连接都已消失。
我预计连接数会更低,例如10到20,并且在“活动”期间保持稳定。测试阶段。相反,只要我打开/关闭新连接,它就会不断上升。
在最初的2分钟内,zookeeper日志显示了打开和关闭连接:
2016-03-25 15:54:04,305 - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:12182:NIOServerCnxnFactory@192] - Accepted socket connection from /0:0:0:0:0:0:0:1:60758
2016-03-25 15:54:04,321 - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:12182:ZooKeeperServer@900] - Client attempting to establish new session at /0:0:0:0:0:0:0:1:60758
2016-03-25 15:54:04,324 - INFO [SyncThread:0:ZooKeeperServer@645] - Established session 0x153ae440b2e000f with negotiated timeout 10000 for client /0:0:0:0:0:0:0:1:60758
2016-03-25 15:54:04,324 - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:12182:ZooKeeperServer@924] - got auth packet /0:0:0:0:0:0:0:1:60758
2016-03-25 15:54:04,325 - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:12182:ZooKeeperServer@958] - auth success /0:0:0:0:0:0:0:1:60758
2016-03-25 15:54:04,326 - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:12182:ZooKeeperServer@924] - got auth packet /0:0:0:0:0:0:0:1:60758
2016-03-25 15:54:04,328 - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:12182:ZooKeeperServer@958] - auth success /0:0:0:0:0:0:0:1:60758
2016-03-25 15:54:04,803 - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:12182:NIOServerCnxnFactory@192] - Accepted socket connection from /127.0.0.1:37236
2016-03-25 15:54:04,804 - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:12182:ZooKeeperServer@900] - Client attempting to establish new session at /127.0.0.1:37236
2016-03-25 15:54:04,805 - INFO [SyncThread:0:ZooKeeperServer@645] - Established session 0x153ae440b2e0010 with negotiated timeout 10000 for client /127.0.0.1:37236
2016-03-25 15:54:04,828 - INFO [ProcessThread(sid:0 cport:12182)::PrepRequestProcessor@489] - Processed session termination for sessionid: 0x153ae440b2e0010
2016-03-25 15:54:04,830 - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:12182:NIOServerCnxn@1008] - Closed socket connection for client /127.0.0.1:37236 which had sessionid 0x153ae440b2e0010
然后,仅在运行结束时,我看到每个连接
2016-03-25 15:57:44,002 - INFO [SessionTracker:ZooKeeperServer@355] - Expiring session 0x153ae440b2e006c, timeout of 10000ms exceeded
2016-03-25 15:57:44,003 - INFO [SessionTracker:ZooKeeperServer@355] - Expiring session 0x153ae440b2e00b8, timeout of 10000ms exceeded
2016-03-25 15:57:44,003 - INFO [SessionTracker:ZooKeeperServer@355] - Expiring session 0x153ae440b2e0094, timeout of 10000ms exceeded
...
2016-03-25 15:57:44,014 - INFO [ProcessThread(sid:0 cport:12182)::PrepRequestProcessor@489] - Processed session termination for sessionid: 0x153ae440b2e006c
2016-03-25 15:57:44,014 - INFO [ProcessThread(sid:0 cport:12182)::PrepRequestProcessor@489] - Processed session termination for sessionid: 0x153ae440b2e00b8
2016-03-25 15:57:44,015 - INFO [ProcessThread(sid:0 cport:12182)::PrepRequestProcessor@489] - Processed session termination for sessionid: 0x153ae440b2e0094
...
(请注意,上面的日志来自手动中断的运行,但如果我让运行完成到16:02则行为相同)
我正在运行以下配置(摘录):
tickTime=2000
maxSessionTimeout=10000
minSessionTimeout=4000
maxClientCnxns=0
与测试设置相关的连接数量是否增加,或者Zookeeper的运行方式是固有的?
答案 0 :(得分:0)
原来这是我们客户端代码中的错误。连接没有正确关闭,只有一半的清理完成(短暂的节点被删除了,但客户端连接实际上并没有真正关闭)。
抱歉占用你的时间。