Apache and nginx server load balancer configuration

Source: Internet
Author: User
Tags nginx load balancing
: This article mainly introduces apache and nginx server load balancer configurations. For more information about PHP Tutorial, see.
I. apache server load balancer is actually very powerful in operating apache. Recently, I have studied apache reverse proxy and server load balancer, the Internet egress of the reverse proxy network Association and the exit of my blog are implemented through the reverse proxy of apache. to sum up, we will focus on the configuration of server load balancer. Operating system: DEBIAN 5.03 (Ubuntu can also be configured in the same way) (1). configure the polling balancing policy to enter the conf directory of Apache and open httpd. conf file. add ProxyPass/balancer: // proxy/# to the end of the file.
 
  
BalancerMember http://www.php186.com/BalancerMember http://www.php186.com/
 Observe the preceding parameter "ProxyPass/balancer: // proxy/". "ProxyPass" indicates the command to configure the virtual server. "/" indicates the URL prefix of the Web request, for example: http: // myserver/or http: // myserver/aaa, these URLs will comply with the above filter conditions; "balancer: // proxy/" indicates that you want to configure server load balancer, the proxy indicates the name of the server load balancer instance. the BalancerMember and its URL indicate the backend server to be configured. the URL is the URL requested by the backend server. The preceding configuration is used as an example to describe how server load balancer works. assume that Apache receives an http: // localhost/aaa request, because the request meets the ProxyPass condition (the URL prefix is "/"), the request will be distributed to a BalancerMember in the background. for example, the request may be forwarded to http://www.php186.com/aaafor 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://www.php186.com /. The load balancing mechanism is realized after such a loop. (2) configure the balance policy by weight: ProxyPass/balancer: // proxy/# note that the configuration ends "/"
 
  
BalancerMember http://www.php186.com/loadfactor = 3 BalancerMember http://www.php186.com/loadfactor = 1
 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, the request is separately loaded to the backend server, and three consecutive such requests are loaded to the server where BalancerMember is the http://www.php186.com, and one such request is load BalancerMember as http: // www.php186.com background server. Implements a balance policy that distributes weights continuously. (3) configure ProxyPass/balancer: // proxy/lbmethod = bytraffic in the response policy of the weight request
 
  
BalancerMember http://www.php186.com/loadfactor = 3 BalancerMember http://www.php186.com/loadfactor = 1
 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. Load balancing is performed according to the above configuration. suppose Apache receives http://myserver/aaa Request: forward the request to the backend server. if the BalancerMember is http: // www.php186.com backend server loads the request, the number of bytes it processes the request and response is http: // three times of the www.php186.com server (recall (2) the server load balancer configuration, (2) the server load balancer is weighted by the number of requests, and (3) the server load balancer is weighted by traffic, this is the biggest difference ). Note: Use apachectl-k restart to restart Apache every time you modify httpd. conf. 2. Nginx server load balancer is developed by the Rambler.ru site with the highest access volume in Russia by Igor Sysoev. it has been running on this site for more than two and a half years. Igor publishes source code in the form of a class BSD license. Despite being a beta version, Nginx is well known for its stability, rich feature sets, sample configuration files, and low system resource consumption. First, the configuration is very simple and powerful. It's time to see each other. Let's take a look at how to write the configuration file worker_processes 1; events {worker_connections 1024;} http {upstream myproject {# specify multiple source servers, ip: Port, port 80 can be written but not to server 192.168.43.158: 80; server 192.168.41.167;} server {listen 8080; location/{proxy_pass http://myproject ; }}} What functions does Nginx server load balancer provide? If one of the backend servers is broken, it can be automatically identified. even better, Nginx can immediately identify servers A and B. If the response time of A is 3, if the response time of B is 1, Nginx automatically adjusts the probability of access to B to three times that of A. the installation is complete after Nginx load balancing is completed. I reported an error when making, saying that there is a problem with the HTTP Rewrite module, I will./configure-without-http_rewrite_module and then make, make install. After installation, create a new configuration file and copy the content of the above configuration file. of course, modify your IP address, save it as load_balance.conf, and start it: /usr/local/Nginx/sbin/Nginx-c load_balence.conf the Nginx author is Russian, so the English documents are not so complete. for me, the biggest advantage of Nginx is that the configuration is simple, powerful functions. I used to configure apache-jk, which is really not suitable for normal users. It is too complicated and can only be used for tomcat Nginx load balancing. Nginx does not have this restriction. for it, what server is next is completely transparent.

The above describes the apache and nginx server load balancer configurations, including the content, and hope to be helpful to anyone interested in the PHP Tutorial.

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.