Private Network Configuration
The clustering method provides the alternative of running the communication between nodes without having to deal with a third-party channel like Redis Pub/Sub. The protocol is, in fact, decentralized.
ADAPTER_DRIVER=cluster soketi start
No matter how many soketi processes you open with the Cluster driver, you will have built-in scalability without additional servers. It's highly recommended to use the cluster adapter when you deploy soketi behind the same private network with PM2 to acquire multithreading.
The only downside to the cluster adapter is that you can only scale processes or instances which are within the same network. The protocol used is tied to a hostname which should be the same for all instances. This can be highly effective when deploying to Kubernetes clusters or behind the firewall, in the same network. To deploy in multi-mesh architectures, consider using Redis Pub/Sub.
Keep in mind you should also set the Rate Limiting driver to
clusterto ensure the rate limiting is even across all your workers.
To deploy to Kubernetes, you should have a CNI that supports Multicast, Unicast or Broadcast, otherwise the Cluster adapter won't work. The best one would be Weave.
These environment variables are working only when the
ADAPTER_DRIVERvariable is set to
The amount of time (in ms) between checks to see if new instances joined the network.
The hostname to bind to the network.
The amount of time (in ms) between checks to see if the master instance is alive.
The amount of time (in ms) between checks to see if the instances are alive.
The port to communicate with other instances.
The address in the private network for the broadcast protocol. Broadcast is enabled by default as the UDP protocol.
The address in the private network for multicasting. Setting this disables broadcasing.
JSON-formatted array of IPs.
The list of addresses in the private network for unicasting. Setting this disables multicasting and broadcasting.
Make sure to choose the same port and hostname if you want the nodes to communicate between each other properly. Deploying multi-tenant architectures should use different ports or hostnames.
IPC is enabled automatically for running servers, and this is used in various cases, like storing rate-limiting buckets or scaling horizontally in the same private network.
Beside scaling horizontally, that can be done by configuring the Redis adapter, each running instance of soketi is able to communicate with other nodes that run in the same private network via the IPC protocol in Node.js.