Preliminary study on load balance of apache2.2.4

Source: Internet
Author: User

With the increasing of traffic and the requirement of response speed, it is necessary to carry out load balancing. The company's system was initially designed to take into account the planning of load Balancing, WWW static server configured Two, because the initial project time is tight, and the traffic is not high, so at that time only used one, the other in the net, just synchronized, and to play a utility. This is a simple test of load balancing.
Let's introduce some of the configuration rules for Apache Mod_proxy_balancer (from the Internet):
There are three different ways to deploy Apache as a loadbalance predecessor, respectively:

1 ) The configuration of the polling equalization policy

Enter Apache's conf directory, open the httpd.conf file, and add at the end of the file:
Proxypass/balancer://proxy/#注意这里以 "/" End
<proxy balancer://proxy>
Balancermember http://192.168.6.37:6888/
Balancermember http://192.168.6.38:6888/
</Proxy>
Let's look at the parameter "proxypass/balancer://proxy/" above, where "Proxypass" is the command to configure the virtual server, "/" to represent the URL prefix for sending the Web request, such as: http://myserver/or HTTP ://MYSERVER/AAA, these URLs will conform to the above filtering conditions, "balancer://proxy/" means to configure load balancing, proxy represents the load balancing name, and Balancermember and its subsequent URLs represent the background server to configure. The URL where the URL is the background server request. Taking the above configuration as an example, the principle of load balancing is as follows:
Assuming that Apache receives the HTTP://LOCALHOST/AAA request, because the request satisfies the Proxypass condition (its URL is prefixed with "/"), the request is distributed to a balancermember in the background, for example, the request may be forwarded to the HTTP ://192.168.6.37:6888/AAA for processing. When the second URL that satisfies the condition is requested, the request may be distributed to another balancermember, for example, may be forwarded to http://192.168.6.38:6888/. The mechanism of load balancing is realized by this cyclic repetition.

2) Configure the allocation of the balance policy by weight

Proxypass/balancer://proxy /          #注意这里以 "/" End
<proxy balancer://proxy> 
         balancermember http://192.168.6.37:6888/  loadfactor=3 
         balancermember http://192.168.6.38:6888/  loadfactor=1
</proxy >&NBSP
      parameter "Loadfactor" indicates that the background server load is the right value to send a request by Apache, which defaults to 1, and you can set the value to any value between 1 and 100. Taking the above configuration as an example, this paper describes how to implement load balancing by weight, assuming that Apache receives HTTP://MYSERVER/AAA 4 requests, which are loaded into the backend server, Then there are 3 consecutive requests that are loaded into the Balancermember-http://192.168.6.37:6888 server, and 1 such requests are loaded Balancermember as http://192.168.6.38:6888 backend servers. The equilibrium strategy is realized according to the continuous weight distribution.

3 allocation of weight request response load Balancing Strategy

Proxypass/balancer://proxy/lbmethod=bytraffic #注意这里以 "/" End
<proxy balancer://proxy>
Balancermember http://192.168.6.37:6888/loadfactor=3
Balancermember http://192.168.6.38:6888/loadfactor=1
</Proxy>
The parameter "lbmethod=bytraffic" indicates the number of bytes in the background server load request and response, and how much of the processing byte count is represented by weight. "Loadfactor" indicates that the background server handles the weight of the load request and response bytes, which defaults to 1, and can set the value to any value from 1 to 100. According to the above configuration is so balanced load, assuming that Apache received the HTTP://MYSERVER/AAA request, forwarding the request to the backend server, if Balancermember is http:// 192.168.6.37:6888 the backend server loads to this request, the number of bytes it handles requests and responses is 3 times times that of Balancermember http://192.168.6.38:6888 server (recall (2) balanced configuration, (2) is based on the number of requests as the weight of the load balance, (3) is the flow of weight load balanced, which is the biggest difference.

See, no, according to different needs, can be configured in these three ways. I'm in the third configuration, and it feels like the balance of the load is more fully justified. My configuration is simple, as follows:
To configure the Equalizer first:
<proxy balancer://proxy>
Balancermember ajp://127.0.0.1:8009/loadfactor=1
Balancermember http://192.168.10.6:8083/loadfactor=1
</Proxy>
Where http://192.168.10.6:8083 is actually another port-initiated Apache, for testing, it simply forwards all requests directly to Tomcat.
For the last VirtualHost, make the following modifications:
<virtualhost *:80>
ServerName www.test.com
Documentroot/www
DirectoryIndex index.html index.jsp
<directory "/www" >
Options Indexes FollowSymLinks
AllowOverride None
Order Allow,deny
Allow from all
</Directory>
<directory "/control" >
Options Indexes FollowSymLinks
AllowOverride None
Order Allow,deny
Allow from all
</Directory>
Proxypass/nxt/images/!
proxypass/nxt/js/!
proxypass/nxt/css/!
#ProxyPass/ajp://127.0.0.1:8009/
#ProxyPassReverse/ajp://127.0.0.1:8009/
proxypass/balancer://proxy/
proxypassreverse/balancer://proxy/
</VirtualHost>
Comment out before the AJP forwarding, but configured to process through the balancer.
By looking at Access log, some of the requests were sent to Apache on Port 8083, and some were directly AJP forwarded to Tomcat. For more load-balanced parameter detection, wait for the empty to do.

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.