First, the preface
The previous article briefly describes how to install Nginx, the method is very simple, the operation is also very convenient. The above mentioned Nginx can do HTTP server, virtual host, load balance. In this blog small and medium-sized to tell you how to use Nginx to do load balancing. second, load balance
First we need to know what load balancing is.
Based on the existing network architecture, load Balancing provides an inexpensive, efficient and transparent way to extend the bandwidth of network devices and servers, increase throughput, enhance network data processing capabilities, and improve network flexibility and availability.
Load balancing, the English name is load Balance, the meaning is to spread to multiple operations unit for execution, such as Web server, FTP server, enterprise key Application server and other mission-critical servers, and so on to work together to complete the task. "Baidu Encyclopedia"
The core of load balancing is: balancing load to three, Nginx load balance
For Nginx, he can forward the submitted request. The architecture is as follows:
The schema diagram explains: In this diagram, the user submits the request to the Nginx server, then forwards the requests by nginx, forwards them to each tomcat server, and then the Tomcat makes logical processing.
And Nginx is how to do it. First, the address of each Tomcat server is written in Nginx, and the architect can increase the level of use of Tomcat based on its performance. Nginx only need to be configured in nginx.conf:
You only need to add a weight after the Upostream server to represent the weights. The larger the weight, the more the number of allocation requests. The default is 1 when not written.
The configuration process is as follows:
1.Nginx of configuration
Configure a server in Nginx: Use domain name way to reverse proxy, the domain name used here is tomcat.taotao.com, the user can access this domain name, submit to Nginx first.
2.tomcat Configuration
Open two Tomcat and the ports are as follows:
Nginx based on the path accessed by Proxy_pass to determine which server is accessed, and automatically assigns the selected according to the weight. The right to deal with a significant probability of high. Iv. Summary
Through this study nginx load balance, the focus is to lead to a weight, the greater the weight of the request to deal with more.
Well, the next blog will introduce you to Nginx's reverse proxy function.