-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Proposal: support insert key with expire time? #231
Comments
I forgot to mention, but until the per-key TTL is implemented, you could workaround by using
Note that the You may want to check an actual usage by another user: #227 (comment) A difference between the real per-key TTL and this workaround is:
|
Got it, thanks. Maybe I can try to implement the real per-key TTL when I'm available. |
@tatsuya6502 I have found that the workarounds are not suitable for my scenario. When the cache is full, new keys cannot be inserted because expired keys cannot be cleared in time. Does it take a lot of work to implement the real per key? Desperately needed! |
That is right. Another workaround is to use
I would say it will take a week or two if I can work on it 2 hours a day after work.
I was a bit busy recently and could not done anything for Moka in the past few weeks. I am hoping to get back to it soon, but I still have other things to do in Moka before I can start working on this. I will let you know when I make some progress, e.g. when I finish 1-a to 1-d so you can start to play with it. |
Does your workload have a high insertion rate all the time (e.g. more than 1500 insertions/sec)? and also does the cache have the max capacity configured? If so, eviction rate (for evicting expired entries) may not catch up with the insertion rate, and the cache will eventually become full although there are expired entries. Once the cache is full, the hit rate can drop if the admission policy is not suitable for your workload. You could check if this is the case by tracking As of Moka v0.10.0, the eviction rate is hard-corded and maybe it is too small. Maybe I will make it larger and/or configurable. In the future, I think the cache should be able to calculate the eviction rate based on the insertion rate and the cache capacity. |
I don’t have metrics on the The capacity is intentionally conservative, as we are storing open |
I see. So your cache will be full in a few seconds, and having slow eviction rate of expired entries will not explain why the performance / hit rate is slowly decreasing over time. Other aspects that will change the hit rate will be:
With the current information, it will be hard to identify the root cause. It will be very helpful if we can get access trace data from the production system. Access trace data can be a CSV file, and each line should have the following information:
Once we have such trace, we can replay it to reproduce the issue and investigate the root cause. |
FYI, I started to work on this feature a few days ago: #248 I am implementing hierarchical timing wheels now.
|
No, this is not that critical for us, and we are very happy with how the cache is performing in general. I will rather wait for proper per-entry TTL support instead of putting more effort into workarounds for that. |
@phantomhker @Swatinem @Millione Just FYI, after finish implementing this feature (per-entry TTL), I will implement Window-TinyLFU admission/eviction policy, which would improve cache hit rate for some kinds of workloads.
I created #249 to track the development of Window-TinyLFU. I also updated the roadmap. |
Maybe you are doing blue/green deployment and traffic will be slowly shifted to the fresh instance during a day? (e.g. AWS CodeDeploy (doc)) Having more traffic could decrease the hit rate as more cache keys will be used by different requests. It will have the same effect to reduce the cache capacity. |
OK. It is not quite ready for a release yet, but you can start to play with it. See: #248 (comment) |
Just FYI, I just published moka v0.11.0 to crates.io. |
Hi @phantomhker,
FYI, @Swatinem reported the problem they were observing was fixed by You might be affected by the same issue, so please try the latest version ( |
Now moka has a global expire time for all keys, can we insert key with expire time to make some keys different?
The text was updated successfully, but these errors were encountered: