Apache Load Balancing

Source: Internet
Author: User
Use Apache as Web Proxy

The apusic application server can integrate with Apache in the following two ways:

4.9.1. HTTP Proxy

The mod_proxy_http module provided by Apache can be used to integrate with the apusic application server, and the apusic application server does not require any settings. Mod_proxy_http provides the proxy HTTP Request function. Supports HTTP/0.9, HTTP/1.0, and HTTP/1.1 standards.

  • Configuration in standalone Environment

    Perform the following configuration in % apache_home %/CONF/httpd. conf:

    ...LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_http_module modules/mod_proxy_http.so...ProxyPass /${request_uri} http://192.168.6.119:6888/${request_uri}...
  • Server Load balancer configuration in multi-host environments

    Using Apache as the front-end server of loadbalance has three different deployment methods:

    • Round Robin balancing policy configuration

    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.

    • Weight-based balancing policy configuration

    ... 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.

    • Configure the server Load balancer policy for weight Request Response

    ... 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.

4.9.2. AJP proxy

AJP is a protocol provided by Apache to complete communication with other servers. In Apache, AJP data is sent through the mod_proxy_ajp module. The server at the other end needs to implement the AJP protocol, which can accept the AJP protocol data sent by the mod_proxy_ajp module. After receiving the AJP protocol data, perform proper processing, the processing result can be sent back to the mod_proxy_ajp module as AJP protocol.

The apusic server fully supports the AJP protocol. The current AJP Protocol version is AJP/1.2 and AJP/1.3. Currently, the apusic server uses the AJP/1.3 protocol by default.

  • Configuration in standalone Environment

    Perform the following configuration in % apache_home %/CONF/httpd. conf:

    ...LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_http_module modules/mod_proxy_ajp.so...ProxyPass /${request_uri} ajp://192.168.6.119:8007/${request_uri}...

    Under the config directory in the installation directory of the apusic Application Server domain, add the following content to the configuration file apusic. conf:

    ...<SERVICE    CLASS="com.apusic.servlet.http.ajp.AJPEndpoint"    NAME="Endpoint:type=ajp,service=httpd" >    <ATTRIBUTE NAME="Port" VALUE="8007"/></SERVICE>...
  • Server Load balancer configuration in multi-host environments

    Perform the following configuration in % apache_home %/CONF/httpd. conf:

    ...LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_balancer_module modules/mod_proxy_balancer.soLoadModule proxy_http_module modules/mod_proxy_ajp.so...ProxyPass /${request_uri} balancer://proxy/<Proxy balancer://proxy>BalancerMember ajp://192.168.6.119:8007/${request_uri}BalancerMember ajp://192.168.6.120:8007/${request_uri}</Proxy>...

    Under the config directory in the installation directory of the apusic Application Server domain, add the following content to the configuration file apusic. conf:

    ...<SERVICE    CLASS="com.apusic.servlet.http.ajp.AJPEndpoint"    NAME="Endpoint:type=ajp,service=httpd" >    <ATTRIBUTE NAME="Port" VALUE="8007"/></SERVICE>...

    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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.