Sentinel (系统自适应保护)基于load的保护为什么没有support container?

ubof19bj  于 2021-11-29  发布在  Java
关注(0)|答案(2)|浏览(276)

SystemStatusListener.java

我们看到cpu usage是support container的,为什么system load average没有support container呢?
多谢!!!

BTW, Google Cadvisor里面可以拿到container的system load average信息: container_cpu_load_average_10s (https://github.com/google/cadvisor/blob/master/docs/storage/prometheus.md)

@Override
    public void run() {
        try {
            OperatingSystemMXBean osBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class);
            currentLoad = osBean.getSystemLoadAverage();

            /*
             * Java Doc copied from {@link OperatingSystemMXBean#getSystemCpuLoad()}:</br>
             * Returns the "recent cpu usage" for the whole system. This value is a double in the [0.0,1.0] interval.
             * A value of 0.0 means that all CPUs were idle during the recent period of time observed, while a value
             * of 1.0 means that all CPUs were actively running 100% of the time during the recent period being
             * observed. All values between 0.0 and 1.0 are possible depending of the activities going on in the
             * system. If the system recent cpu usage is not available, the method returns a negative value.
             */
            double systemCpuUsage = osBean.getSystemCpuLoad();

            // calculate process cpu usage to support application running in container environment
            RuntimeMXBean runtimeBean = ManagementFactory.getPlatformMXBean(RuntimeMXBean.class);
mcvgt66p

mcvgt66p1#

Actually both CPU usage and load metrics haven't supported container env yet. Contributions are welcomed!

8nuwlpux

8nuwlpux2#

hmm...
Dear @sczyh30 , based on my testing result, cpu usage is container aware.

SystemStatusListener.java

相关问题