Updated on 2023-05-17 GMT+08:00

Configuring API Cascading

Overview

API cascading allows you to cascade two ROMA Connect instances in the same region or different regions so that one instance can use an API of the other instance as its backend service, thereby implementing 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 TCP protocol must be used on the air wall for secure access. A dedicated VPN or tunnel can also be used to implement cross-network interworking.

Procedure

  1. Enable cascading for the cascaded instance.
    1. Log in to the ROMA Connect console on which the cascaded instance is located. On the Instances page, click View Console.
    2. On the Instance Information page, click the Configuration Parameters tab 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. The cascade_auth_key value of the cascaded instance must be the same as that of the cascading instance.

      cascade_instance_ids

      IDs of the instances that are allowed to cascade the current instance. Use commas (,) to separate multiple instance IDs. A maximum of five instance IDs can be configured.

  2. Enable cascading for the cascading instance.
    1. Log in to the ROMA Connect console on which the cascading instance is located. On the Instances page, click View Console.
    2. On the Instance Information page, click the Configuration Parameters tab 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 2 Parameters related to the cascading function

      Parameter

      Description

      cascade_auth_key

      Encryption key used for authentication between two APIs. The cascade_auth_key value of the cascaded instance must be the same as that of the cascading instance.

      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 Management. On the Load Balance Channels tab page, click Create.
    2. On the Create Load Balance Channel page, configure load balance channel information.
      • Configure basic information about the load balance channel.
        Table 3 Parameters for configuring the load balance channel

        Parameter

        Description

        Name

        Enter a load balance channel name. It is recommended that you enter a name based on naming rules to facilitate search.

        Port

        Enter the access port number of the ECS in the load balance channel. You can determine the port number based on the protocol used by the API in the cascaded instance. For HTTP, set this parameter to 80. For HTTPS, set this parameter to 443.

        Routing Algorithm

        Select an algorithm for routing backend service requests. The load balance channel determines the server to which the requests are to be sent by the algorithm.

        Backend Server Type

        Select the type of servers for the load balance channel. To access the API of the cascaded instance, select Cloud server.

      • Configure the backend server type.
        1. Click Create Server Group.
        2. 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. It is recommended that you enter a name based on naming rules to facilitate search.

          Weight

          Enter the weight of the server group. A larger weight indicates that more requests can be forwarded to the servers in the group.

          Description

          Enter a brief description of the server group.

        3. Click Add Backend Server Address.
        4. Configure backend server information.
          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

          After you enable this option, 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. If the port number is 0, the port of the load balance channel is used.

          Server Status

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

      • Configure the health check.

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

        Table 6 Health check configurations

        Parameter

        Description

        Protocol

        Select the protocol used for the health check. The value can be TCP, HTTP, or HTTPS.

        Two-way Authentication

        This parameter is available only if Protocol is 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. The value can be GET or HEAD.

        Health Check Port

        Enter the destination port of the health check. By default, the port number configured for the load balance channel is used.

        Healthy Threshold

        Number of consecutive successful checks required for an ECS to be considered healthy. For example, if Healthy Threshold is set to 2, ROMA Connect considers the ECS status as healthy when the check is successful for two consecutive times.

        Unhealthy Threshold

        Number of consecutive failed checks required for an ECS to be considered unhealthy. For example, if Unhealthy Threshold is set to 5, ROMA Connect considers the ECS status as abnormal when the check fails for five consecutive times.

        Timeout (s)

        Response timeout of a health check, in seconds. If no response is received within the specified duration, 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 considers the response as successful. Multiple response codes can be specified at the same time.

    3. 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.

    Protocol

    Set this parameter based on the request protocol of the API in the cascaded instance.

    Request Mode

    Set this parameter based on the API request method used in the cascaded instance.

    Load Balancing

    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 now.

    Load Balance Channel

    Select the load balance channel created in 3.

    Cascading Flag

    This parameter is available only when cascade in the instance configuration parameters is set to on.

    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.

    Path

    Enter the request path of the backend service in the /getUserInfo/{userId} format. 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 (#), for example, /#path#. Multiple environment variables can be added, for example, /#path##request#.

    Timeout (ms)

    Enter the timeout interval of a backend service request. The default value is 5000.

    Retry No.

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

    • If the value is -1, the retry function is disabled. However, requests will be retried once by default except for those using POST and PATCH.
    • If the value ranges from 0 to 10, the retry function is enabled, and retries are performed based on the configured value. The number of retries must be less than the number of backend servers enabled in the load balance channel.

    Two-way Authentication

    This parameter is available only if Protocol is 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.