user730569
user730569

Reputation: 4004

Socket.io scaling - Reduce # of messages or size of messages

I'm sending a lot of messages over a socket.io node.js server, and I have the ability to send over multiple messages in an array, or send each one individually. My question is, what scales better: a larger number of messages sending a smaller amount of data, or fewer messages sending a larger amount of data?

Upvotes: 1

Views: 476

Answers (1)

Tony Abou-Assaleh
Tony Abou-Assaleh

Reputation: 3040

Generally speaking, what @freakish said holds: fewer messages is better, mainly because of the overhead of each message.

There are certain cases, however, when this may not be true.

For instance, if your server has a single processing thread, and your client is sending a very large amount of data, say megabytes, then other clients trying to communicate with the server would block until the transfer completes. If you send the data in smaller chunks, then other clients would be processed in between request. If you happened to have this situation, then you may want to do some testing to find the optimal maximum message size.

Upvotes: 2

Related Questions