--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at http://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to a topic in the Google Groups "Redis DB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/redis-db/tF1cIg-bXS0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to redis-db+u...@googlegroups.com.
Note, when I use "active expiry" below I'm referring to the process of periodically sampling keys and expiring them if needed in order to reduce memory used by dead keys (as performed in activeExpireCycle).
Recently I've been fighting quite a bit with various fragmentation and expiry issues in some huge databases. One of the things that could have helped is more aggressive active expiry.
Digging into the active expiry code I noticed at least 5 parameters that can affect how aggressive redis is when performing active expiry:
ACTIVE_EXPIRE_CYCLE_LOOKUPS_PER_LOOP - number of keys to sample and check for expiry before deciding if to continue expiring keys
ACTIVE_EXPIRE_CYCLE_LOOKUPS_PER_LOOP/4 - percentage of expired sampled keys indicating we should continue expiring stuff
ACTIVE_EXPIRE_CYCLE_FAST_DURATION - time limit in per cmd expiry cycle (fast cycle)
ACTIVE_EXPIRE_CYCLE_FAST_DURATION - min interval between fast cycles
ACTIVE_EXPIRE_CYCLE_SLOW_TIME_PERC - time limit in periodic (slow cycle) expiry as percentage of HZ
The design here seems pretty complex and probably stems from the need to balance different use case a performance considerations. I'd really like to get some more insight into what are the general motivations behind this complex design?
What's the purpose of the fast vs slow cycles?
Also the documentation mentions: "This means that at any given moment the maximum amount of keys already expired that are using memory is at max equal to max amount of write operations per second divided by 4." can you explain how this is achieved? In my specific scenario there are roughly 3K wops/sec but many millions of expired keys in memory (so this isn't working in my case).
Additionally because the above parameters are all constants there's no real way to tweak active expiry in runtime. For my case there seems some value in making this more configurable. The easy solution would be to make all 5 constants configurable. But before I go into this, I'd like some feedback about how to best make active expiry configurable. At a high level I want to be able to balance between CPU time spend on active expiry and memory used up by expired keys but given the complexity of the implementation I’m a bit lost at how this can be easily done.
At present, only 25% of your keys with expiration might not be expired when they should. You can slightly reduce this number if you increase the 'hz' value, at the cost of more CPU time spent trying to expire data.