kvrocks icon indicating copy to clipboard operation
kvrocks copied to clipboard

The requirement of two commands for Kvrocks

Open lrb1996 opened this issue 2 years ago • 5 comments

Search before asking

  • [X] I had searched in the issues and found no similar issues.

Motivation

I have a requirement which I hope you dear admins can fix. When we use Redis, we can easily know the memory usage of the specific key by using command "memory usage key " as well as the keyspace hits percentage of the specific key by using command "info". But for Kvrocks, we can't easily get the information by using commands. In conclusion, i'll appreciate it if you can solve this problem. Looking forward to your reply, thank you!

Solution

No response

Are you willing to submit a PR?

  • [ ] I'm willing to submit a PR!

lrb1996 avatar Sep 14 '22 06:09 lrb1996

Do you mean the disk space usage of key? Kvrocks stores its data in disk instead of the memory, so the memory usage of key is meaningless for Kvrocks.

git-hulk avatar Sep 14 '22 10:09 git-hulk

Thanks for your reply. I know that Kvrocks stores its data in disk instead of the memory, but i think it's also necessary to know the size of the specific key accurately, otherwize it may cause the abnormal increment of the cpu percentage or some other related indexes for the machine. As a dba, i need to contact the developers to focus the unusual key as fast as i find unusal indexes mentioned above of machines. So I wonder if there's a fast way to get the size of the specific key (disk space usage of key) clearly like Redis. Thanks.

lrb1996 avatar Sep 14 '22 10:09 lrb1996

Thanks for your clarification. It makes sense to export the value size of the specific key, and it should be possible since the RocksDB has a way to get the approximate size with the prefix if my memory serves.

git-hulk avatar Sep 14 '22 11:09 git-hulk

Thanks for your clarification. It makes sense to export the value size of the specific key, and it should be possible since the RocksDB has a way to get the approximate size with the prefix if my memory serves.

@git-hulk Hi. Maybe u mean GetApproximateSizes. I am willing to do this task. Can you give me some guidance?

tanruixiang avatar Sep 14 '22 15:09 tanruixiang

@tanruixiang sure, thanks for your interest. We want a command like Redis MEMORY USAGE except the usage should be disk space, and as you said we can use GetApproximateSizes to count the approximate size.

So what we need to do is:

  1. implement a command like DISK USAGE key and [SAMPLES count] is no need.
  2. Count the value size directly if the key type is a string, or we need to use GetApproximateSizes to get the key size with a prefix. The prefix should be composed of key and version since we use the version to identify the live subkeys. I think you can have a look at How Kvrocks Design Complex Structure On Rocksdb and come back to discuss if you still don't know how to do that.

git-hulk avatar Sep 14 '22 16:09 git-hulk