Configure a Kaazing WebSocket Gateway Cluster
To create a cluster, you must configure multiple gateways to communicate with each other. This is accomplished by adding a cluster
service to each Gateway. Once a cluster
service is configured on each Gateway cluster member and the members are started, the clustered instances will handle connection-switching when another cluster member unexpectedly terminates. Cluster members share information about activity and which of their services are load balanced.
In the following procedure, two Gateway members are clustered. Additional members can be added or removed using the same steps.
Before You Begin
This procedure is part of Checklist: Configure Kaazing WebSocket Gateway for High Availability:
- Using Kaazing WebSocket Gateway to Support High Availability
- Configure a Kaazing WebSocket Gateway Cluster
- Set Up Kaazing WebSocket Gateway as a Load Balancer
- Troubleshoot Kaazing WebSocket Gateway Clusters and Load Balancing
To Create a Cluster with the Gateway
In this example, there are two Gateways. Each Gateway is listening on its IP address for incoming connections (192.168.2.10 for the first Gateway and 192.168.2.11 for the second Gateway), and both are connecting to the cluster group address udp://224.2.2.44:54327.
- On the first Gateway (192.168.2.10), add the following
cluster
configuration element in the Gateway configuration file (GATEWAY_HOME/conf/gateway-config.xml).<cluster> <name>MyCluster</name> <accept>tcp://192.168.2.10:5942</accept> <connect>udp://224.2.2.44:54327</connect> </cluster>
The
cluster
element requiresname
,accept
, andconnect
elements:- The
name
element can be any name. The name must be the same in thecluster
service of every Gateway that wishes to join this cluster. - The
accept
element contains the URI on which the cluster member listens for other cluster members. The URI contains the local IP address of the member. If the Gateway cannot match the IP address in theaccept
URI to one of the host's network interfaces, then the cluster startup process will fail.
The URI in theaccept
uses a TCP scheme followed by the IP address of the network interface for the connection, and a port number (the port number in this example is arbitrary). - The
connect
element contains the URI used to discover other cluster members. Thecluster
element can contain a singleconnect
that uses a multicast address (such as udp://224.2.2.44:54327) or multipleconnect
elements that use unicast addresses (such as tcp://192.168.4.50:5942).- For multicast addressing, the
connect
element URI is known as the group address. This URI must be the same in thecluster
service of every Gateway that wishes to join this cluster. Theconnect
element URI uses a multicast address and port number (the port number in this example is a common multicast port number). Each cluster member sends multicast datagrams to the multicast address. Theconnect
element may use a hostname instead of a multicast address, such as udp://cluster.example.com:9999, if the hostname resolves in DNS to the IP addresses of all of the cluster members. - For unicast addressing, there can be many
connect
elements, each pointing to a different cluster member. Thecluster
service does not require aconnect
URI for every other cluster member. The minimum requirement is that acluster
service have aconnect
for one other cluster member in order to join the cluster.
- For multicast addressing, the
- The
- On the second Gateway (192.168.2.11), add the following
cluster
service element (note that itsname
andconnect
elements are identical to those in thecluster
service on the first Gateway).<cluster> <name>MyCluster</name> <accept>tcp://192.168.2.11:5942</accept> <connect>udp://224.2.2.44:54327</connect> </cluster>
Notice that this
accept
element in the second Gateway uses the same port number as theaccept
element in the first Gateway. These are different hosts and can therefore use the same port number. This also simplifies administration. - Start both cluster members.
- Monitor the cluster using the steps in Monitor with Command Center. To monitor a cluster, the default URL is: http://localhost:8080/commandcenter.
- When you shut down one of the instances, you should see the following message in the terminal that was used to start the remaining gateway instance:
INFO Cluster member /192.168.2.10:5942 is down
Next Step
Set Up Kaazing WebSocket Gateway as a Load Balancer
Notes
- To set up a cluster locally for testing purposes, see Configure a Two-Member Local Demo Cluster.
- To configure clustering in an Enterprise Shield™ topology, see How Does Enterprise Shield™ Work in a Cluster?.
Summary
In this document, you learned about configuring the Gateway for clustering. For more information about Gateway administration, see the documentation.