Answer the question
In order to leave comments, you need to log in
Does it make sense to use BSON instead of JSON when communicating over WebSocket?
In one of the projects that I am now starting to do, the task is to send data using the WebSocket protocol. On the client, the usual "web face" with javascript logic and Tornado is used as the server. By default, Tornado works with JSON (there is a built-in deserializer and serializer). JSON is perfectly processed by Javascript and does not require any dancing with a tambourine.
So. Does it make sense to use the BSON binary format instead of JSON?
At the moment I see the following advantages :
wsconnection = new WebSocket(---);
wsconnection.binaryType = 'arraybuffer';
wsconnection.onmessage = function (event) {
console.log(BSON.deserialize(new Uint8Array(event.data)));
}
Answer the question
In order to leave comments, you need to log in
In general, it makes no sense. On the server, processing is a little faster. On the client noticeably slower. The weight is 2% less ... But at the same time, it is also not readable. BSON instead of JSON - the answer is no.
We tried MessagePack. Speed tests gave the best results, but it was not possible to start transmission on this format. Why is unknown. The unpackb function returns an error.
Conclusion:
Thank you all
And at least one of the listed pluses is critical for you? So, are you really into it?
If yes, use it, if not, don't.
KISS
KISS +1. I don't think it makes sense. We use sockets ourselves, there is no point in BSON. Between servers, yes, there is a lot of traffic there.
> This conversion does not inspire confidence in me. Not productive.
In vain. Binary operations are the fastest you can get.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question