Sabtom
Sabtom

Reputation: 41

How does ElasticSearch calculate memory pressure?

We have a couple of Java services that we would like to add monitoring/alarms to.

We were collecting memory usage information from the JVM. Then, we noticed that ElasticSearch has a metric called memory pressure which sounds like a useful metric for our Java services as well.

The problem is that I can't figure out how it works. I've tried searching for "memory pressure" in the code on their GitHub, to no avail.

When I try to search for the formula or an explanation of how it calculates this, I somehow always end up finding the same two articles: Understanding the Memory Pressure Indicator and JVM memory pressure indicator.

Those nicely explain how to interpret the values ElasticSearch calculates, but not how it calculates it.

Does anyone know how the ElasticSearch memory pressure calculation works under the hood?

Upvotes: 4

Views: 1138

Answers (1)

Val
Val

Reputation: 217594

As mentioned on the third link you referenced:

the JVM memory pressure indicator is actually the fill rate of the old generation pool

So it's simply the percentage of the old pool usage

When retrieving the GET _nodes/stats you'll get the following information regarding the JVM metrics:

  ...
  "jvm" : {
    "timestamp" : 1614957874986,
    "uptime_in_millis" : 274397434,
    "mem" : {
      "heap_used_in_bytes" : 20094897664,
      "heap_used_percent" : 65,
      "heap_committed_in_bytes" : 30836523008,
      "heap_max_in_bytes" : 30836523008,
      "non_heap_used_in_bytes" : 310525488,
      "non_heap_committed_in_bytes" : 321077248,
      "pools" : {
        "young" : {
          "used_in_bytes" : 6710886400,
          "max_in_bytes" : 0,
          "peak_used_in_bytes" : 12264144896,
          "peak_max_in_bytes" : 0
        },
        "old" : {
          "used_in_bytes" : 13098798592,
          "max_in_bytes" : 30836523008,
          "peak_used_in_bytes" : 14881037312,
          "peak_max_in_bytes" : 30836523008
        },
        "survivor" : {
          "used_in_bytes" : 285212672,
          "max_in_bytes" : 0,
          "peak_used_in_bytes" : 1300234240,
          "peak_max_in_bytes" : 0
        }
      }
    },

So the memory pressure is simply computed with the following formula:

100 * jvm.mem.pools.old.used_in_bytes / jvm.mem.pools.old.max_in_bytes 

Which in my case yields 42% and can be seen on the following screenshot

enter image description here

Upvotes: 6

Related Questions