Skip to content
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

Define cache size limit #49

Closed
emerleite opened this issue Jul 20, 2016 · 13 comments
Closed

Define cache size limit #49

emerleite opened this issue Jul 20, 2016 · 13 comments
Assignees

Comments

@emerleite
Copy link

I guess we should have a way to determine cache size limit, to avoid reach server RAM limit. I could not find any options to define this.

@whitfin
Copy link
Owner

whitfin commented Jul 20, 2016

@emerleite I've been considering this for a while, but I don't know an efficient way to trim the size, and on what grounds.

The most obvious is LRU, but that requires a sorted table in order to easily determine use time. Any ideas? Perhaps LFU should also be an option... that seems to make the most sense in context.

In the meantime, just set TTLs on your keys - that should be an easy workaround.

@whitfin
Copy link
Owner

whitfin commented Jul 20, 2016

Further thinking on this makes me feel that we can implement LRU with a hook. There will naturally be overhead to this, but it can be toggled on/off if you have a clever enough eviction policy. I just need to work out some of the QLC magic behind it.

@whitfin whitfin self-assigned this Jul 20, 2016
@emerleite
Copy link
Author

I set the TTL, but with high throughput, I'm not sure if I'll reach the limit anyway.

@emerleite
Copy link
Author

@zackehh I guess LFU could be better, but we could have a simple option to just rotate, regardless of the policy.

@emerleite
Copy link
Author

I found this project. Do you think we can go through the same aproach? - https://github.com/arago/lru_cache

@whitfin
Copy link
Owner

whitfin commented Jul 20, 2016

@emerleite we can't, because using something like an Agent is a 6x slowdown on all reads against the throughput Cachex has today.

The reason I never added LRU before is simply because it would typically require a write on every read (like that Agent approach). I have an idea, but need to find some time to try an implementation.

@emerleite
Copy link
Author

@zackehh makes sense. But how about just set a limit and remove the first inserted? It's just to not reach system limit.

@whitfin
Copy link
Owner

whitfin commented Jul 20, 2016

@emerleite first inserted is possible, but arguably the things you put in a cache instantly and live the longest are also those which need to be cached the most.

@whitfin
Copy link
Owner

whitfin commented Jul 20, 2016

@emerleite how would you imagine this working in the case where you have a distributed cache?

@whitfin whitfin closed this as completed Jul 20, 2016
@whitfin whitfin reopened this Jul 20, 2016
@emerleite
Copy link
Author

@zackehh not sure. It's true we have to figure out this.

@whitfin
Copy link
Owner

whitfin commented Aug 13, 2016

Coming back to this;

I have a plan to implement this with a hook, but it won't work on a distributed scale (at least I don't think so). I'm going to investigate a way around this in future, perhaps by splitting out the remote caches into their own project.

@whitfin
Copy link
Owner

whitfin commented Aug 14, 2016

@emerleite I opened a new issue in #55. I'm going to close this one but feel free to follow that issue instead.

@whitfin whitfin closed this as completed Aug 14, 2016
@emerleite
Copy link
Author

Coll @zackehh ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants