Closed Amr2812 closed 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
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
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.