socketcluster icon indicating copy to clipboard operation
socketcluster copied to clipboard

vertical scaling with sc-broker

Open nizzlenitz opened this issue 7 years ago • 2 comments

Hi,

I apologize for using issues to ask a question. I am new to SC and am trying to wrap my head around the framework.. My use case is a chat with multiple workers on a vertically scaled machine. I would like to persist shared data from the chat in memory, so that if a client drops they can catch up with lost messages. Would I store the data using sc-broker? If so is there an example I can reference that has multiple workers with a central shared memory store?

Thank you so much!

nizzlenitz avatar Feb 18 '19 03:02 nizzlenitz

You can if convenience is important to you and you don't care about horizontal scalability (or you want to implement your own syncing mechanism between different instances). The recommended approach though is to store that data in a database or memory store like Redis.

The scServer.exchange instance supports the same methods as the sc-broker object here: https://github.com/SocketCluster/sc-broker#client-methods - It can scale pretty well vertically if you're just storing simple hierarchical data (or just key-value pairs) but it's not designed to scale across multiple machines.

It's useful mostly to allow workers to easily/efficiently share data with each other without having to manage a separate database or datastore.

jondubois avatar Feb 26 '19 21:02 jondubois

Thanks Jon! That makes a lot of sense. One other area I am looking into is server to server replication of data between instances of SocketCluster. I see you can use scc-broker & scc-state to scale horizontally, which I assume would allow you to broker data between instances. However my use case involves sometimes just publishing to another instance sometimes just subscribing or both based on needs and configuration. It doesn't feel like scc-broker/state would be the best fit for that. What I was thinking instead would be a need to create socketcluster-client(s) between instances. Would this be the best way to handle this form of inter-node data sharing? Is there a way to attach a process/processes to handle these clients that would be attached to the SocketServer to watch the broker? Or would I need to manually spawn a process to do this.

Thank you for your feedback and creating this amazing framework!

kylebernhardy avatar Feb 26 '19 21:02 kylebernhardy