Apache+Jetty load balancing configuration

Apache+Jetty load balancing configuration

There are three ways to use Apache and jetty in combination :

1. Use Apache mod_proxy and a normal Jetty HTTP connector.

2. Use Apache mod_proxy_ajp and Jetty AJP connector.

3. Use Apache mod_jk and the Jetty AJP connector.

Among them, Jetty recommends the first one. The recommended reasons are as follows:

1. Using HTTP , Jetty 's performance is better.

2. The AJP protocol documentation is lacking, and many versions are illegal.

If you want to use AJP , mod_proxy_ajp is better than mod_jk . Previously, mod_jk 's load balancing capabilities necessitated its use, but in Apache 2.2 , mod_proxy_balancer is available over HTTP and AJP connectors.

Using mod_proxy is actually configuring a reverse proxy, which simply forwards the URL of the request to jetty . If you want to achieve load balancing, apache also needs to load mod_blancer .

       1. Download Apache

        http://de.apachehaus.com/downloads/ , the version in this example is httpd-2.2.29-x64

         2. Download Jetty, the version is jetty-8.1.14.

       3. Configure Apache 's httpd.conf and add the following modules to it

        LoadModule proxy_module  /modules/mod_proxy.so

        LoadModule proxy_balancer_module  /modules/mod_proxy_balancer.so

        LoadModule proxy_http_module  /modules/mod_proxy_http.so

        LoadModule proxy_ajp_module /modules/mod_proxy_ajp.so

        LoadModule jk_module  /modules/mod_jk.so 

        Add the reverse proxy configuration at the end of the httpd.conf file,

        ProxyRequests Off

        <Proxy *> 

                Order deny,allow 

                Allow from all 

        </Proxy>

        ProxyPass /za http://localhost:8080/

        ProxyPass / http://localhost:8080/

The default configuration of Apache is port 80. When accessing http://localhost or http://localhost/za , the request should be forwarded to jetty , which is http://localhost:8080 .

After the configuration is complete, start Apache , and then visit http://localhost , which is the jetty page.

4. Load balancing configuration

If you want to configure load balancing, it is assumed that there are two jetty instances on this machine, and the listening ports are 8080 and 8090 respectively . The simple load balancing configuration is as follows :

        ProxyRequests Off 

 

        <Proxy *> 

                Order deny,allow 

                Allow from all 

        </Proxy> 

 

        ProxyPass /zk balancer://mycluster 

        ProxyPass /zk balancer://mycluster 

 

        <Proxy balancer://mycluster> 

                BalancerMember http://localhost:8109/aa 

                BalancerMember http://localhost:8108/aa 

        </Proxy>  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326447136&siteId=291194637