-
Notifications
You must be signed in to change notification settings - Fork 91
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
Using MessagePack (binary frames) with SocketCluster #64
Comments
@mirague I think the current format is nice because it's simple and extensible... But I agree with your point. For compression, there is support for perMessageDeflate (good for large messages). This has been in SC for a long time but I just added documentation today: Search for perMessageDeflate is great for large JSON messages but not very useful for very short messages sent with high throughput. (which is your use case) I believe the WebSockets standard might support other custom compression algorithms in addition to Either way, yes I think it would be nice to allow the user to inject their own compression/decompression functions on the client and server. We could also consider changing the current format to something more lightweight but this would introduce new problems:
I'm kind of leaning on allowing the user to inject their own custom compression/decompression functions. |
We could introduce a new concept: custom Codecs - So users could specify a custom JavaScript module for coding and decoding packets - Right now, only https://github.com/SocketCluster/sc-formatter is supported but we could allow the user to swap it out with anything they like. For games, the user could use their own Codec optimized for their specific game - It could format messages as raw binary. If a codec is used on the client, the same codec module will need to be provided on the server-side. It would just have two methods: The community could then share codecs - Each one being optimized for specific purposes. |
@mirague I added a new custom codec feature. See https://github.com/SocketCluster/socketcluster#custom-codecs |
@jondubois Excellent work! I will have a look at the changes coming week, thank you! |
If there's a lot of req by sec, consider using webRTC + socketCluster (if it is p2p task, of course). |
@mirague In case you're interested, I've done some work on a minimal binary codec which you can easily plug into SC: https://github.com/SocketCluster/sc-codec-min-bin Right now it just uses MessagePack to encode/decode messages between JSON <=> ArrayBuffer/Buffer (Binary) but in the future, it will also do some SC-specific compression to reduce the protocol overhead to almost nothing - Suggestions and PRs are welcome. You may want to upgrade socketcluster to Also, we started adding some features to speed up pub/sub in SC so that should help with high-throughput workloads as well. |
Currently the SocketCluster client uses a format of:
The format has considerable overhead on the messaging structure and I was wondering how we could go about implementing a buffered-approach such as MessagePack. This could save us big on bandwidth as we're developing an application with a high rate of message throughput.
Right now I'm trying something like:
What do you think of supporting raw binary frames directly? And if there's no interest in official support, could you share your thoughts on this? Thanks!
The text was updated successfully, but these errors were encountered: