Redis - Approach for Storing Data Into Redis :: JSON String OR Serialized pojo Redis - Approach for Storing Data Into Redis :: JSON String OR Serialized pojo json json

Redis - Approach for Storing Data Into Redis :: JSON String OR Serialized pojo


You should consider using MessagePack as it is full compatible with Redis and Lua, it is a great compression on JSON: http://msgpack.org/

It implies some Lua code to compress and uncompress, but the cost should be small. Here is an example: http://gists.fritzy.io/2013/11/06/store-json-as-msgpack

There is a small benchmark which lacks data: https://gist.github.com/muga/1119814

Still it should be a great option for you, as you can use it in different languages, fully supported on redis, and it is based on JSON.


The answer is you should measure it for your use cases and environment. I would first try JSON at it's more versatile and less problematic - i.e. easier to debug and restore corrupted data.

Performance. JSON serialization is fast, so in many scenarios it won't be your bottleneck. Most probably it is disk or network IO: java serialization benchmarking. Avoid using default Java serialization as it is slow. Kryo is an option for binary output. If you need miltiple platforms for binary format consider DB's internal format or i.e. Google Protobuffers.

Compression. In Google they use Snappy for less-cpu-demanding compression. Snappy is also used in Cassandra, Hadoop and Hypertable. Some benchmarks for JVM compressors: Compression test using Calgary corpus data set .