Closed Energytechglobal closed 4 years ago
scc-worker
instances are local broker processes
which have two jobs:local worker processes
(which are running on the same host).scc-broker
instances and local worker processes
.The existence of local broker processes
in SC v14 and earlier means that (for certain use cases), fewer messages need to pass through the network because each message from the cluster is only delivered once per host (no matter how many worker processes there are on that host).
scc-broker
instances route messages between multiple scc-worker
instances which are running on different hosts. Note that scc-worker
instances contain local broker processes
as you correctly pointed out - These local broker processes
are part of the scc-worker
instances and they're the ones which connect with the remote scc-broker
instances and forward messages to the local worker processes
. A broker process
is both a server and a client; it's a server to worker processes
but it's also a client of scc-broker
instances and it proxies messages between the two based on who is subscribed to what channels. Note that even though this approach was more efficient for certain use cases, the concept of local broker processes was removed in SC v15 to simplify the architecture and provide more flexibility to developers.
It's not by default, but it could be used instead of scc-broker
instances with some work because Redis supports similar pub/sub features those of scc-broker
.
Hopefully the first two points answer this.
No, unlike other solutions which rely on HTTP polling, with SC, once the initial connection is passed to one of the local worker processes, the client will stay connected that worker so there is no need for session stickiness in the load balancers.
This is to prevent all the channel data in the entire system from passing through a single scc-broker
instance. That would overwhelm the instance; that is why, if you have multiple scc-broker
instances, it will apply a mapping function (on the scc-worker
) to decide which of the x
available scc-broker
instances should manage each channel based on its name. The mapping function is deterministic but it ensures even distribution between all available scc-broker
instances so that the load is split evenly between them. The mapping function uses an algorithm called rendezvous hashing (skeleton-based)
which gives even distribution and is efficient at handling scenarios where scc-broker instances are regularly added to and removed from the cluster.
Channel messages do not pass through the scc-state
instance. scc-state
only keeps track of and tells scc-worker
instances about the state of the cluster; that's all. scc-broker
instances are the ones which actually forward the messages. scc-state
is only needed when the state of the cluster has changed.
Thanks, Jonathan for the explanation. Yes, we are using socketcluster version 14.4.2.
Could you also suggest the following?
Regards, EnergyTech Global
@Energytechglobal you will need to benchmark this on your environment there is no one fit all recipe.
a good starting point is 1 broker per worker
Thanks, Frank for the suggestion. And once again thanks, Jonathan for the detailed explanation. It was really helpful. I am closing this one.
Regards, EnergyTech Global
Hi Jonathon,
We are using SCC in our chat application. We have gone through the documentation to scale our application horizontally and have got some questions. Could you please go through our understanding and provide us with the answers for the questions asked?
Our understanding of SCC architecture:
Questions:
Thanks in advance.
Regards, EnergyTech Global