0

I have the AWS monitoring scripts set up on an EC2 instance to alert me when memory utilization is over 75%. Currently, I am sending all of the memory related parameters to Cloudwatch, but only have a Cloudwatch alert set up for mem-util.

On Cloudwatch, I see a memory utilization of over 97%

However, when running the top command, I get a very different memory utilization of roughly 74%:

Tasks: 101 total,   1 running,  61 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.3 us,  0.0 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  8166940 total,   212124 free,  6232712 used,  1722104 buff/cache
KiB Swap:        0 total,        0 free,        0 used.  1634048 avail Mem 

I saw a similar thread for CPU usage statistic discrepancy, and am wondering if the same issues apply here. More importantly, which of the two is more reliable in the context of managing the available memory?

shingi
  • 3
  • 2
  • 2
    Which of the [memory statistics](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/mon-scripts.html) are you sending to CloudWatch? mem-util, mem-used, or -mem-used-incl-cache-buff? This is a parameter to the scripts. Please edit your question to show the command line, and then reply to the comment so I see it's changed. – Tim May 16 '19 at 07:59
  • I'm using mem-util – shingi May 16 '19 at 14:05

1 Answers1

0

It looks like cloudwatch is counting total memory in use, and top is counting memory is use by processes but not for caches/buffers that can be easily reclaimed.

Which is more appropriate depends on your workload.

rsaxvc
  • 197
  • 6
  • If this ec2 instance has a sole purpose of running a single java app - which by itself accounts for 74% of the usage noted by top - and nothing else is running, which one is a better measure of "available memory" from the standpoint of watching for memory leaks? – shingi May 16 '19 at 14:09
  • Then I would be most interested in the amount of memory used either by that process or all processes, and not the total amount including caches and buffers. – rsaxvc May 17 '19 at 02:00