什么是直通负载平衡器?与代理负载均衡器有何不同? [英] What is pass-through load balancer? How is it different from proxy load balancer?
问题描述
Google Cloud Network负载均衡器是直通负载均衡器,而不是代理负载均衡器. ( https://cloud.google.com/compute/docs/load-balancing /network/).
我通常无法通过LB找到任何资源. HAProxy和Nginx似乎都是代理LB.我猜想通过LB会将客户端直接重定向到服务器.在什么情况下会是有益的?
除了传递和代理之外,是否还有其他类型的负载均衡器?
很难找到用于传递负载平衡的资源,因为每个人都提出了一种不同的调用方式:传递,直接服务器返回(DSR) ,直接路由......
我们在这里称它为直通.
让我尝试解释一下这件事:
-
IP数据包未经修改就转发到了VM,没有地址或端口转换.
-
VM认为负载均衡器IP是其自己的IP之一.
在特定情况下计算引擎网络负载平衡 https://cloud.google .com/compute/docs/load-balancing/:对于Linux,这是通过在本地"路由表中添加到该IP的路由来完成的,Windows是通过在网络接口上添加辅助IP来完成的.
-
路由逻辑必须确保TCP连接或UDP连接"的数据包始终发送到同一VM.
对于GCE网络LB,请参见 https://cloud.google.com/compute/docs/load-balancing/network/target-pools#sessionaffinity
关于其他负载均衡器类型,没有明确的列表,下面是一些示例:
-
NAT. iptables的示例在此处 https://tipstricks.itmatrix. eu/use-iptables-to-balance-web-trafic/.
-
TCP代理.在Google Cloud Platform中,您可以使用TCP代理负载平衡 https: //cloud.google.com/compute/docs/load-balancing/tcp-ssl/tcp-proxy
-
HTTP代理.在Google Cloud Platform中,您可以使用HTTP负载均衡 https://cloud .google.com/compute/docs/load-balancing/http/
-
DNS,称为"DNS转发器".例如:dnsmasq http://www.thekelleys.org.uk/dnsmasq/doc.html ,或以转发"模式进行绑定 https://github.com/mysql/mysql-proxy 的MySQL协议p>
-
SIP协议.此处的实现的主要清单 https://www.voip- info.org/wiki/view/Open+Source+VOIP+Software#SIPProxies
关于直通相对于其他方法的优势:
-
如果IP数据包上的地址正在更改,例如SIP协议,则某些应用程序将无法运行或需要进行修改.有关与NAT https://en不能很好地配合使用的应用程序的更多信息,请参见Wikipedia. .wikipedia.org/wiki/Network_address_translation#NAT_and_TCP/UDP .
此处的优点是传递不更改源IP和目标IP.
请注意,负载均衡器可以在较高的层上工作以保留IP:在连接到后端时,负载均衡器会欺骗客户端的IP.在撰写本文时,没有负载均衡产品在Compute Engine中使用此方法.
-
如果您需要对客户端的TCP连接进行更多控制,例如调整TCP参数.这是通过TCP(或更高层)代理的直通或NAT的优势.
Google Cloud Network load balancer is a pass-through load balancer and not a proxy load balancer. ( https://cloud.google.com/compute/docs/load-balancing/network/ ).
I can not find any resources in general on a pass through LB. Both HAProxy and Nginx seems to be proxy LBs. I'm guessing that pass through LB would be redirecting the clients directly to the servers. In what scenarios it would be beneficial?
Are there any other type of load balancers except pass-through and proxy?
It's hard to find resources for pass-through load balancing because everyone came up with a different way of calling it: pass-though, direct server return(DSR), direct routing,...
We'll call it pass-through here.
Let me try to explain the thing:
The IP packets are forwarded unmodified to the VM, there is no address or port translation.
The VM thinks that the load balancer IP is one of its own IPs.
In the specific case of Compute Engine Network Load Balancing https://cloud.google.com/compute/docs/load-balancing/: For Linux this is done by adding a route to this IP in the "local" routing table, Windows by adding a secondary IP on the network interface.
The routing logic has to make sure that packets for a TCP connection or UDP "connection" are always sent to the same VM.
For GCE network LB see here https://cloud.google.com/compute/docs/load-balancing/network/target-pools#sessionaffinity
Regarding other load balancer types there can't be a definitive list, here are a few examples:
NAT. An example with iptables is here https://tipstricks.itmatrix.eu/use-iptables-to-load-balance-web-trafic/.
TCP Proxy. In Google Cloud Platform you can use TCP Proxy Load Balancing https://cloud.google.com/compute/docs/load-balancing/tcp-ssl/tcp-proxy
HTTP Proxy. In Google Cloud Platform you can use HTTP(s) Load Balancing https://cloud.google.com/compute/docs/load-balancing/http/
DNS, called "DNS forwarder". For example: dnsmasq http://www.thekelleys.org.uk/dnsmasq/doc.html, or bind in "forwarding" mode https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-caching-or-forwarding-dns-server-on-ubuntu-14-04
Database communication protocols. For example the MySQL Protocol with https://github.com/mysql/mysql-proxy
SIP protocol. Big list of implementations here https://www.voip-info.org/wiki/view/Open+Source+VOIP+Software#SIPProxies
As for the advantages of pass-through over other methods:
Some applications won't work or need to be adapted if the addresses on the IP packets is changing, for example the SIP protocol. See the Wikipedia for more on applications that don't play along well with NAT https://en.wikipedia.org/wiki/Network_address_translation#NAT_and_TCP/UDP.
Here the advantage pass-through is that it does not change the source and destination IPs.
Note that there is a trick for a load balancer working at a higher layer to keep the IPs: the load balancer spoofs the IP of the client when connecting to the backends. As of this writing no load balancing product uses this method in Compute Engine.
If you need more control over the TCP connection from the client, for example to tune the TCP parameters. This is an advantage of pass-through or NAT over TCP (or higher layer) proxy.
这篇关于什么是直通负载平衡器?与代理负载均衡器有何不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!