python - What's the best serialization method for objects in memcached? -


This API uses Python's native resident and Python objects to de-serialize.

This API makes nested Python inventory, dictionary and tuples easier to store and store in a memcatch, and reading these objects back in the application is completely transparent - it just works.

But I do not want to be limited to using only python, and if all the memkach objects are sorted with pickle, the client written in other languages ​​will not work.

Here are the cross-platform serialization options I've considered:

  1. XML - The main advantage is that it is human-readable, but it is not important in this application . XML also takes a lot of space, and it's expensive to parse. JSON - looks like a good cross-platform standard, but I'm not sure that the object type is read back to the character from Memcached, for example, according to the Tupley use. When switching to lists is done; Also, it seems that adding elements of JSON structure can break the code written to the old structure

  2. - I am very interested in it because it looks very fast and compact - at least Less smaller than 10 times faster than XML; It is not human-readable, but it is not important for the app;

Considering the priorities for this app, what is the ideal object serialization method for memcached?

  • Cross-platform support (Python, Java, C #, C ++, Ruby, Pearl)

  • Nested data structures
  • Faster serialization /
  • Minimum memory footprint

  • Flexibility to change structure without breaking old code
  • < I tried a number of methods and compressed JSON as the best balance between speed and memory footprint.

    I see the 3: 1 compression so that all data gets fit in the memos and the app has sub-page rendering -10 ms response time.

    Here JSON, thrift, protocol buffers and YAML are being compared, without compression:

    It looks as if I did the test I did with compressed JSON Since I do not have to pre-define every structure, it seems like the fastest and smallest cross-platform answer.


    Comments