-
Notifications
You must be signed in to change notification settings - Fork 702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NEW] keyspace_expiration_misses
stats
#1507
Comments
One small issue I have with this proposal is that it does not play well when active expiry is enabled. When enabled, the engine might handle active expiration is changing efficiency and the user tracking this metric might get the wring insight about his application access patterns. given said that I do not have a strong objection tracking this metric, but would it be so much different than tracking the lazy-expired key events? |
Yes, you are right. So user carefully interpret the stat in context with:
User can form a comprehensive view of how many keys are truly missed by the application due to unexpected TTL expiry. Based on the stat, user can tune TTL setting or
keyspace expired event can be generated from active expiry and passive expiry both. we can get more deeper insight to expired items using the stat and keyspace expired event. |
I am not sure how well a user can achieve that from what you just mentioned. Users are mostly better off not touching the hz config and I cannot understand how this can be deducted from the expired_keys, keyspace_misses, application’s read patterns or overall eviction policy.
I know. what I meant was if only adding a statistic for lazy-expired keys would not be good enough (although it will also capture the expired on writes). IMO this might be more helpful statistic. |
Ah, now I see. Yes you are right. Stat is not enough. lazy expired keyspace event should come with the stat. |
@ranshid |
The problem/use-case that the feature addresses
In large-scale caching systems, passive expiration of keys can cause unexpected cache misses, resulting in unnecessary performance degradation. The current
keyspace_misses
metric in Valkey tracks all key misses, but it does not distinguish between misses due to expired keys and misses due to non-existent keys.This lack of distinction makes it difficult for users to identify whether their cache misses are primarily caused by TTL settings or application-level key access patterns. Without visibility into passive expiration misses, users cannot optimize their TTL values effectively or adjust eviction policies to reduce unnecessary misses.
The
keyspace_expiration_misses
metric will provide better observability by tracking how many cache misses are specifically due to passive expiration. This will help users:Description of the feature
The feature introduces a new metric called
keyspace_expiration_misses
, which counts the number of key misses caused specifically by passive expiration.The new metric will be tracked in the
lookupKey()
function in the Valkey codebase. When a key is found to be expired during a lookup, thekeyspace_expiration_misses
counter will be incremented. This will allow users to distinguish between expiration misses and other types of misses when inspecting Valkey'sINFO stats
output.Example output from the
INFO stats
command after the feature is implemented:Key changes in Valkey codebase:
lookupKey()
to incrementkeyspace_expiration_misses
.INFO stats
output to include the new metric.Additional information
Potential Next Steps:
Once
keyspace_expiration_misses
is implemented, a future enhancement could include tracking the distribution expiration gap (the time difference between now and the expiration time when a key is passively expired). This would provide deeper insights into whether keys are being accessed just after they expire or long after they are no longer relevant.The text was updated successfully, but these errors were encountered: