HACKER Q&A
📣 eeegnu

Are there any tools for optimal data compression over multiple messages?


To clarify, consider that a single long message can efficiently and losslessly be compressed with methods such as a huffman encoding. But when sending many small messages, you may lose out on a broader encoding that both sides can use which would in the long pay off.

For example say that I know my application and the user should only ever communicate N different things, and one at a time. I could manually map each of these to an integer and only allow the payload to be an integer. But it feels like allot of extra work for something that could better just be built into the protocols configuration, and maybe set up by presenting it with a common usage list of your typical messages. Does something like this exist?


  👤 Matthias247 Accepted Answer ✓
For mapping of commands to integers you can use commonly available serialization libraries and schemas. E.g. using protocol buffers you can describe all your datatypes as enums, and it will only send integers around.