本文介绍了Spring Boot Actuator 指标 mem 和 mem.free的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在通过 /metrics 端点公开的 Spring Boot 指标中,memmem.free 是什么意思?

What is the meaning of mem and mem.free in Spring Boot metrics exposed via /metrics endpoint?

我们正在对部署在三个节点上的新 Spring Boot 微服务进行负载测试,mem 在 VM 的 4G 总量中,每个盒子的 mem 始终在 250M 左右,mem.free 下不切实际的负载像正常负载的100倍可以降到15M,测试后慢慢恢复.

We are load testing a new Spring Boot microservice deployed in three nodes, mem for each box is always around 250M out of 4G total in VM, mem.free under unrealistic load like 100 times of normal load can go down to 15M and slowly recovers after the test.

它们不是堆内存,因为 Spring Boot Metrics 单独报告它们,它们不是 Java 进程本身,因为从命令行我可以看到无论负载有多大,它都保持在 4G 的 16%,大约 900MB.这是/metrics 调用响应片段:

They are not heap memory because Spring Boot Metrics report them separately and they are not Java process itself because from command line I can see no matter how big the load, it stays at 16% of 4G which is about 900MB. Here is /metrics call response snippet:

{
    mem: 227657,
    mem.free: 44280,
    processors: 2,
    instance.uptime: 80393579,
    uptime: 80414405,
    systemload.average: 0.03,
    heap.committed: 133632,
    heap.init: 61440,
    heap.used: 89351,
    heap: 872448,
    nonheap.committed: 96688,
    nonheap.init: 2496,
    nonheap.used: 94025,
    nonheap: 0,
    threads.peak: 109,
    threads.daemon: 34,
    threads.totalStarted: 183,
    threads: 63,
    classes: 10079,
    classes.loaded: 10155,
    classes.unloaded: 76,

....}

Grafana mem.free 过去 24 小时的屏幕截图,最低点是在高负载测试期间(15MB!)

Grafana mem.free screenshot for last 24 hours, the lowest point is during that heavy load testing (15MB!)

Grafana cpu 和内存使用情况报告如下所示,它告诉我在此期间 CPU 处于压力之下,这是可以理解的.但是,Java 进程内存(在该框中仅运行 1 个 Spring boot)是稳定的:

Grafana cpu and memory usage report is shown below which tells me CPU under stressed during that period which is understandable. However Java process memory (only 1 Spring boot running in that box) is stable:

那么,Spring Boot 指标中 memmem.free 的含义是什么?

So again what is the meaning of mem and mem.free in Spring Boot metrics?

推荐答案

mem 是 JVM 当前正在使用的内存总量.它是两个值的总和:

mem is the total amount of memory that the JVM is currently using. It is the sum of two values:

来自

The value of getUsed() from MemoryMXBean.getNonHeapMemoryUsage()

mem.free 是可供 JVM 使用的内存量.这是一个单一的值:

mem.free is the amount of memory that's available to the JVM. It's a single value:

要查看更多详细信息,请查看 Spring Boot 的 SystemPublicMetrics 类.

To see more of the details, take a look at Spring Boot's SystemPublicMetrics class.

这篇关于Spring Boot Actuator 指标 mem 和 mem.free的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 23:29