Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socketCluster-server with SCC | redis and streams | connections #36

Open
fas3r opened this issue Mar 6, 2019 · 0 comments
Open

socketCluster-server with SCC | redis and streams | connections #36

fas3r opened this issue Mar 6, 2019 · 0 comments

Comments

@fas3r
Copy link

fas3r commented Mar 6, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant