fakedrake
fakedrake

Reputation: 6856

Websockets - multiple vs multipurpose tradeoff

I am writing a web interface to a rasperry pi that needs to have the least possible latency and is visible from the local network. Would it be better to have multiple websockets or one and demux the messages?

Out of curiosity, what if I wanted an internet facing service backed by a normal server. Is the number of sockets used a tradeoff situation or is it the less the better? Obviously if I don't want to flood the server with too many connections but at the same time if I demux messages with javascript it should be harder on the client that to have the browser websocket implementation do the heavy lifting. Could I get some insight on this?

Upvotes: 1

Views: 200

Answers (1)

vtortola
vtortola

Reputation: 35965

The less the better. One websocket per client should be enough. JavaScript is mono thread anyway, so there is no benefit in use multiple.

If you have X bandwidth between client and server, that bandwidth is shared across connections.

Use a publisher/subscriber model over a single connection.

Upvotes: 2

Related Questions