Updated on 2024-06-25 GMT+08:00

Configuring API Cascading

API cascading allows you to cascade two ROMA Connect instances in one or more regions. This lets one instance use an API of the other instance as its backend service for cross-instance API calling. A dedicated authentication channel will be used for API cascading to prevent authentication conflict.

  • Cascading instance: uses an API of the other instance as its backend service.
  • Cascaded instance: provides its API to the other instance as a backend service.

API cascading enables you to provide APIs in one instance for another instance to improve the reuse capability of API assets, without having to deploy backend services in different instances repeatedly.

Prerequisites

  • The two instances can communicate with each other.
  • If the two instances are located in different networks and communicate with each other through an air wall, their IP address and port number must be configured on the air wall. In addition, the air wall must use the TCP protocol for secure access. A dedicated VPN or tunnel can also be used for cross-network interworking.

Procedure

  1. Enable cascading for the cascaded instance.
    1. Log in to the ROMA Connect console that displays the cascaded instance. On the Instances page, click View Console.
    2. Choose Instance Information > Configuration Parameters, and locate the cascade parameter.
    3. Click Edit on the right of the parameter, set Current Value to on, and click Save.
    4. Click on the left of the parameter and configure the following parameters.
      Table 1 Parameters related to the cascading function

      Parameter

      Description

      cascade_auth_key

      Encryption key used for authentication between two APIs.

      This must be the same for the cascaded and cascading instance pair.

      cascade_instance_ids

      IDs of the instances that are allowed to cascade the current instance. Use commas (,) to separate multiple (max. 5) instance IDs.

  2. Enable cascading for the cascading instance.
    1. Log in to the ROMA Connect console that displays the cascading instance. On the Instances page, click View Console.
    2. Choose Instance Information > Configuration Parameters, and locate the cascade function.
    3. Click Edit on the right, set Current Value to on, and click Save.
    4. Click on the left and configure the following parameters.
      Table 2 Parameters related to the cascading function

      Parameter

      Description

      cascade_auth_key

      Encryption key used for authentication between two APIs.

      This must be the same for the cascaded and cascading instance pair.

      cascade_instance_ids

      This parameter is not required for cascading instances.

  3. Create a load balance channel from the cascading instance to the cascaded instance.
    1. In the navigation pane of the cascading instance console, choose API Connect > API Policies. On the Load Balance Channels tab, click Create Load Balance Channel.
    2. On the page displayed, configure load balance channel information.
      Table 3 Basic information

      Parameter

      Description

      Name

      Enter a load balance channel name.

      Using naming rules facilitates future search.

      Port

      Enter the access port number of the ECS in the load balance channel.

      The port number is the protocol used by the API in the cascaded instance.

      80: HTTP

      443: HTTPS

      Routing Algorithm

      Select an algorithm for routing backend service requests. The load balance channel determines which server the algorithm will send the requests to.

      • WRR: Requests are forwarded to each cloud server in order of server weight.
      • WLC: Requests are forwarded to the cloud server with the fewest live connections in order of server weight.
      • SH: Requests are forwarded to the cloud server by source IP address. Requests with the same source IP address are forwarded to the same server unless the server is unavailable.
      • URI hashing: Requests are forwarded to the cloud server by request path. Requests from the same path are forwarded to the same server unless the server is unavailable.
    3. Configure servers. To access APIs of the cascaded instance, select Specify IP addresses.
    4. Click Create Server Group. In the dialog box displayed, configure group information and click OK.

      Servers can be added to different groups.

      Table 4 Server group configuration

      Parameter

      Description

      Group Name

      Enter a server group name. Using naming rules facilitates future search.

      Weight

      Enter the weight of the server group. The larger the weight, the more requests can be forwarded to the servers in the group.

      Description

      Enter a brief description of the server group.

    5. Click Add Backend Server Addresses and configure backend servers.
      Table 5 Backend server information

      Parameter

      Description

      Backend Server Address

      Enter the API access address of the cascaded instance.

      • IP address format:
        • Set this parameter to the EIP of the cascaded instance if the two instances communicate with each other over a public network.
        • Set this parameter to the APIC connection address of the cascaded instance if the two instances communicate with each other over a VPC intranet.
      • Domain name format: Enter the access domain name of the API.

      Standby Node

      Enabled: The backend server serves as a standby node. It works only when all non-standby nodes are faulty.

      Port

      Enter the access port number of the backend server.

      0: uses the load balance channel port.

      Server Status

      Specify whether to enable the server. Requests are distributed to the server only after it is enabled.

    6. Configure the health check.

      The health check function is enabled by default. If you do not need the health check, disable this function.

      Table 6 Health check parameters

      Parameter

      Description

      Protocol

      Select the protocol used for the health check.

      Options: TCP, HTTP, HTTPS

      Two-way Authentication

      Available for Protocol set to HTTPS.

      Specify whether to enable two-way authentication between ROMA Connect and backend servers.

      Path

      Mandatory for Protocol set to HTTP or HTTPS.

      Enter the health check URL.

      Method

      Mandatory for Protocol set to HTTP or HTTPS.

      Select the HTTP request method used for the health check.

      Options: GET or HEAD

      Health Check Port

      Enter the destination port of the health check.

      Default: port number configured for the load balance channel

      Healthy Threshold

      Number of consecutive successful checks required for an ECS to be considered healthy.

      Example: If set to 2, ROMA Connect declares the ECS status to be healthy when the check is successful twice in a row.

      Unhealthy Threshold

      Number of consecutive failed checks required for an ECS to be considered unhealthy.

      Example: If set to 5, ROMA Connect declares the ECS status to be abnormal when the check fails five times in a row.

      Timeout (s)

      Response timeout of a health check, in seconds. If no response is received within this time, the health check fails.

      Interval (s)

      Interval between consecutive checks.

      Response Codes

      Mandatory for Protocol set to HTTP or HTTPS.

      When the server returns a specified HTTP response code, the server declares the response to be successful.

      Supports multiple response codes.

    7. Click Finish.
  4. On the cascading instance, create an API and set the backend address to the API in the cascaded instance.

    For details about how to create an API, see Creating an API. Only the configuration of defining the backend service is different between the cascading and the cascaded instances, as shown as follows.

    Table 7 Backend service access parameters

    Parameter

    Description

    Backend Type

    Select a backend service type. When the API of the cascaded instance is used as the backend service, select HTTP/HTTPS.

    Load Balance Channel

    Determine whether to use a load balance channel to access backend services. When the API of the cascaded instance is used as the backend service, select Configure.

    URL

    Configure the URL of the backend service.

    • Method: Select the request method of the backend service based on the API request method of the cascaded instance.
    • Protocol: Select the request protocol used by the backend service based on the API request protocol of the cascaded instance.
    • Load Balance Channel: Select the load balance channel created in 3.
    • Path: Enter the request path of the backend service, for example, /getUserInfo/{userId}. A URL can have multiple path parameters, each enclosed by braces.

      If the path needs to contain an environment variable, enclose the environment variable in number signs (#)

      Example: /#path#

      Environment variable names are case sensitive.

      Multiple environment variables can be added.

      Example: /#path##request#

    Cascading Flag

    Determine whether to use the cascading mode to access backend services. Enable this option.

    Host Header

    Define the Host header field carried in the backend service request. If you have specified Backend Server Address with an IP address when creating a load balance channel in 3, set Host Header to the domain name of the API of the cascaded instance.

    Timeout (ms)

    Enter the timeout interval of a backend service request.

    Default: 5000

    Retries

    Number of retries after ROMA Connect fails to call the backend service.

    • -1: The retry function is disabled. However, requests will be retried once by default except for those using POST and PATCH.
    • 0 to 10: This parameter is enabled and will make the configured number of retries. The number must be less than that of backend servers enabled in the load balance channel.

    Two-Way Authentication

    Available for Protocol set to HTTPS.

    Determine whether to enable two-way authentication between ROMA Connect and backend services. When the API of the cascaded instance is used as the backend service, do not enable two-way authentication.

    Backend Authentication

    Determine whether to enable backend authentication. When the API of the cascaded instance is used as the backend service, do not enable backend authentication.