Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find biggest values in Redis - currently using too much memory [duplicate]

Tags:

redis

I have a redis instance which keeps growing in memory to the point where something is clearly going wrong with my application logic, I have tens of thousands of keys and want to find out which are the bigest users of memory. Is there a know technique to solve this?

like image 654
henry.oswald Avatar asked Nov 04 '22 06:11

henry.oswald


1 Answers

I'd think that the way to go is not finding which of your keys are the biggest, but what characteristics do your keys have - i.e. what sort of data they hold.

Redis is not a replacement for a relational database, it is a complementary tier (very important and usefuly but still complementary). You use it to accelerate access to data in your application in various ways. That means that at the end of the day, Redis should probably not include everything but only the most frequently used data, and/or general statistics and aggregations.

I don't know your application's domain, but try looking for expiration for keys, for the beginning. Keys that are infrequently accessed should eventually be deleted.

As a further step I would check for redundant keys, that is - the same data being saved in multiple forms.

Note: There is absolutely nothing wrong with redundancy in Redis, in fact that's a recommended pattern to go with (use Redis without normalization, in favor of speed of access for every given query). All I'm suggesting is that you might find some classes of keys that are completely useless given other ones, i.e. they don't add any speed advantage and just inflate your Redis database.

Try have a look at some Redis GUI applications that might assist you exploring your runtime Redis instance:

  • http://blog.freeflow.io/reddish-a-better-visual-admin-for-redis
  • http://code.google.com/p/redis-admin/
  • Redis Admin UI
like image 54
Ofer Zelig Avatar answered Jan 04 '23 15:01

Ofer Zelig