All Products
Search
Document Center

Serverless App Engine:Configure gateway routing for an application by using an ALB instance

Last Updated:Nov 16, 2024

After you host an application to Serverless App Engine (SAE), you can configure gateway routing for the application to distribute your requests to other services or applications. This topic describes how to configure gateway routing for an application by using an Application Load Balancer (ALB) instance.

Prerequisites

  • An application is hosted to SAE. For more information, see Deploy a Java application to SAE 1.0.

  • An ALB instance is created. For more information, see Create an ALB instance.

  • You are familiar with the related limits. For more information, see Limits of ALB.

  • The application for which you want to configure gateway routing and the backend application that receives requests reside in the same namespace.

Background information

Server Load Balancer (SLB) is a service that distributes network traffic across groups of backend servers to increase the throughput of your applications. You can use SLB to prevent service disruptions that are caused by single points of failure (SPOFs) and improve the availability of applications. For more information, see Overview.

For information about how to configure gateway routing for your application by using a Classic Load Balancer (CLB) instance, see Configure gateway routing for an application by using a CLB instance.

Scenarios

The gateway routing feature is suitable for the following scenarios:

  • A single application or multiple applications need to forward traffic from the same domain name but with different paths.

  • A single application or multiple applications need to forward traffic from different domain names that are resolved to the same IP address.

After you configure gateway routing, you can use a URL in the Domain name:Port number/Path format to access the related backend services or applications.

Create a gateway route

  1. Log on to the SAE console.

  2. In the left-side navigation pane, click Namespace.

  3. On the Namespaces page, find the namespace in which you want to create the gateway route and click its name.

  4. On the details page of the namespace, click Gateway Routing in the left-side pane.

  5. On the page that appears, click Create Gateway Route and configure the parameters described in the following table.

    Parameter

    Description

    Example

    Route Name

    The name of the route.

    test

    Network Type

    The network type of the gateway that you want to use to forward requests. Valid values:

    • Internet: You are charged for the actual amount of traffic that is forwarded by using Internet gateways. The charges are included into your SAE bills.

    • Private: You are not charged for the traffic that is forwarded by using private gateways. Traffic can be forwarded only in the current virtual private cloud (VPC).

    Internet

    Gateway Type

    The type of the gateway. Select ALB.

    ALB

    ALB Instance

    The ALB instance that you want to use to configure gateway routing. You can select an existing ALB instance from the drop-down list or click Create ALB Instance to the right of the drop-down list to create a new ALB instance. For more information, see Create an ALB instance.

    sae_gw_route_****(*****)

    Frontend Protocol Type

    The protocol that is used to forward requests. Valid values:

    • HTTP: HTTP is applicable to applications that must identify data from different sources, such as web applications and mobile games.

    • HTTPS: HTTPS is applicable to applications that require encrypted data transmission.

    HTTP

    Port

    The listener port that is used to receive requests and forward the requests to backend services or applications. Valid values: 1 to 65535.

    80

    Custom Forwarding Policy

    • Domain Name: required. The domain name from which you want to forward requests.

    • Port: The value of this parameter is the same as that of the Port parameter and cannot be changed.

    • Path: required. The path of requests that require forwarding.

    • Backend Application: the application that receives requests. The backend application must reside in the same namespace as the application from which requests are forwarded.

    • Container Port: the port of the container that is used to access the backend application.

    Note
    • Applicable to only microservices applications and applications in Always Allocate Fixed CPU Cores mode.

    • The ports of listeners within an SLB instance must be unique.

    • You can click + Add Rule to add a custom forwarding rule for the same domain name and configure the Port, Path, Backend Application, and Container Port parameters for the custom forwarding policy.

    • You can also click + Add Domain Name to add a custom forwarding rule for another domain name and configure the Domain Name, Access Port, Path, Backend Application, and Container Port parameters for the custom forwarding policy.

    • Domain Name: www.abc.com

    • Port: 80

    • Path: /

    • Backend Application: test-1

    • Container Port: 8080

    Default Forwarding Rule

    • ALB Instance: The value of this parameter is the same as that of the preceding ALB Instance parameter and cannot be changed.

    • Port: The value of this parameter is the same as that of the preceding Port parameter and cannot be changed.

    • Backend Application: the application that receives requests. The backend application must reside in the same namespace as the application from which requests are forwarded.

    • Container Port: the port of the container that is used to access the backend application.

    Note

    We recommend that you configure the default forwarding policy for all requests that do not match the custom forwarding policy. If you do not configure the default forwarding policy, an access error is reported.

    • ALB Instance: sae_gw_route_****(*****)

    • Port: 80

    • Backend Application: test-gw

    • Container Port: 8080

  6. Click Save.

  7. Verify the result.

    • On the Event Information page of the namespace, check whether the routing rule is configured.

    • Log on to the SLB console. Find the ALB instance that you specified in the previous step to go to the instance details page. On the Listener tab, check whether a listener is configured.

      image

    • Use a URL in the Domain name:Port number/Path format to access the related backend service or application.

Manage a gateway route

After you create a routing rule, you can view the forwarding policy, modify or delete the gateway route, and view the related events on the Gateway Routing page.