"Nginx" uses Nginx to do load balancing

Source: Internet
Author: User
Tags nginx server tomcat server
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.

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.