nginx 4层负载均衡
When deploying a back end application you might need to have multiple instances for handling large traffic. A load balancer is used to manage these large number of requests between the multiple servers.
部署后端应用程序时,您可能需要具有多个实例来处理大量流量。 负载平衡器用于管理多个服务器之间的大量请求。
Layer 7 load balancing operates at the high‑level application layer. It can make a load‑balancing decision based on the content of the message (the URL or cookie, for example). It then makes a new TCP connection to the selected upstream server (or reuses an existing one, by means of HTTP keepalives) and writes the request to the server.
第7层负载平衡在高层应用程序层上运行。 它可以根据消息的内容(例如URL或cookie)做出负载平衡决策。 然后,它与选定的上游服务器建立新的TCP连接(或通过HTTP keepalive复用现有的服务器),并将请求写入服务器。
A device that performs Layer 7 load balancing is often referred to as a reverse‑proxy server.
执行第7层负载平衡的设备通常称为反向代理服务器 。
The Client doesn’t connect to a server directly. The request from the clients is received by the load balancer. The load balancer decides to which server the request will be sent. The server receives the request and sends back the response to the load balancer which forwards the response to the client over port 80.
客户端不直接连接到服务器。 来自客户端的请求由负载均衡器接收。 负载平衡器决定将请求发送到哪个服务器。 服务器接收请求,并将响应发送回负载平衡器,负载平衡器将响应通过端口80转发给客户端。
Below is an example. Consider a load balancer which manages traffic between three servers. The load balancer is using a round-robin algorithm for this purpose.
下面是一个例子。 考虑一个负载均衡器,它管理三个服务器之间的流量。 负载均衡器为此使用循环算法。