What is the connection between nginx reverse proxy and load balancing?
世界只因有你
世界只因有你 2017-05-16 17:21:36
0
4
762

What is the connection between nginx reverse proxy and load balancing?

世界只因有你
世界只因有你

reply all(4)
洪涛
  • Reverse proxy means that the back-end service is not directly exposed to the outside world. The request is first sent to nginx, and then nginx forwards the request to the back-end server, such as tomcat, etc. If the back-end service has only one server, nginx has only one role here. It functions as a proxy for the backend service to receive requests. It is called a reverse proxy.

  • But in real application scenarios, the probability of a single point of failure on a backend server is very high or the throughput of a single machine is limited and cannot handle too many requests. At this time, you need to configure multiple servers on the nginx backend , use the built-in rules of nginx to forward the request to different back-end machines. At this time, it plays the role of load balancing.

Of course I am just speaking roughly, the actual architecture is far more complicated than this. But it is enough to understand the difference.

洪涛

If there is no reverse proxy, the pressure is directly placed on a single http server. With a reverse proxy, typically, one ngnix acts as a reverse proxy, followed by several http servers. Think of ngnix for all traffic. This thing will direct the traffic to the following HTTP server according to the configured policy, either rotation, randomness or pressure distribution. Thus achieving load balancing.

ngnix + node load balancing - SegmentFault - /a/1190000003023558

大家讲道理

Two things:

  • Reverse proxy: The application server does not provide services directly. It processes requests through http(s) servers such as nginx. According to different locations (different domain names, different request paths, etc.), it goes to different application servers (Tomcat, Apache, etc.) Get the response and hand it over to the client. The user looks like the request is processed directly by the nginx server.

  • Load balancing: In a broad sense, it not only refers to http server-level load (the most popular one is to use Nginx), but also includes LVS and operating system-level optimization processing. The purpose is to ensure that the application server responds quickly while It does not cause blocking of the underlying application servers and better utilizes their data processing capabilities.

仅有的幸福

Reverse proxy and load balancing are originally two different things, but nginx only implements several commonly used load balancing algorithms in the backend upstream of the reverse proxy.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template