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

Backend-level expiration / resource deallocation #230

Open
sermoz opened this issue Nov 21, 2022 · 2 comments
Open

Backend-level expiration / resource deallocation #230

sermoz opened this issue Nov 21, 2022 · 2 comments

Comments

@sermoz
Copy link

sermoz commented Nov 21, 2022

Can someone please either confirm or refute my understanding: unless I specify the arguments.memcached_expire_time config option, the keys/values never actually expire in the Memcached itself. It's just that Dogpile considers them expired by checking the expiration times, but actual data don't get deallocated from the underlying Memcached storage (which is RAM). This is probably also true for other backends.

I'm actually concerned about resource deallocation by Memcached. And I guess the reason that the current behavior does not lead to (m)any complaints/problems in practice is that Memcached is typically configured with some memory limit, and when it's reached it's just starting to evict old keys.

So, to summarize it: under typical configuration of Dogpile (no arguments.memcached_expire_time specified), cached data is not deleted from Memcached leading to more resource usage than with that config option set to a reasonable timeout.

(Of course, I'm assuming that we're not calling cache_region.delete() explicitly.)

@jvanasco
Copy link
Member

jvanasco commented May 4, 2023

Yes, that is basically what happens with memcahed and most other backends.

If you set memcached_expire_time for a region, Dogpile will explicitly tell memcached to expire/evict the key after that time. If that arg is unset, you are implicitly telling memcached to handle evicting the keys as it sees fit - which will be based off it's own LRU logic.

Dogpile essentially caches data in the form of:

key -> serialized({metadata:{expiry=foo}, value=data})

The metadata contains an expiry, because not all backends support expiry and there are some edge situations where you need the expiry in Python.

If you want to play with performance, you can use custom serializers and classes to change various features.

@sermoz
Copy link
Author

sermoz commented Feb 5, 2024

@jvanasco Thanks for reply!

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

No branches or pull requests

2 participants