Compressing/compacting messages over websocket on Node.js

Posted by icelava on Programmers See other posts from Programmers or by icelava
Published on 2013-11-13T01:58:10Z Indexed on 2013/11/13 4:11 UTC
Read the original article Hit count: 270

Filed under:
|
|

We have a websocket implementation (Node.js/Sock.js) that exchanges data as JSON strings. As our use cases grow, so have the size of the data transmitted across the wire. The websocket protocol does not natively offer any compression feature, so in order to reduce the size of our messages we'd have to manually do something about the serialisation.

There appear to be a variety of LZW implementations in Javascript, some which confuses me on their compatibility for in-browser use only versus transmission across the wire due to my lack of understanding on low-level encodings. More importantly, all of them seem to take a noticeable performance drag when Javascript is the engine doing the compression/decompression work, which is not desirable for mobile devices.

Looking instead other forms of compact serialisation, MessagePack does not appear to have any active support in Javascript itself; BSON does not have any Javascript implementation; and an alternative BISON project that I tested does not deserialise everything back to their original values (large numbers), and it does not look like any further development will happen either.

What are some other options others have explored for Node.js?

© Programmers or respective owner

Related posts about node.js

Related posts about JSON