Expiry or Eviction logs

Hi All,

We are facing an issue where some API calls (connecting to our redis DB) are slow during the time there is decline in number of redis keys. We suspect these are due to expiry or eviction. We need to find out any logs which show the logs for this action and if possible which alogorithm i.e. KEYS,SCAN etc. was used to trigger this Eviction/Expiry

Thanks in advance,
Mandar

Hi @mandara,

Hope all is well. Sorry for not getting back to your question sooner. Have you resolved this issue?

No Not yet. Can anyone help on this one?

@mandara

A couple of questions and some observations so that we can better help you figure this one out:

  • Assuming you are using Redis as your cache, what framework/language are you using and how is the cache configured?
  • You are right that it is likely the TTL (time to live) of the keys being cached. Find out what the TTL is for new cache entries (see TTL – Redis)
  • One quick way to find out what the TTL is would to use the Redis CLI and issue a TTL mykey for one of the keys in the cache
  • Is your Redis instance configured to persist the data to disk? If so, is it RDB or AOF?
  • if not, check if your company has a policy to bounce/restart machines on a schedule. If your cache is not persistent that would produce 100% misses after a server restart :slight_smile:
  • Also, depending on how you are creating those keys you might be getting cache misses for queries/API calls that you should be hits
1 Like

…and as far as I know there are no expiry or eviction logs in Redis. You would have to track something like that yourself with Redis Gears maybe?

1 Like

Back tracking a bit here, there seems to be notifications you can listen to Redis Keyspace Notifications – Redis see:

x     Expired events (events generated every time a key expires)
e     Evicted events (events generated when a key is evicted for maxmemory)
1 Like

but for CRDB I dont think eviction happens when memory is full

Still I am going to test this keyspace notifications