Apache and Nginx Load balancer configuration

Source: Internet
Author: User
Tags nginx load balancing
Apache Load Balancer operation Apache function is actually very powerful, recently studied the next Apache reverse proxy and load balancing, reverse proxy network network export and my blog export is through the reverse proxy Apache implementation, summed up, the emphasis on load balancing configuration                        。 Operating system: DEBIAN 5.03 (Ubuntu can also be configured similarly) (1), polling equalization policy configuration into the Apache Conf directory, open the httpd.conf file, add at the end of the file: Pr oxypass/balancer://proxy/#注意这里以 "/" End
 
  
   Balancermember Http://www.php186.com/BalancerMember http://www.php186.com/ 
  
 Let's observe the parameter "proxypass/balancer://proxy/" above, where "Proxypass" is the command that configures the virtual server, "/" represents the URL prefix for sending Web requests, such as: http://myserver/or HTTP ://MYSERVER/AAA, these URLs will conform to the above filter conditions, "balancer://proxy/" means to configure load balancing, proxy represents the load balancer name; Balancermember and its subsequent URLs represent the backend servers to be configured. Where the URL is the URL of the background server request. With the above configuration as an example, the principle of load balancing is as follows: Assuming Apache receives a HTTP://LOCALHOST/AAA request, because the request satisfies the Proxypass condition (its URL prefix is "/"), the request is distributed to a background balancermem ber, for example, the request may be forwarded to HTTP://WWW.PHP186.COM/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://www.php186.com/.            In this cycle, the load balancing mechanism is realized. (2), distribution by weight allocation policy configuration proxypass/balancer://proxy/#注意这里以 "/" End
 
  
   balancermember http://www.php186.com/loadfactor=3 balancermember http://www.php186. Com/loadfactor=1
  
 The parameter "Loadfactor" indicates that the background server is loading to the weight of the request sent by Apache, which defaults to 1 and can be set to any value from 1 to 100. Taking the above configuration as an example, describes how to achieve load balancing by weight allocation, now assume that Apache received HTTP://MYSERVER/AAA 4 times such a request, the request was load to the background server, 3 consecutive such requests are loaded to Balancermember for http://www.php186.com server, 1 times such requests are loaded Balancermember http://www.php186.com backend server.            It realizes the equilibrium strategy of continuous distribution according to the weight. (3), the configuration of the weight request response load Balancing policy proxypass/balancer://proxy/lbmethod=bytraffic #注意这里以 "/" End
 
  
   balancermember http://www.php186.com/loadfactor=3 balancermember http://www.php186. Com/loadfactor=1
  
             The parameter "Lbmethod=bytraffic" represents the number of bytes of the background server load request and response, and the number of bytes processed is expressed in the form of a weighted value. "Loadfactor" indicates that the background server handles the weight of the payload request and the number of response bytes, which defaults to 1 and can set the value to any value from 1 to 100. Based on the above configuration, the load is balanced, assuming Apache receives the HTTP://MYSERVER/AAA request and forwards the request to the backend server if Balancermember is http:// www.php186.com background server load to this request, then it processes the request and Response bytes is balancermember to http://www.php186.com server 3 times times (Recall (2) balanced configuration, (2)            is based on the number of requests as a weighted load balancer, (3) is based on the flow of weight load balanced, which is the biggest difference).        Note: Each time you modify httpd.conf, use apachectl–k restart to restart Apache. Second, Nginx load balancing operation Nginx was developed by Igor Sysoev for the second rambler.ru site in Russia, which has already run more than 2.5 of the site. Igor release the source code in the form of a BSD-like license.             Although still beta, Nginx has been known for its stability, rich feature set, sample configuration files, and low system resource consumption. The first is that the configuration is very simple and the functionality is very powerful. It's brief encounter.              Let's take a look at the configuration file. worker_processes 1;              Events {Worker_connections 1024;                      } http{upstream MyProject {#这里指定多个源服务器, IP: port, 80 port can be written without writing                      Server 192.168.43.158:80;                  Server 192.168.41.167; } SERVer {listen 8080;                      Location/{Proxy_pass http://myproject;            }}} What are the features of Nginx load balancer? If one of the following servers is broken, it can be automatically identified, the more bull is it good after the Nginx can immediately identify server A and B, if a response time of 3,b response time is 1, then Nginx will automatically adjust the probability of Access B is a 3 times times, really do the nginx load balance good, The installation is complete. I made a mistake when I said that there was a problem with the HTTP Rewrite module, and I just./configure–without-http_rewrite_module and then Make,make install.            OK. After the installation of a new configuration file, the above configuration file to copy the contents, of course, to modify your IP, save for example load_balance.conf and then start:/usr/local/nginx/sbin/nginx-c load_balence . conf because Nginx is the author of the Russian, so the English document is not so perfect, for me the biggest advantage of Nginx is simple configuration, powerful. I used to be a apache-jk, that's really not what the average person can match.            It's too complicated and can only be used to make Tomcat load balancer. Nginx does not have this limit, for it is what the server is completely full name.

The above describes the Apache and Nginx load balancer configuration, including the aspects of the content, I hope that the PHP tutorial interested in a friend to help.

  • Related Article

    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.