How would I go about predicting memory usage of sorted set in redis?
Asked Answered
G

0

6

I'm trying to forecast memory usage on my Redis (v6.2.5) cluster when using sorted sets. From my initial research I can tell that the length of the key, the length of each individual element, and the length of each individual score has an impact on memory usage.

Here is what I have so far:

  • Using a key between 1 and 8 characters, an element with length 1, and a score with length 1, I see that 63 bytes of memory are used.
  • A 9-character key increases the memory usage by 8 bytes (71 bytes)
  • An 8 character key, 8 character element, and 1 character score increases usage by 4 bytes (75 bytes)
  • An 8 character key, element, and score increases usage by another 4 bytes (79)

I can kind of see a pattern, but I'm hoping a Redis guru can help me make sense of this either in the source code or through an explanation of the implementation of sorted sets in Redis.

FWIW, I found this which shows that scores are stored as char arrays with length of 128. https://github.com/redis/redis/blob/c5e6a6204c4cf57f85e7c83a9b4e99f1a7204fd2/src/t_zset.c#L1029

Any help is appreciated.

Germiston answered 26/10, 2021 at 21:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.