This document is the first step in setting up an HTTP(S) load balancer. Before you start, make sure that you are familiar with overall HTTP(S) Load Balancing concepts.
Google Cloud Platform (GCP) HTTP(S) Load Balancing provides global load balancing for HTTP(S) requests destined for your instances.
Global load balancing requires that you use the Premium Tier of Network Service Tiers.
You can configure URL rules that route some URLs to one set of instances and route other URLs to other instances. Requests are always routed to the instance group that is closest to the user, provided that group has enough capacity and is appropriate for the request. If the closest group does not have enough capacity, the request is sent to the closest group that does have capacity.
HTTP(S) Load Balancing supports both IPv4 and IPv6 addresses for client traffic. Client IPv6 requests are terminated at the load balancing layer, then proxied over IPv4 to your backends.
HTTP requests can be load balanced based on port 80 or port 8080. HTTPS requests can be load balanced on port 443.
The load balancer acts as an HTTP/2 to HTTP/1.1 translation layer, which means that the web servers always see and respond to HTTP/1.1 requests, but that requests from the browser can be HTTP/1.0, HTTP/1.1, or HTTP/2. HTTP/2 server push is not supported.
Before you begin
HTTP(S) Load Balancing uses instance groups to organize instances. Make sure you are familiar with instance groups before you use load balancing.
If you want to jump right in and build a working load balancer for testing, the following diagrams demonstrate three different scenarios using the HTTP(S) Load Balancing service. These scenarios provide a practical context for HTTP(S) Load Balancing and demonstrate how you might set up load balancing for your specific needs.
The rest of this page discusses more details about how load balancers are constructed and how they work.
Cross-region load balancing
You can use a global IP address that can intelligently route users based on proximity. For example, if you set up instances in North America, Europe, and Asia, users around the world will be automatically sent to the backends closest to them, assuming those instances have enough capacity. If the closest instances do not have enough capacity, cross-region load balancing automatically forwards users to the next closest region.
Content-based load balancing
Content-based or content-aware load balancing uses HTTP(S) Load Balancing to
distribute traffic to different instances based on the incoming HTTP(S) URL. For
example, you can set up some instances to handle your video
content and another set to handle everything else. You can configure your load
balancer to direct traffic for
example.com/video to the video servers
example.com/ to the default servers.
Creating a combined load balancer
Content-based and cross-region load-balancing can work together by using multiple backend services and multiple regions. You can build on top of the scenarios above to configure your own load balancing configuration that meets your needs. The HTTP(S) load balancing tutorial shows you how to generate a load balancing configuration that is both content-based and cross-regional.
Your HTTP(S) Load Balancing service can be configured and updated through the following interfaces:
gcloudcommand-line tool: a command-line tool included in the Cloud SDK. The HTTP(S) Load Balancing documentation calls on this tool frequently to accomplish tasks. For a complete overview of the tool, see the gcloud Tool Guide. You can find commands related to load balancing in the
gcloud computecommand group.
You can also get detailed help for any
gcloudcommand by using the
gcloud compute http-health-checks create --help
The Google Cloud Console: Load balancing tasks can be accomplished through the Google Cloud Console.
The REST API: All load balancing tasks can be accomplished using the Cloud Load Balancing API. The API reference docs describe the resources and methods available to you.
Notes and Restrictions
- HTTP(S) Load Balancing supports the
HTTP/1.1 100 Continueresponse.
- If your load balanced instances are running a public operating system image supplied by Google Cloud Platform, then firewall rules in the operating system will be configured automatically to allow load balanced traffic. If you are using a custom image, you have to configure the operating system firewall manually. This is separate from the GCP firewall rule that must be created as part of configuring an HTTP(S) load balancer.
- Load balancing does not keep instances in sync. You must set up your own mechanisms, such as using Deployment Manager, for ensuring that your instances have consistent configurations and data.
- Create a content-based and cross-regional HTTP(S) load balancer.
- Add backend buckets to a load balancer.
- Read conceptual information about HTTP(S) Load Balancing.
- Read about forwarding rules.
- Read about setting up URL maps or read conceptual information about URL maps
- Configure SSL certificates
- Create SSL policies