cluster
Clustering
A cluster mode is provided by Web Collaboration Server. This mode supports horizontal scaling, so that it can support large-scale users.
In cluster mode, multiple Collaboration Servers can be started to form a cluster to handle users requests together.
Users can provide the core services required for the collaborative cluster mode by implementing the interfaces defined by collaboration server.
To support cluster, some additional configurations are required when creating collaboration server. For example:
const messageQueue = new CustomMessageQueue()
const memberStateService = new CustomMemberStateService()
const server = new WebCollabServer({
// other options
cluster: {
serverId: '1',
messageQueue, // only required if you want to use your customized MessageQueue
memberStateService // only required if you want to use your customized MemberStateService
}
});
Further descriptions of cluster parameters are as follows:
serverId
A serverId
is required for each collaboration server instance.
It can be any string but please make sure that it is unique in the same cluster.
MessageQueue
A message queue is used to exchange Message among different servers and components.
Message queue is a key component for the clustering of collaboration servers. All collaboration servers in the cluster communicate by exchanging messages via message queue.
A message queue can be implemented on top of RabbitMQ, Kafka, Redis, etc.
This config is optional.
A default MessageQueue
based on Redis is provided, and will be used if messageQueue
is not provided in the cluster option.
The Redis URL should be provided as an environment variable when starting the collaboration server, like REDIS_URL="redis://127.0.0.1:6379"
.
MemberStateService
MemberStateService
is used to store and retrieve member states. The currently supported member states are online/offline. For more information, please refer to the API Reference of Foxit Web Collaboration Add-on.
This config is optional. A default MemberStateService
is provided and will be used if memberStateService
is not provided in the cluster option.
Load Balancer
In the cluster mode, a Load Balancer is needed to distribute the requests to server instances in the cluster.
Typically, Load Balancer has different load balancing strategies, and the collaboration server has no restrictions on the strategies.
We recommend to use consistent hashing based on collaborationId
, which can reduce the synchronization overhead of multiple Server instances.