Skip to content

Use Pickle+zlib When Applicable #29

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jamescarr
Copy link
Contributor

The log message was off a bit when just passing the value to str(). This approach uses the actual way it is done under the hood.

…wise a call to __str__ may return something quite different! Also accounts for compression
@jwhitlock
Copy link
Member

I'm trying to understand the need for this change. I'm guessing that something like this happened:

  • You are storing something big, like complete HTML pages, in memcached
  • You hit the 1 MB limit on cached values
  • You tried compression to get below the limit, but it didn't completely fix the problem,
  • You want to know how close to 1 MB you are with compression.

Is this accurate, or did you have another need for this change?

@jamescarr
Copy link
Contributor Author

Nope that was it, we were getting a lot of errors and couldn't pinpoint why. Adding this to the logs allowed us to know which keys were too big.

I'm actually fine with closing this PR as we actually swapped to pymemcache for other reasons and our in-house django wrapper for it just rejects objects over 1MB after compressed.

@jwhitlock
Copy link
Member

I like the idea of the commit, since the 1 MB limit is not commonly known, and serialization + compression makes it hard to see exactly when it happens. I'd prefer that pylibmc raises a more specific error that includes the size of the serialized value. It looks like a libmemcached change might be making this harder than it seems.

@jamescarr
Copy link
Contributor Author

Right... until I added this for our fork we were getting a plethora of timeouts caused by sending super large values to memcached. We had no way of knowing, but it turned out our blog posts were attempting to cache 6MB of compressed data because the pickle call was invoking all() on a django model. Adding this helped better identify what was causing problems.

@jwhitlock
Copy link
Member

lericson/pylibmc#184 has been fixed with a code change, so there may be some more options here.

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

Successfully merging this pull request may close these issues.

2 participants