Starting April 29, 2025, Gemini 1.5 Pro and Gemini 1.5 Flash models are not available in projects that have no prior usage of these models, including new projects. For details, see Model versions and lifecycle.
Stay organized with collections
Save and categorize content based on your preferences.
In this step, you create an Application Load Balancer
to distribute the traffic to backend instances hosted on Cloud Run.
In the load balancer configuration, you define the routing rules, which
determine how the load balancer directs the traffic. Routing rules include host
rules and path matches, which constitute the configuration components of an external
Application Load Balancer's URL map.
Note that to complete this step, you must have a valid domain name or a
valid self-managed certificate.
Create a load balancer for the Cloud Run service
In the Google Cloud console, go to the Load balancing page.
PRIORITY: Specify the priority of the backend service by
which the route rules are evaluated. In this scenario, set this to any
value because you created only one backend service.
Click Done.
Click Review and finalize to review the configuration and create the load balancer.
Review and finalize
Review the load balancer configuration.
To create the load balancer, click Create.
Add the IP address to the domain DNS records
Update the DNS records of your domain to point to the reserved IP address that was
created for your load balancer. You might have to contact the administrator
of your domain to complete this step.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-29 UTC."],[],[],null,["# Step 3: Create a load balancer\n\nIn this step, you create an [Application Load Balancer](/load-balancing/docs/application-load-balancer)\nto distribute the traffic to backend instances hosted on Cloud Run.\nIn the load balancer configuration, you define the routing rules, which\ndetermine how the load balancer directs the traffic. Routing rules include host\nrules and path matches, which constitute the configuration components of an external\nApplication Load Balancer's [URL map](/load-balancing/docs/url-map-concepts).\n\nNote that to complete this step, you must have a valid domain name or a\nvalid self-managed certificate.\n\nCreate a load balancer for the Cloud Run service\n------------------------------------------------\n\n1. In the Google Cloud console, go to the **Load balancing** page.\n\n [Go to Load balancing](https://console.cloud.google.com/net-services/loadbalancing/list/loadBalancers)\n2. Click **Create load balancer**.\n\n3. In the **Type of load balancer** section, click **Application Load Balancer (HTTP/HTTPS)** , and then click **Next**.\n\n4. In the **Public facing or internal** section, click **Public facing (external)** , and then click **Next**.\n\n5. In the **Global or single region deployment** section, click **Best for global workloads** , and then click **Next**.\n\n6. In the **Load balancer generation** section, click **Global external Application Load Balancer** , and then click **Next**.\n\n7. Click **Configure**.\n\n8. In the **Load Balancer name** field, enter `gemini-streamlit-app-lb`.\n\n9. Configure the load balancer by completing the **Frontend configuration** , **Backend configuration** , and **Routing rules** sections.\n\n### Frontend Configuration\n\n1. Specify the following **Frontend configuration**:\n\n - **Name** : Enter `gemini-streamlit-app-frontend`.\n\n - **Protocol** : Select **HTTPS (includes HTTP/2 and HTTP/3)**.\n\n - **Network Service Tier** : Set the **IP address** by [reserving a new external static IP address](/load-balancing/docs/https/setup-global-ext-https-serverless#ip-address). While reserving the new IP address, specify `genai-app-ip` as the **Name**.\n\n - **Certificate**: Perform the following steps to create a new Google-managed certificate:\n\n 1. Click **Create a new certificate**.\n\n 2. Specify the following details:\n\n - **Name** : Enter `my-genai-app-certificate`.\n\n - **Create mode** : Click **Create Google-managed certificate**.\n\n - **Domains**: Enter the domain name for provisioning the certificate.\n\n 3. Click **Create**.\n\n For more information about Google-managed SSL certificates, see\n [Use Google-managed SSL certificates](/load-balancing/docs/ssl-certificates/google-managed-certs).\n\n \u003c!-- --\u003e\n\n - Select the **Enable HTTP to HTTPS redirect** checkbox.\n2. Click **Done**.\n\n3. Click **Backend configuration** to configure the backend.\n\n### Backend configuration\n\n1. Click the **Backend services \\& backend buckets** list and then click\n CEnter the following details:\n\n - **Name** : Enter `gemini-streamlit-app-backend`.\n\n - **Backend type** : Click **Serverless network endpoint group**.\n\n - **Backends** : On the **New Backend** card, perform the following steps:\n\n 1. Click the **Serverless network endpoint groups** list, and then click **Create serverless network endpoint group**.\n\n 2. Enter the following details:\n\n - **Name** : Enter `streamlit-app-neg`.\n\n - **Region** : Select `us-central1`.\n\n - **Serverless network endpoint group type** : Select **Cloud Run**.\n\n - **Select service** : Select the `gemini-streamlit-cloudrun` Cloud Run service.\n\n 3. Click **Create**.\n\n 4. Click **Done**.\n\n2. Clear the **Enable Cloud CDN** checkbox.\n\n3. In the **Policy name** box, enter `default-security-policy-gemini-app-backend`.\n\n4. Click **Create** , and then click **OK**.\n\n5. Click **Routing rules** to configure the routing rules.\n\n### Routing rules\n\n1. Click **Advanced host and path rule**.\n\n2. In the **Host and path rules** section, click **(Default) Route traffic to backend \"\" for any unmatched hosts**, and then enter the following details:\n\n - **Action** : Select **Route traffic to a single backend**.\n\n - **Backend** : Select `gemini-streamlit-app-backend`.\n\n | **Note:** This rule handles the traffic for any unmatched host.\n3. Click **Done**.\n\n4. Click **Add host and path rule** to add a new rule.\n\n5. Under **New host and path rule**, enter the following details:\n\n - **Hosts**: Enter the domain name used while\n creating the Google-managed certificate.\n\n - **Path Matcher**: Copy the following URL map configuration:\n\n defaultService: projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/global/backendServices/gemini-streamlit-app-backend\n name: matcher1\n routeRules:\n - matchRules:\n - prefixMatch: /gemini-streamlit-app\n priority: \u003cvar translate=\"no\"\u003ePRIORITY\u003c/var\u003e\n routeAction:\n weightedBackendServices:\n - backendService: projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/global/backendServices/gemini-streamlit-app-backend\n weight: 100\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: Your Google Cloud project ID.\n\n - \u003cvar translate=\"no\"\u003ePRIORITY\u003c/var\u003e: Specify the priority of the backend service by\n which the route rules are evaluated. In this scenario, set this to any\n value because you created only one backend service.\n\n6. Click **Done**.\n\n7. Click **Review and finalize** to review the configuration and create the load balancer.\n\n### Review and finalize\n\n1. Review the load balancer configuration.\n\n2. To create the load balancer, click **Create**.\n\nAdd the IP address to the domain DNS records\n--------------------------------------------\n\nUpdate the DNS records of your domain to point to the reserved IP address that was\ncreated for your load balancer. You might have to contact the administrator\nof your domain to complete this step."]]