Zookeeper zk_max_latency如何计算? [英] How is Zookeeper zk_max_latency calculated?

查看:134
本文介绍了Zookeeper zk_max_latency如何计算?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚删除了我的动物园管理员的一些数据……

Hi I just took some stats off my zookeeper...

您可以看到zk_max_latency很高.但这是曾经达到的最大值还是始终是当前值?

As you can see zk_max_latency is quite high. But is that the maximum it ever reached or is it always the current value?

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

推荐答案

zk_max | avg | min_latency 指标是从ZK服务器启动开始计算的.

The zk_max|avg|min_latency metric is calculated starting from ZK server startup.

mntr 命令由

The mntr command is handled by MonitorCommand, which query the max/avg/min request metrics from 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

ServerStats.java

// getters
public long getMinLatency() {
    return requestLatency.getMin();
}

public double getAvgLatency() {
    return requestLatency.getAvg();
}

public long getMaxLatency() {
    return requestLatency.getMax();
}

并且请求延迟在 AvgMinMaxCounter .

And the request latency is updated at ServerStats.updateLatency(). The core implementation class is 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);
    }
}

这篇关于Zookeeper zk_max_latency如何计算?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆