How to calculate redis memory used percentage on ElastiCache
Asked Answered
P

4

13

I want to monitor my redis cache cluster on ElastiCache. From AWS/Elasticache i am able to get metrics like FreeableMemory and BytesUsedForCache. If i am not wrong BytesUsedForCache is the memory used by cluster(assuming there is only one node in cluster). I want to calculate percentage uses of memory. Can any one help me to get percentage of Memory uses in Redis.

Parthenon answered 9/12, 2015 at 9:18 Comment(2)
I am looking for the same answer. Do you have any update on it ??Simian
Also looking for an answer!Tauten
B
8

We had the same issue since we wanted to monitor the percentage of ElastiCache Redis memory that is consumed by our data. As you wrote correctly, you need to look at BytesUsedForCache - that is the amount of memory (in bytes) consumed by the data you've stored in Redis. The other two important numbers are

  1. The available RAM of the AWS instance type you use for your ElastiCache node, see https://aws.amazon.com/elasticache/pricing/

  2. Your value for parameter reserved-memory-percent (check your ElastiCache parameter group). That's the percentage of RAM that is reserved for "nondata purposes", i.e. for the OS and whatever AWS needs to run there to manage your ElastiCache node. By default this is 25 %. See https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/redis-memory-management.html#redis-memory-management-parameters

So the total available memory for your data in ElastiCache is

(100 - reserved-memory-percent) * instance-RAM-size

(In our case, we use instance type cache.r5.2xlarge with 52,82 GB RAM, and we have the default setting of reserved-memory-percent = 25%. Checking with the info command in Redis I see that maxmemory_human = 39.61 GB, which is equal to 75 % of 52,82 GB.)

So the ratio of used memory to available memory is

BytesUsedForCache / ((100 - reserved-memory-percent) * instance-RAM-size)
Buttock answered 13/11, 2019 at 14:13 Comment(0)
K
2

By comparing the freeableMemory and bytesUsedForCache metrics, you will have the available memory for the Elasticache non-cluster mode (not sure if it applies to cluster-mode too).

Here is the NRQL we're using to monitor the cache:

SELECT Max(`provider.bytesUsedForCache.Sum`) / (Max(`provider.bytesUsedForCache.Sum`) + Min(`provider.freeableMemory.Sum`)) * 100 FROM DatastoreSample WHERE provider = 'ElastiCacheRedisNode'

This is based on the following:

  • FreeableMemory: The amount of free memory available on the host. This is derived from the RAM, buffers and cache that the OS reports as freeable.AWS CacheMetrics HostLevel
  • BytesUsedForCache: The total number of bytes allocated by Redis for all purposes, including the dataset, buffers, etc. This is derived from used_memory statistic at Redis INFO.AWS CacheMetrics Redis

So BytesUsedForCache (amount of memory used by Redis) + FreeableMemory (amount of data that Redis can have access to) = total memory that Redis can use.

Kelcey answered 31/3, 2020 at 15:22 Comment(0)
C
1

With the release of the 18 additional CloudWatch metrics, you can now use DatabaseMemoryUsagePercentage and see the percentage of memory utilization in redis.

View more about the metric in the memory section here

Cumulus answered 24/6, 2021 at 16:55 Comment(0)
D
0

You would have to calculate this based on the size of the node you have selected. See these 2 posts for more information.

Pricing doc gives you the size of your setup.

https://aws.amazon.com/elasticache/pricing/

https://forums.aws.amazon.com/thread.jspa?threadID=141154

Dilettantism answered 5/3, 2019 at 16:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.