- 1 year ago
Wildfly 11 load balancing 2 server nodes
To set up load balancing with two server nodes in WildFly 11, you can utilize the built-in load balancing features provided by the Undertow subsystem. Here are the general steps to configure load balancing:
Configure the domain controller:
- Edit the domain configuration file (
domain.xml
) located in theconfiguration
directory of your WildFly installation. - Add a
<server-group>
element for the load-balanced group. Specify thename
,profile
, and other relevant attributes. - Inside the
<server-group>
, define the two server instances using<server>
elements. Configure their host, name, and other properties. - Add a
<jvm>
element within each<server>
to configure the Java Virtual Machine settings. - Optionally, define any necessary system properties, interfaces, sockets, etc., for each server instance.
- Edit the domain configuration file (
Configure the load balancer:
- Still in the domain configuration file, add a
<proxy>
element within the<subsystem xmlns="urn:jboss:domain:undertow:x.x">
section. - Configure the
<load-balancer>
element with a uniquename
,type
, and other attributes. - Inside the
<load-balancer>
, add<server>
elements for each server instance, specifying theirname
andgroup
attributes.
- Still in the domain configuration file, add a
Start the domain controller and server instances:
- Start the domain controller by running the
domain.sh
ordomain.bat
script. - Start the server instances using the
host-slave.sh
orhost-slave.bat
script, passing the appropriate arguments for each instance.
- Start the domain controller by running the
With this configuration, the load balancer will evenly distribute incoming requests across the two server instances. You can test it by accessing the load balancer's endpoint and verifying that the requests are being routed to both servers.
Note that the actual configuration may vary depending on your specific environment and requirements. It's recommended to refer to the WildFly documentation for detailed instructions and additional options for load balancing configuration.