The Load Balancer's task is to distribute the load of incoming traffic amongst a set of back-end worker nodes. When a request comes to the WSO2 Load Balancer, the host header is identified and the cluster domain is determined.
An example Host header is https://appserver.cloud-test.wso2.com/t/ttt.ttt/carbon/admin/login.jsp. The service domain is appserver domain and the tenant Id is determined from the url. In this example, the tenant domain is ttt.ttt. These parameters can be extracted from the header.
Using both the service domain and tenant domain, requests can be directed to the correct cluster as defined in the loadbalancer.conf file, where services with their cluster domains and tenant ranges can be configured. When the Load Balancer starts, it picks those ranges and cluster domains.
Refer to the following sample configuration for one service with two clustering domains in the loadbalancer.conf file, which can be found in the <PRODUCT_HOME>/repository/conf directory.
appserver { # multiple hosts should be separated by a comma. hosts appserver.cloud-test.wso2.com; domains { carbon.as1.domain { tenant_range 1-100; } carbon.as.domain { tenant_range *; } } }
The sample configuration above is for an application service with two service clusters. According to the first line, appserver is the main node. Host entries are specified in the lines that follow with the the host address that maps to the application server service.
If you need to add multiple service domains, add them separated by commas. The above sample has two domains with predefined tenant ranges. The cluster names as 'carbon.as1.domain' is responsible for loading tenants with tenant id 1 to 100 and the one named as 'carbon.as.domain' is responsible for loading all tenants except the ones belonging to the above range.
This ensures that requests are forwarded to the correct cluster based on the service domain and tenant domain. The following diagram depicts how requests are forwarded to the correct cluster.