socketio / socket.io-cluster-adapter

The Socket.IO official cluster adapter, allowing to broadcast events between several Socket.IO servers.
https://socket.io
MIT License
16 stars 9 forks source link

Is the cluster adapter powerful enough to manage heavy socket.io instances (regarding speed) or is Redis adapter more recommended? #2

Closed Amr2812 closed 2 years ago

darrachequesne commented 2 years ago

That's a good question!

We didn't do extensive benchmark of the adapter, but it seems inter-process communication (IPC) is more efficient than Redis in that case: https://60devs.com/performance-of-inter-process-communications-in-nodejs.html

Note: since the primary/master process handles all incoming requests (and then forwards it to a given worker, see socket.io-sticky), it might be the limiting factor for the number of incoming connections.

As usual, please benchmark it against your own use case.

Amr2812 commented 2 years ago

So in that case, I don't need nginx either to reverse proxy between servers and sticky sessions as you said the primary/master process handles all incoming requests, so should i use nginx or not?

Thanks in advance

darrachequesne commented 2 years ago

For a single server and multiple workers, using @socket.io/sticky and @socket.io/cluster-adapter is sufficient, and nginx is not needed.

For multiple servers (each one with multiple workers), you will need to use a load balancer (like nginx) and another adapter, like the one based on Redis.

Reference: https://github.com/socketio/socket.io-sticky#notes