Updated on 2022-12-05 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 calling between the two instances that establish the cascading relationship. This can prevent an authentication conflict in API cascading scenarios.

  • The instance that uses an API of the other instance as its backend service can be called a cascading instance.
  • The instance that provides its API to the other instance as a backend service can be called a cascaded instance.

With the API cascading function, API providers can provide APIs in one instance to another instance to improve the reuse capability of API assets and avoid repeatedly deploying backend services in different instances.

Prerequisites

  • The cascading and cascaded instances can communicate with each other.
  • If the cascading and cascaded instances are located in different networks and they communicate with each other through an air wall, the IP address and port number of the instances must be configured on the air wall. In addition, the TCP protocol must be used on the air wall to establish network paths in ferry mode. A dedicated VPN or tunnel can also be used to implement cross-network interworking.

Procedure

  1. Enable the cascading function on 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 to expand and set the parameters related to the cascading function.
      Table 1 Parameters related to the cascading function

      Parameter

      Description

      cascade_auth_key

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

      cascade_instance_ids

      ID list of cascading instances. Only instances specified by this parameter can establish the cascading relationship with the current instance. Use commas (,) to separate multiple instance IDs. A maximum of five instance IDs can be configured.

  2. Enable the cascading function on 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 to expand and set the cascading parameters.
      Table 2 Parameters related to the cascading function

      Parameter

      Description

      cascade_auth_key

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

      cascade_instance_ids

      ID list of cascading instances. You do not need to set this parameter in the cascading instance.

  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 basic information and health check information and click Next.
      Table 3 Parameters in Basic Information and Health Check Configuration

      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.

      Member Type

      Select the member type of a server in the load balance channel. To access an API of the cascaded instance, select IP address for Member Type.

      Distribution Algorithm

      Select a distribution algorithm for backend service requests. The load balance channel determines the server to which the request is to be sent based on the distribution algorithm.

      Protocol

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

      Path

      This parameter is mandatory only if Protocol is set to HTTP or HTTPS.

      Enter the health check URL.

      Method

      This parameter is available only if Protocol is set to HTTP or HTTPS.

      Select the HTTP request method used for the health check. The value can be GET or HEAD.

      Advanced Settings

      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)

      Enter the response timeout duration of a health check, in the unit of seconds. If no response is received within the specified duration, the health check fails.

      Interval (s)

      Interval between consecutive checks.

      Response Codes

      This parameter is mandatory only if Protocol is 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 Add Backend Server Address. On the page displayed, configure the IP address of the cascaded instance.
      Table 4 Backend server information

      Parameter

      Description

      Backend Server Address

      Enter the API access address of the cascaded instance.

      • If you use the IP address format:
        • Set this parameter to the EIP of the cascaded instance if the cascading and cascaded instances communicate with each other over a public network based on the EIP.
        • Set this parameter to the APIC connection address of the cascaded instance if the cascading and cascaded instances communicate with each other over an intranet.
      • If you use the domain name format, enter the access domain name of the API.

      Weight

      This parameter is mandatory only if WRR or WLC is selected for Distribution Algorithm of the load balance channel.

      Enter the weight of the backend server. A larger weight indicates that more requests will be forwarded to the backend server.

    4. 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. The following table describes the different configuration.

    Table 5 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

    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, 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. The request path can contain the path parameter in the format of {Parameter name}.

    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.

    Two-way Authentication

    This parameter is mandatory 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.