Server Load balancer configuration in multi-host environments
Using Apache as the front-end server of loadbalance has three different deployment methods:
Go to the % apache_home %/conf directory and check whether the following settings are correct in httpd. conf:
...LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_balancer_module modules/mod_proxy_balancer.soLoadModule proxy_http_module modules/mod_proxy_http.so...
After the above configuration check is correct, add the following at the end of the httpd. conf file:
... Proxypass/balancer: // proxy/# Note: <proxy balancer: // proxy> balancermember http: // 192.168.6.119: 6888/balancermember http: // 192.168.6.120: 6888/</Proxy>...
Let's observe the above parameters. Here we assume it is "proxypass/balancer: // proxy/", where "proxypass" is the command for configuring the virtual server, "/" indicates the URL prefix for sending Web requests, such as http: // myserver/or http: // myserver/AAA. All these URLs comply with the preceding filter conditions. "balancer: // proxy/"indicates that Server Load balancer is to be configured, and proxy indicates the Server Load balancer name. balancermember and its url indicates the backend server to be configured, And the URL indicates the request URL of the backend server. The preceding configuration is used as an example to describe how Server Load balancer works:
If Apache receives an http: // localhost/AAA request, because the request meets the proxypass condition (its URL prefix is "/"), the request will be distributed to a balancermember in the background, for example, the request may be forwarded to http: // 192.168.6.37: 6888/AAA for processing. When the Second Matching URL request comes over, the request may be distributed to another balancermember. For example, the request may be forwarded to http: // 192.168.6.38: 6888 /. The load balancing mechanism is realized after such a loop.
... Proxypass/balancer: // proxy/# Note: <proxy balancer: // proxy> balancermember http: // 192.168.6.119: 6888/loadfactor = 3 balancermember http: // 192.168.6.120: 6888/loadfactor = 1 </Proxy>...
The "loadfactor" parameter indicates the weight from the backend server load to the request sent by Apache. The default value is 1. You can set this value to any value between 1 and 100. The preceding configuration is used as an example to describe how to implement Load Balancing Based on weights. Now, Apache receives four such requests: http: // myserver/AAA, this request is separately loaded to the backend server, and three consecutive such requests are loaded to the server where balancermember is http: // 192.168.6.119: 6888, one such request was loaded with the backend server balancermember http: // 192.168.6.120: 6888. Implements a balance policy that distributes weights continuously.
... Proxypass/balancer: // proxy/lbmethod = bytraffic # note that the end of "/" <proxy balancer: // proxy> balancermember http: // 192.168.6.119: 6888/loadfactor = 3 balancermember http: // 192.168.6.120: 6888/loadfactor = 1 </Proxy>...
The parameter "lbmethod = bytraffic" indicates the number of bytes of the backend server load requests and responses, and the number of bytes processed is expressed by the weight. "Loadfactor" indicates the backend server's weight for processing load requests and response bytes. The default value is 1. You can set this value to any value ranging from 1 to 100. According to the above configuration, the Server Load balancer is balanced. If Apache receives an http: // myserver/AAA request and forwards the request to the backend server, if balancermember is http: // 192.168.6.119: 6888 when the backend server loads this request, the number of bytes it processes the request and response is three times that of the balancermember http: // 192.168.6.120: 6888 server (recall the second balanced configuration, the number of requests is used as the weight load balancing, and the third is the traffic-weighted load balancing, which is the biggest difference ).
|
Note: |
Use apachectl-K restart to restart Apache every time you modify httpd. conf. |
When a user needs to use the sticky session feature for load balancing in a multi-host environment, in addition to configuring to enable sticky session in apusic, we also need the VM on the apusic server. in the options (% domain_home %/config directory) file, set:
## This is the default sytem configurations . You can modify any server side# configurations in this file.#...com.apusic.jvm.route=proxyserver1...
|
Note: |
The above configuration is based on Windows XP SP2 + Apache 2.2, and the configuration on Linux/Unix is basically consistent. After the configuration is complete, restart the apusic and Apache servers. |