Redis: Show database size/size for keys

前端 未结 9 1792
青春惊慌失措
青春惊慌失措 2020-12-12 11:26

My redis instance seems to being growing very large and I\'d like to find out which of the multiple databases I have in there consumes how much memory. Redis\' INFO

9条回答
  •  情书的邮戳
    2020-12-12 11:45

    You might find it very useful to sample Redis keys and group them by type. Salvatore has written a tool called redis-sampler that issues about 10000 RANDOMKEY commands followed by a TYPE on retrieved keys. In a matter of seconds, or minutes, you should get a fairly accurate view of the distribution of key types.

    I've written an extension (unfortunately not anywhere open-source because it's work related), that adds a bit of introspection of key names via regexs that give you an idea of what kinds of application keys (according to whatever naming structure you're using), are stored in Redis. Combined with the more general output of redis-sampler, this should give you an extremely good idea of what's going on.

提交回复
热议问题