Cool Tools: Redis Keys Statistics

What do you do when your ElastiCache cluster’s evictions start spiking and it starts deleting key/value pairs?
In a previous post I talked about an Redis Eviction Nightmare I had encountered recently. In this post I will give you a tool to help diagnose these issues.
Enter RKS:
As its name implies Redis Key Statistics or “RKS “ gives you statistics about what keys are being stored in Redis. This includes finding the keys with values that are taking up the most memory, getting counts of various keys by type, and prefix statistics (This is my favorite).
It can achieve insane performances because it uses Lua scripts running close to the metal.
How I have used it:
When Evictions start to spike you want to know a few things:
- What are the biggest keys?
- Which key pattern/prefix has the most keys?
- Which key pattern/prefix is growing the fastest?
The 3rd one can be found manually by just taking a series of snap shots and looking at which ones are increasing or decreasing.
It’s also a great tool to use when “it” is not hitting the fan. Sometimes I need to do cost estimations for a client and knowing what keys are being used and how, allows me to design better solutions. Just knowing the key type can help me know if I can scale a cluster horizontally vs vertically so it pays dividends to know this stuff up front.
Questions For You:
How are you tracking what key/value pares make up your data in your ephemeral storage?
Do you have any other tools for this?