Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Message ordering in socket.io

Does socket.io guarantee that on() callbacks will be called in the same order that the messages were emitted?

like image 313
Denis Karpov Avatar asked Feb 18 '13 10:02

Denis Karpov


People also ask

Do WebSocket messages arrive in order?

Short answer: No.

Does Socket.IO guarantee order?

This is an old post, but it's worth noting that Socket.io over WebSockets actually does guarantee event ordering is maintained. This is because TCP itself, which is the underlying technology for WebSockets & HTTP guarantees packet ordering to be maintained.

Is Socket.IO good for chat?

This is an organization based application. In this app, I have to implement chat functionality. So as we all know Socket.io is the best solution for instant messaging app and its reliability.

How many messages per second can Socket.IO handle?

Both server and client node processes use 95-100% of a CPU core each. So pure throughput looks ok. I can emit 100 messages per second to 100 local clients at 55% CPU usage on the server process.


1 Answers

Node.js is a single event loop so yes.

But you have another problem, think about the latency between you and your clients, if two clients sent their messages, the first message that came to the server will be handled first, so if the first client emitted his message but he had a higher latency to the server from the second client (which sent his message after the first client), then it's probably be the second client message that will be handled first

like image 183
udidu Avatar answered Sep 27 '22 23:09

udidu