GCP - GOOD - 11 - Hybrid Load Balancing and Traffic Management - ILT
GCP - GOOD - 11 - Hybrid Load Balancing and Traffic Management - ILT
Cloud
02
Today’s
Hybrid load balancing
03 Traffic management
05 Quiz
We’ll begin with an overview of Cloud Load Balancing. We will continue with a
discussion of hybrid load balancing. In other words, load balancing between Google
Cloud, other public clouds, and on-premises environments.
A load balancer, as the name suggests, balances load across multiple instances of
your applications.
Cloud Load Balancing receives client traffic. This traffic can be external or internal,
depending on the load balancer you use. A backend configuration distributes requests
to healthy backends.
One or more backends must be connected to the backend service or backend bucket.
Client
of services or workloads.
Cloud Load Balancing can route traffic to either a backend service or a backend
bucket. The backend services define how to handle the traffic. For example, backend
services define how the traffic is distributed, which health check to use, and if session
affinity is used. Backend services also define which other Google Cloud services to
use, such as Cloud CDN or Identity-Aware Proxy. On the other hand, backend
buckets direct incoming traffic to Cloud Storage buckets. Backend buckets are useful
in serving static content. We will discuss this in more detail in the upcoming section.
Regional Regional
Global Regional Regional Cross-region
external internal
external proxy external proxy internal proxy internal proxy
passthrough passthrough
Network Load Network Load Network Network Load
Network Load Network Load
Balancer Balancer Load Balancer Balancer
Balancer Balancer
Google Cloud Platform offers a range of load balancing solutions that can be
classified based on the OSI model layer they operate at and their specific
functionalities.
These load balancers are designed to handle HTTP and HTTPS traffic, making them
ideal for web applications and services that require advanced features like
content-based routing and SSL/TLS termination. Application Load Balancers operate
as reverse proxies, distributing incoming traffic across multiple backend instances
based on rules you define. They are highly flexible and can be configured for both
internet-facing (external) and internal applications.
Network Load Balancers operate at the transport layer and efficiently handle TCP,
UDP, and other IP protocols. They can be further classified into two types:
Proxy Load Balancers: These also function as reverse proxies, terminating client
connections and establishing new ones to backend services. They offer advanced
traffic management capabilities and support backends located both on-premises and
in various cloud environments.
Passthrough Load Balancers: Unlike proxy load balancers, these do not modify or
terminate connections. Instead, they directly forward traffic to the backend while
preserving the original source IP address. This type is well-suited for applications that
require direct server return or need to handle a wider range of IP protocols.
Network endpoint groups (NEGs)
Cloud Load
Balancing
You can use NEGs as backends for some load balancers and with Traffic Director.
There are five types of NEGs:
● Zonal NEGs define how endpoints should be reached, whether they are
reachable, and where they are located. A zonal NEG contains one or more
endpoints that can be Compute Engine virtual machines (VMs) or services that
run on the VMs. Each endpoint is specified either by an IP address or an
IP:port combination.
● An internet NEG contains a single endpoint that is hosted outside of Google
Cloud. This endpoint is specified by hostname FQDN:port or IP:port.
● A serverless NEG is a backend that points to a Cloud Run, App Engine,
Cloud Functions, or API Gateway service that resides in the same region as
the NEG.
● A Private Service Connect NEG contains a single endpoint. That endpoint
resolves to either a Google-managed regional API endpoint or a managed
service published by using Private Service Connect.
● A hybrid connectivity NEG points to Traffic Director services that run outside
● of Google Cloud (on-premises or other public cloud backends). The focus in
this module is on hybrid connectivity NEGs.
For more information on using NEGs, and a complete list of supported load
balancers, please refer to the Network endpoint groups overview in the Google Cloud
documentation.
01 Load balancing
02
Today’s
Hybrid load balancing
03 Traffic management
05 Quiz
● A hybrid strategy lets you extend Cloud Load Balancing to workloads that run on your
existing infrastructure outside of Google Cloud.
A hybrid load balancing lets you extend Cloud Load Balancing to workloads that run
on your existing infrastructure outside of Google Cloud. A hybrid strategy is a
pragmatic solution for you to adapt to changing market demands and incrementally
modernize the backend services that run your workloads. You can create a hybrid
deployment to enable migration to a modern cloud-based solution or a permanent
fixture of your organization IT infrastructure.
Client Client
Internal
Client
On-premises data
center
Service
Cloud Load
Balancing External
Client
In this example, traffic from clients on the public internet enters your private on-premises
environment, and traffic from another public cloud provider enters through a Cloud load
balancer. The load balancer also gets requests from internal clients.
The load balancer sends requests to the services that run your workloads. These
services are the load balancer endpoints, and they can be located inside or outside of
Google Cloud. You configure a load balancer backend service to communicate to the
external endpoints by using a hybrid NEG. The external environments can use Cloud
Interconnect or Cloud VPN to communicate with Google Cloud. The load balancer
must be able to reach each service with a valid IP address:Port combination.
The example shows a load balancer backend service with a hybrid and a zonal NEG.
The hybrid NEG connects to endpoints that are on-premises and in other public
clouds. The zonal NEG points to Cloud Endpoints in the same subnet and zone.
Configuring backend services
outside of Google Cloud asia-south1-a
Cloud Load
● Configure one or more hybrid connectivity network Balancing
Backend Backend
A hybrid load balancer requires special configuration only for the backend service.
The frontend configuration is the same as any other load balancer.
To configure backend services outside of Google Cloud, first configure one or more
hybrid connectivity network endpoint groups (NEG).
Create the NEG in a Google Cloud zone that is as close as possible to your other
environment. For example, if you’re hosting a service in an on-premises environment
in Bengaluru, India, you can place the NEG in the asia-south1-a Google Cloud zone,
as shown in the example.
Add the hybrid connectivity NEGs to a hybrid load balancer backend. A hybrid
connectivity NEG must only include endpoints outside Google Cloud. Traffic might be
dropped if a hybrid NEG includes endpoints for resources within a Google Cloud VPC
network.
Types of load balancers that support
hybrid load balancing
Regional Cross-region
Global external Classic
external internal
Application Application
Application Application
Load Balancer Load Balancer
Load Balancer Load Balancer
Regional Cross-region
Regional internal Global External Regional internal
External proxy internal proxy
Application proxy Network proxy Network
Network Load Network Load
Load Balancer Load Balancer Load Balancer
Balancer Balancer
You choose a load balancer depending on your needs, such as where the clients and
workloads are located.
Caveats: Hybrid load balancing
To create, delete, or manage a load balancer with mixed zonal and hybrid connectivity
NEGs backends in a single backend service, you must use the Google Cloud CLI or
the REST API.
Regional dynamic routing and static routes are not supported. The Cloud Router used
for hybrid connectivity must be enabled with global dynamic routing.
The internal Application Load Balancer and hybrid connectivity must be configured in
the same region. If they are configured in different regions, you might see backends
as healthy, but client requests will not be forwarded to the backend.
Ensure that you also review the security settings on your hybrid connectivity
configuration. Currently, HA Cloud VPN connections are encrypted by default, using
IPsec encryption. Cloud Interconnect connections are not encrypted by default. For
more details, go to Encryption in Transit in Google Cloud on the Google Cloud
website.
01 Load balancing
02
Today’s
Hybrid load balancing
03 Traffic management
05 Quiz
http://cymbal.com/hd/abc.html
Cloud Load
Balancing
Bola, a Cloud Network Engineer at Cymbal Corporation, is responsible for maintaining their
video streaming platform. The website accesses the Cymbal store infrastructure using Cloud
Load Balancing. To optimize performance and costs, they want to route user traffic to different
server backends based on the requested video quality (e.g., 4K versus HD). What should Bola
do?
Traffic management
Bola can benefit from Traffic management . Traffic management provides enhanced
features to route load balancer traffic based on criteria that you specify.
The traffic features that are available can vary per load balancer. Check the Google
Cloud documentation for details, for example, Traffic management overview for a
classic Application Load Balancer, Traffic management overview for global external
Application Load Balancers, and Traffic management overview for regional external
Application Load Balancers.
Recall that, in addition to traffic management, Cloud Load Balancing offers backend
services like health checks, session affinity, balancing mode, and capacity scaling.
Supported load balancers
These load balancers support traffic management: global external Application Load
Balancer, global external classic Application Load Balancer, internal Application Load
Balancer and the regional external Application Load Balancer. Other load balancers
have access to only traffic features available in backend services, such as balancing
mode and session affinity.
Not all load balancers support all traffic management features. For a complete list of
traffic management features supported for each load balancer, refer to Routing and
traffic management in the Google Cloud documentation.
URL map
The URL map contains rules that define the criteria to use to route incoming traffic to
a backend service or backend bucket. Traffic management features are configured in
a URL map. In other words, the load balancer uses the URL map to determine where
to route incoming traffic. When you configure routing, you can choose between the
following modes:
Each URL map can contain only one mode or the other mode.
URL map workflow
URL map
URL map
Default backend
Path matcher
Host rule All other path
Default backend
Host rule
match
A request is first evaluated based on the host rule. If the domain matches a defined
host rule, the system uses its associated path matcher to further refine routing. Each
host rule consists of a list of one or more hosts and a single path matcher
(pathMatcher). If no hostRules are defined, the request is routed to the
defaultService. The request's path is compared against available path rules, with the
longest, most specific match taking priority. Path rules are evaluated on a
longest-path-matches-first basis. You can specify the path rules in any order.
Once the best match is found, the request is sent to the corresponding backend
service. If no specific host and path rules apply, the request is handled by the default
backend service. This setup allows you to create custom routing rules, like sending
video-related requests to a dedicated service while directing general traffic to a
different backend.
Bola can use URL maps to distribute traffic
cymbal.com/video/ video-site
Host rule All other path Path macher
Default backend
matches:
cymbal.com
cymbal.com/video/hd/
video-hd
Path-matcher Path Rule 2
(HD Processing)
cymbal.com/video/4k/
video-4k
Path Rule 3
(4k processing)
Going back to the scenario, Bola can use the URL map to distribute traffic.
The host rule is cymbal.com, which means any host other than cymbal.com (example,
cymbal.org, cymbal,net) are directed to the default service. Once the host name,
cymbal.com matches, the URL is matched for a Path rule:
- The default backend service is video-site.
- Requests with the exact URL path /video/hd/ are directed to the video-hd
backend service.
- Requests with the exact URL path /video/4k/ are directed to the video-4k
backend service.
A simple URL map
defaultService:https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/org-site
fingerprint: mfyJIT7Zurs=
hostRules:
- hosts:
- '*'
pathMatcher: pathmap
name: video-org-url-map
pathMatchers:
- defaultService:https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/video-site
name: pathmap
pathRules:
- paths:
- /video/hd
service: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/video-hd
- paths:
- /video/4K
service: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/video-4k
On this slide, you see a URL map that routes video traffic to the example we covered
in the previous slides. This example is shown by using a YAML file. You can also use
the Google Cloud console to configure URL maps.
The hostRules defines a list of hostnames that are processed by this rule. In this
example, there’s only one item in the list, which means that only one host rule is
defined. This host rule contains an asterisk (*). The asterisk is a wildcard, which
matches all hosts.
To see where to find the matching logic to use, look at the value of pathMatcher.
For this host rule, pathMatcher is set to pathmap. Here’s a pathMatchers list,
which contains a list of path matching rules. The only element in this list is pathmap.
Each match rule defines logic to process the traffic that is sent to the backend service.
In this example, there are two sets of paths. One paths list defines valid URL paths
for the video-hd. The other paths list defines valid URL paths for the video-4k. If
the URL contains a match for one of these paths lists, the load balancer routes the
traffic to the corresponding service.
If the traffic contains a path that matches none of the paths lists, then it’s sent to the
default backend service, video-site. In other words, the traffic is sent to the service
denoted by pathMatchers/defaultService. For additional details, refer to the
documentation.
Advanced routing mode
The advanced routing mode can choose a rule based on a defined priority and
includes additional configuration options. Instead of path rules, advanced routing uses
route rules.
Each URL map can include either simple or advanced rules, but not both.
An advanced routing mode URL map
defaultService: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/service-a
hostRules:
- hosts:
- '*'
pathMatcher: matcher1
name: lb-map
pathMatchers:
- defaultService: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/service-b
name: matcher1
routeRules:
- matchRules:
- prefixMatch: ''
routeAction:
weightedBackendServices:
- backendService: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/service-a
weight: 95
- backendService: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/service-b
weight: 5
This URL map contains rules that route 95% of the traffic to service-a, and 5% of
the traffic is routed to service-b.
The example shows a YAML implementation of an advanced routing mode . You can also
use the Google Cloud console to configure URL maps.
When no matching host rule is found, the defaultService defines a service to use.
The field defaultService is required.
The hostsRules works the same way as for simple routing mode. As in the previous
example, this host rule uses the asterisk to match all hosts. Because pathMatcher
is set to matcher1, /pathMatchers/matcher1 defines the matching logic.
Advanced routing mode: pathMatchers
pathMatchers:
- defaultService:
https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/service-b
name: matcher1
routeRules:
- matchRules:
- prefixMatch: ''
routeAction:
weightedBackendServices:
- backendService:
https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/service-a
weight: 95
- backendService:
https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/service-b
weight: 5
In this example, there's only one item in matchRules, where prefixMatch equals
an empty string. The prefixMatch condition matches the URL path prefix; URLs
that start with the same string match. In the example, the prefixMatch is the empty
string, which matches all URLs. In other words, all URLs trigger this match rule, and
the routeAction is applied.
The routeAction defines how the traffic is routed. In the example, the
routeAction is set to weightedBackendServices.
weightedBackedServices is a list of backend services. A weight value is specified
for each backend service; representing a percentage of the total traffic. 95% of the
traffic is sent to service-a, and 5% of the traffic is sent to service-b.
The routeAction can also define traffic policies, such as retry policies and CORS.
For a complete list of routeAction values, refer to the Google Cloud documentation
for the load balancer that you’re using.
defaultService
defaultService: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/service-a
hostRules:
- hosts:
- '*' Used if there's no matching host rule.
pathMatcher: matcher1
name: lb-map
pathMatchers:
- defaultService: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/service-b
name: matcher1
routeRules:
- matchRules: Used if there's a matching host rule
- prefixMatch: '' but there's no matching route rule.
routeAction:
weightedBackendServices:
- backendService: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/service-a
weight: 95
- backendService: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/service-b
weight: 5
In this example, you might notice that there are two defaultService key-value
pairs. One defaultService is associated with the hostRules, and the other is
associated with the routeRules.
Not all load balancers support all traffic management features. For a complete list of
traffic management features supported for each load balancer, refer to Routing and
traffic management in the Google Cloud documentation.
Wildcards are supported, but only after a forward slash (/). For example, /video/* is
valid and /video* is invalid.
Rule matching does not use regular expressions or substring matching. For example,
/videos/hd/* does not match /videos/hd-pdq, because -pdq is a substring and
also because it comes after the forward slash. /videos/* matches
/videos/hd-pqd.
Let’s ask Gemini
You are a patient and friendly Google Cloud technical support engineer who
specializes in cloud networking and responds to customer's questions.
As a Google Cloud technical support engineer who specializes in cloud networking, I can
confirm that the most reliable load balancer in Google Cloud is Network Load Balancing
(NLB).
You can also use Gemini to learn more. One trick to get a better response is to assign
Gemini a role.
Prime the model to assume a specific role (also known as a persona). Adding a role is
not always necessary but can enforce a certain level of expertise when generating a
response, improve performance, and tailor its communication style. This technique is
particularly useful for getting the model to perform highly technical tasks or enforcing
specific communication styles.
The example on slide shows a sample prompt where Gemini assumes the role of a
Google Cloud technical support engineer.
01 Load balancing
02
Today’s
Hybrid load balancing
03 Traffic management
05 Quiz
We’ll begin with an overview of Cloud Load Balancing. We will continue with a
discussion of hybrid load balancing. In other words, load balancing between Google
Cloud, other public clouds, and on-premises environments.
In this lab, you create a regional internal Application Load Balancer with two
backends. Each backend will be an instance group. You will configure the load
balancer to create a blue-green deployment.
The blue deployment refers to the current version of your application. The green
deployment refers to a new application version. In this lab exercise, you configure the
load balancer to send 70% of the traffic to the blue deployment and 30% to the green
deployment.
01 Load balancing
02
Today’s
Hybrid load balancing
03 Traffic management
05 Quiz
We’ll begin with an overview of Cloud Load Balancing. We will continue with a
discussion of hybrid load balancing. In other words, load balancing between Google
Cloud, other public clouds, and on-premises environments.
When you use the internal IP address of the forwarding rule to specify an internal Network
Load Balancer next hop, the load balancer can only be:
A. In the same VPC network as the next hop route.
B. In the same VPC network as the next hop route or in a peered VPC network.
C. In the same subnet as the next hop route.
D. In the same subnet as the next hop route or a Shared VPC network.
Quiz | Question 2
Question
Explanation:
A. That’s incorrect. Although you can connect these environments, this answer is
not complete.
B. That’s incorrect. Although you can connect these environments, this answer is
not complete.
C. That’s incorrect. Although you can connect these environments, this answer is
not complete.
D. Correct. You can connect any destination that you can reach by using a
Google hybrid connectivity product and that can be reached with a valid
IP:Port combination.
Debrief
We then talked about using traffic management with your load balancers. You learned
which load balancers support traffic management features. You were introduced to the
URL map, where you configure traffic management features. We walked through a
simple example of traffic management. In the example, you saw how to configure a
URL map to match against incoming traffic and specify where the traffic should be
sent.