GCP 中网络和 HTTP(s) 负载均衡器之间的区别是什么
What are the differences between Network and HTTP(s) load balancer in GCP
-
load-balancing
-
google-compute-engine
-
google-cloud-platform
-
google-cloud-network-load-balancer
-
google-cloud-http-load-balancer
GCP 提供了两个负载平衡器,即 Network 和 HTTP(s),其中前者在 layer 4 和后来的工作在 layer 7.
还有一份文档指出,即使是 HTTP 流量也可以通过网络负载平衡器进行负载平衡。这有点混淆了为 GCP 中的 Web 应用程序选择哪个负载均衡器。项目选择之前最好了解一下差异。
根据workflow、setup、region/zone[=,它们有什么区别基于 24=],session affinity 和其他设置的选项?
网络负载均衡器与 HTTP(s) 负载均衡器
+---------------------+------------------------------------------+------------------------------------------------------+
| Category | Network Load Balancing (NLB) | HTTP(S) Load Balancing (HLB) |
+---------------------+------------------------------------------+------------------------------------------------------+
| 1. Region / | NLB supports only within a region. | HLB supports both within cross-region |
| Cross-Region | Does not support cross-region | load balancing. |
| | load balancing | |
+---------------------+------------------------------------------+------------------------------------------------------+
| 2. Load balancing | NLB is based on IP address, port | HLB is based only on HTTP and HTTPS |
| based on | and protocol type. Any TCP/UDP | protocols. |
| | traffic, even SMTP can be | |
| | load balanced. | |
+---------------------+------------------------------------------+------------------------------------------------------+
| 3. Packet | Packet inspection is possible and | HLB cannot inspect packets. |
| inspection | load balance based on packets | |
+---------------------+------------------------------------------+------------------------------------------------------+
| 4. Instance | No need of creating instance group. | Managed / UnManaged Instance group |
| Group | Target pools need to be created. | is necessary for creating HTTP / HTTPS |
| | Instance can be just tagged to the pool. | load balancer. |
| | Ideal for unmanaged instance group | |
| | where instances are non homogeneous. | |
+---------------------+------------------------------------------+------------------------------------------------------+
| 5. Workflow | Forwarding rules is the starting point. | This is quite complex in HTTP(s) load balancer. |
| | It directs the request to the | Global forwarding rulesroutes direct the request |
| | target pools from which compute | to target HTTP proxy, which in turn checks the |
| | engines will pick the request. | URL map to determine appropriate backend |
| | | services. These services in turn direct the request |
| | Forwarding rules -> target pool | to the instance group. |
| | -> instances | |
| | | |
| | | Global forwarding rules -> Target HTTP proxy -> |
| | | URL map -> Backend Sevices -> instance group |
+---------------------+------------------------------------------+------------------------------------------------------+
| 6. Types of | Basic network load balancer which | 1. Cross-region load balancer uses only one |
| load balancer | directs the request based on IP address, | global IP address and routes the request |
| | port and the protocol within the region. | to the nearest region. |
| | | |
| | | 2. Content-based load balancer is based |
| | | on the URL path. Different path rules need |
| | | different backend services. for eg: /video |
| | | and /static require two separate backend services. |
+---------------------+------------------------------------------+------------------------------------------------------+
| 7. Session affinity | Session affinity can be set, but only | 1. Client IP Affinity: This directs the same |
| | during the creation of target pool. | client ip to same backend instance by |
| | Once it is set, the value | computing hash of the IP. |
| | cannot be changed. | 2. Generated Cookie Affinity: Load balancer stores |
| | | cookie in clients and directs the same client to |
| | | same instance with the help of retrieved cookie. |
+---------------------+------------------------------------------+------------------------------------------------------+
| 8. Health check | Health check is optional, but network | Health can be verified by either using HTTP |
| | load balancing relies on HTTP Health | heath check or HTTPS health check. |
| | checks for determining instance health. | |
+---------------------+------------------------------------------+------------------------------------------------------+
以上table是我的观点。如果有任何不正确或遗漏的内容,请随时发表评论,我会将其添加到 table.
这里是 有关在 GCP 中设置 HTTP 负载平衡器 的说明。
此外,我想提一下在 GCP 中选择正确的负载均衡器 (LB) 时需要考虑 3 main aspects:
1) 全球与区域
2) 外部与内部
3) 流量类型
也请查找有关此 chart 的更多信息。
总的来说,下面是网络负载均衡器和 Http 负载均衡器之间的区别。
网络负载均衡器(第 4 层):
这是基于网络变量(例如 IP 地址和目标端口)的流量分配。它位于第 4 层 (TCP) 及以下,并未设计为考虑应用层的任何内容,例如内容类型、cookie 数据、自定义 headers、用户位置或应用程序行为。它是 context-less,只关心它以这种方式定向的数据包中包含的 network-layer 信息。
应用程序负载均衡器(第 7 层)
这是基于多个变量的请求分布,从网络层到应用层。它是 context-aware 并且可以根据任何单个变量直接请求,就像它可以组合变量一样容易。应用程序根据其特殊行为进行负载平衡,而不仅仅是在服务器(操作系统或虚拟化层)上 information.Provides 根据规则、基于主机或基于路径路由 HTTP 和 HTTPS 流量的能力。与 NLB 一样,每个 Target 可以位于不同的端口。
两者之间的另一个区别很重要,因为网络负载平衡不能保证应用程序的可用性。这是因为它的决策完全基于网络和 TCP-layer 变量,并且根本不知道应用程序。通常,网络负载平衡器将根据服务器响应 ICMP ping 或正确完成 three-way TCP 握手的能力来确定“可用性”。应用程序负载平衡器更深入,不仅能够根据特定页面的成功 HTTP GET 确定可用性,而且能够根据输入参数验证内容是否符合预期。
load-balancing
google-compute-engine
google-cloud-platform
google-cloud-network-load-balancer
google-cloud-http-load-balancer
GCP 提供了两个负载平衡器,即 Network 和 HTTP(s),其中前者在 layer 4 和后来的工作在 layer 7.
还有一份文档指出,即使是 HTTP 流量也可以通过网络负载平衡器进行负载平衡。这有点混淆了为 GCP 中的 Web 应用程序选择哪个负载均衡器。项目选择之前最好了解一下差异。
根据workflow、setup、region/zone[=,它们有什么区别基于 24=],session affinity 和其他设置的选项?
网络负载均衡器与 HTTP(s) 负载均衡器
+---------------------+------------------------------------------+------------------------------------------------------+
| Category | Network Load Balancing (NLB) | HTTP(S) Load Balancing (HLB) |
+---------------------+------------------------------------------+------------------------------------------------------+
| 1. Region / | NLB supports only within a region. | HLB supports both within cross-region |
| Cross-Region | Does not support cross-region | load balancing. |
| | load balancing | |
+---------------------+------------------------------------------+------------------------------------------------------+
| 2. Load balancing | NLB is based on IP address, port | HLB is based only on HTTP and HTTPS |
| based on | and protocol type. Any TCP/UDP | protocols. |
| | traffic, even SMTP can be | |
| | load balanced. | |
+---------------------+------------------------------------------+------------------------------------------------------+
| 3. Packet | Packet inspection is possible and | HLB cannot inspect packets. |
| inspection | load balance based on packets | |
+---------------------+------------------------------------------+------------------------------------------------------+
| 4. Instance | No need of creating instance group. | Managed / UnManaged Instance group |
| Group | Target pools need to be created. | is necessary for creating HTTP / HTTPS |
| | Instance can be just tagged to the pool. | load balancer. |
| | Ideal for unmanaged instance group | |
| | where instances are non homogeneous. | |
+---------------------+------------------------------------------+------------------------------------------------------+
| 5. Workflow | Forwarding rules is the starting point. | This is quite complex in HTTP(s) load balancer. |
| | It directs the request to the | Global forwarding rulesroutes direct the request |
| | target pools from which compute | to target HTTP proxy, which in turn checks the |
| | engines will pick the request. | URL map to determine appropriate backend |
| | | services. These services in turn direct the request |
| | Forwarding rules -> target pool | to the instance group. |
| | -> instances | |
| | | |
| | | Global forwarding rules -> Target HTTP proxy -> |
| | | URL map -> Backend Sevices -> instance group |
+---------------------+------------------------------------------+------------------------------------------------------+
| 6. Types of | Basic network load balancer which | 1. Cross-region load balancer uses only one |
| load balancer | directs the request based on IP address, | global IP address and routes the request |
| | port and the protocol within the region. | to the nearest region. |
| | | |
| | | 2. Content-based load balancer is based |
| | | on the URL path. Different path rules need |
| | | different backend services. for eg: /video |
| | | and /static require two separate backend services. |
+---------------------+------------------------------------------+------------------------------------------------------+
| 7. Session affinity | Session affinity can be set, but only | 1. Client IP Affinity: This directs the same |
| | during the creation of target pool. | client ip to same backend instance by |
| | Once it is set, the value | computing hash of the IP. |
| | cannot be changed. | 2. Generated Cookie Affinity: Load balancer stores |
| | | cookie in clients and directs the same client to |
| | | same instance with the help of retrieved cookie. |
+---------------------+------------------------------------------+------------------------------------------------------+
| 8. Health check | Health check is optional, but network | Health can be verified by either using HTTP |
| | load balancing relies on HTTP Health | heath check or HTTPS health check. |
| | checks for determining instance health. | |
+---------------------+------------------------------------------+------------------------------------------------------+
以上table是我的观点。如果有任何不正确或遗漏的内容,请随时发表评论,我会将其添加到 table.
这里是
此外,我想提一下在 GCP 中选择正确的负载均衡器 (LB) 时需要考虑 3 main aspects:
1) 全球与区域
2) 外部与内部
3) 流量类型
也请查找有关此 chart 的更多信息。
总的来说,下面是网络负载均衡器和 Http 负载均衡器之间的区别。
网络负载均衡器(第 4 层): 这是基于网络变量(例如 IP 地址和目标端口)的流量分配。它位于第 4 层 (TCP) 及以下,并未设计为考虑应用层的任何内容,例如内容类型、cookie 数据、自定义 headers、用户位置或应用程序行为。它是 context-less,只关心它以这种方式定向的数据包中包含的 network-layer 信息。
应用程序负载均衡器(第 7 层) 这是基于多个变量的请求分布,从网络层到应用层。它是 context-aware 并且可以根据任何单个变量直接请求,就像它可以组合变量一样容易。应用程序根据其特殊行为进行负载平衡,而不仅仅是在服务器(操作系统或虚拟化层)上 information.Provides 根据规则、基于主机或基于路径路由 HTTP 和 HTTPS 流量的能力。与 NLB 一样,每个 Target 可以位于不同的端口。
两者之间的另一个区别很重要,因为网络负载平衡不能保证应用程序的可用性。这是因为它的决策完全基于网络和 TCP-layer 变量,并且根本不知道应用程序。通常,网络负载平衡器将根据服务器响应 ICMP ping 或正确完成 three-way TCP 握手的能力来确定“可用性”。应用程序负载平衡器更深入,不仅能够根据特定页面的成功 HTTP GET 确定可用性,而且能够根据输入参数验证内容是否符合预期。