嗨,我刚刚删除了我的动物园管理员的一些数据……
您可以看到zk_max_latency很高。但这是曾经达到的最大值还是总是当前值?
echo mntr | nc localhost 2181
zk_version 3.4.13-2d71af4dbe22557fda74f9a9b4309b15a7487f03, built on 06/29/2018 04:05 GMT
zk_avg_latency 0
zk_max_latency 4738
zk_min_latency 0
zk_packets_received 2387852
zk_packets_sent 2387928
zk_num_alive_connections 29
zk_outstanding_requests 0
zk_server_state follower
zk_znode_count 7973
zk_watch_count 74
zk_ephemerals_count 22
zk_approximate_data_size 12356979
zk_open_file_descriptor_count 62
zk_max_file_descriptor_count 16384
zk_fsync_threshold_exceed_count 2
答案 0 :(得分:2)
zk_max|avg|min_latency
指标是从ZK服务器启动开始计算的。
mntr
命令由MonitorCommand处理,该命令从ZooKeeperServer.serverStats.requestLatency查询最大/平均/最小请求指标
ZKDatabase zkdb = zkServer.getZKDatabase();
ServerStats stats = zkServer.serverStats();
print("version", Version.getFullVersion());
print("avg_latency", stats.getAvgLatency());
print("max_latency", stats.getMaxLatency());
print("min_latency", stats.getMinLatency());
ServerStats.java
// getters
public long getMinLatency() {
return requestLatency.getMin();
}
public double getAvgLatency() {
return requestLatency.getAvg();
}
public long getMaxLatency() {
return requestLatency.getMax();
}
并且请求延迟更新为ServerStats.updateLatency()。核心实现类为AvgMinMaxCounter。
public void updateLatency(Request request, long currentTime) {
long latency = currentTime - request.createTime;
if (latency < 0) {
return;
}
requestLatency.addDataPoint(latency);
if (request.getHdr() != null) {
// Only quorum request should have header
ServerMetrics.UPDATE_LATENCY.add(latency);
} else {
// All read request should goes here
ServerMetrics.READ_LATENCY.add(latency);
}
}
答案 1 :(得分:0)
zk_max_latency : 该ZooKeeper服务器处理请求所花费的最长时间(以毫秒为单位)。
不,这是从上次重启ZooKeeper服务器以来测得的。