🗃️Private Network Configuration

Private Network Scaling

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.

SOKETI_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 cluster to 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.

Environment Variables

These environment variables are working only when the ADAPTER_DRIVER variable is set to cluster.

Name
Default
Possible values
Description

SOKETI_CLUSTER_CHECK_INTERVAL

500

Any number

The amount of time (in ms) between checks to see if new instances joined the network.

SOKETI_CLUSTER_HOST

0.0.0.0

Any string

The hostname to bind to the network.

SOKETI_CLUSTER_MASTER_TIMEOUT

2000

Any number

The amount of time (in ms) between checks to see if the master instance is alive.

SOKETI_CLUSTER_NODE_TIMEOUT

2000

Any number

The amount of time (in ms) between checks to see if the instances are alive.

SOKETI_CLUSTER_PORT

11002

Any number

The port to communicate with other instances.

SOKETI_CLUSTER_BROADCAST_ADDRESS

255.255.255.255

Any IP

The address in the private network for the broadcast protocol. Broadcast is enabled by default as the UDP protocol.

SOKETI_CLUSTER_MULTICAST_ADDRESS

null

Any IP

The address in the private network for multicasting. Setting this disables broadcasing.

SOKETI_CLUSTER_UNICAST_ADDRESSES

null

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.

Built-in IPC

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.

Last updated