socketcluster-server
socketcluster-server copied to clipboard
socketCluster-server with SCC | redis and streams | connections
Hello,
I would like to implement what is describe in the SCC guide, from what I understand from the guide, if I use the socketcluster-server I should be able to scale automatically vertically and horizontally.
Could you please tell me what are the network requirement between the sc-state, sc-broker and the scc-server ? Does 80/443 is enough or the sc-state use additional ports ?
In my backend I use redis stream to pub/sub streams to specific channels/rooms using GROUP and XREADGROUP + rxJs, can I use the sc-redis as a base to create the necessary adapter ?
Last thing is more about the logic/management or how to deal with connections like RabbitMQ, ... As per the following doc of RabbitMq I'm not quite sure to understand how to apply what follow below with socketCluster...
As SCC will scale horizontally across the CPUs of my instance, should I create my connections on the master(server.js) and share it across all the brokers/workers and open channels from there ?
Don’t open and close connections or channels repeatedly Have long lived connections if possible, and use channels for each task. The handshake process for an AMQP connection is quite complex and requires at least 7 TCP packets (more if TLS is used). Channels can be opened and closed more frequently if needed. Even channels should be long-lived if possible, e.g., reuse the same channel per thread for publishing. Don’t open a channel each time you are publishing. If you can't have long lived connections, then make sure to gracefully close the connection Best practice is to reuse connections and multiplex a connection between threads with channels.
AMQP connections: 7 TCP packages AMQP channel: 2 TCP packages AMQP publish: 1 TCP package (more for larger messages) AMQP close channel: 2 TCP packages AMQP close connection: 2 TCP packages Total 14-19 packages (+ Acks)
and (most important)
Don’t share channels between threads You should make sure that you don’t share channels between threads as most clients don’t make channels thread-safe (because it would have a serious negative impact on performance).
The concept of cluster using nodeJs is quite new for me and due to some restriction we can not use the framework version of socketCluster. Looking forward to read to answers.
Thanks by advance. fas3r