Help Center/ ModelArts/ Best Practices/ Inference Deployment (New Version)/ Accessing a Real-Time Service Through a Dedicated API Gateway, WAF, VPC, and ELB
Updated on 2026-11-17 GMT+08:00

Accessing a Real-Time Service Through a Dedicated API Gateway, WAF, VPC, and ELB

Overview

This function is designed to ensure that public network users can securely and efficiently access ModelArts real-time services and flexibly integrate ModelArts prediction services.

This section describes how to use Dedicated API Gateway (APIG), Web Application Firewall (WAF), Virtual Private Cloud (VPC), and Elastic Load Balance (ELB) to access ModelArts real-time services over the intranet.

Figure 1 Real-time service access

The details are as follows:

  1. After a visitor enters a domain name in the browser, the client sends a request to the DNS service to query the domain name resolution address.
  2. DNS returns the domain name resolution address to the client.
  3. The domain name resolution address returned by the DNS service is the EIP of the load balancer, and the client accesses the load balancer through the EIP.
  4. The ELB load balancer forwards the traffic to WAF.
  5. WAF checks the traffic, blocks abnormal traffic, and forwards normal traffic to the real-time service over the back-to-source IP address of the dedicated WAF engine.
Figure 2 Network architecture

Constraints

Constraints

Remarks

Workaround

Domain name

Prepare a public domain name for ICP filing in advance; the application and registration typically take three to five days.

Use the ELB IP address for access.

Response timeout

APIG limits the maximum response timeout of the backend service to 5 minutes.

If a longer timeout interval is required, you can remove APIG.

Resource and Cost Planning

This example uses these specifications only to set up access links. The QPS remains low. Final inference performance depends on each component's capabilities. Choose components that meet your service needs.

Resource

Specifications (for Reference)

Quantity

API Gateway (APIG)

  • Billing mode: Pay-per-use
  • Basic edition
  • Single AZ: 50 Mbit/s
  • Dual-AZ or more: 100 Mbit/s
  • Private network connections per second: 1,000

For details about how to purchase specifications, see:

Specifications_Service Overview_API Gateway_Huawei Cloud

1

Elastic IP (EIP)

  • Billed by bandwidth
  • Bandwidth: 5 Mbit/s

For details about how to purchase specifications, see:

Billing_Service Overview_Elastic IP_Huawei Cloud

Lower Public Network Costs_Best Practices_Elastic IP_Huawei Cloud

1

Elastic Load Balance (ELB)

  • Network type: public network
  • Bandwidth: 5 Mbit/s

For details about how to purchase specifications, see:

Load Balancer Selection and Service Planning_Best Practices_Elastic Load Balance_Huawei Cloud

1

Web Application Firewall (WAF)

  • WI-100
  • Estimated single instance performance
  • Throughput
  • 100Mbps
  • HTTP/HTTPS service
  • Recommended QPS: 1,000; maximum QPS: 2,000; WAF-to-Server persistent connections: 60,000
  • Websocket
  • Concurrent connections: 1,000

For details about how to purchase specifications, see:

About Purchase and Specifications Change_Huawei Cloud

How Do I Select Service QPS When Purchasing WAF?_Huawei Cloud

1

VPC Endpoint

  • Basic edition

For details about how to purchase specifications, see:

Lower Network Costs_Best Practices_Virtual Private Cloud_Huawei Cloud

Bandwidth_FAQs_Virtual Private Cloud_Huawei Cloud

1

Permissions

Table 1 Permissions required for creating components

Component

Component Creation Permission

Official Website

VPC

VPC FullAccess or VPC Administrator

Permissions_Service Overview_Virtual Private Cloud_Huawei Cloud

EIP

VPC FullAccess or VPC Administrator

EIP Permissions_Service Overview_Elastic IP_Huawei Cloud

APIG

  • System role permissions: You can create an instance only if you have both the APIG Administrator and VPC Administrator permissions.
  • System policy: You only need to have the APIG FullAccess permission.

Quickly Opening and Calling APIs_Getting Started_API Gateway_Huawei Cloud

ELB

ELBFullAccess or ELB Administrator

Permissions_Service Overview_Elastic Load Balance_Huawei Cloud

WAF

WAF Administrator or WAF FullAccess

Permission Dependency of the WAF Console_Permissions Management_User Guide_Web Application Firewall_Huawei Cloud

When using the private network connection function, you must have the following permissions:

Table 2 Permissions required for private network connection

Permission

action

Scenario

Obtaining details about a workspace

modelarts:workspace:get

Accessing workspaces

Obtaining model services

modelarts:service:list

Obtaining services

Obtaining dedicated resource pools

modelarts:pool:list

Obtaining resource pools

Obtaining VPCs

vpc:vpcs:list

Private network connection page and private network connection request creation

Obtaining subnets or subnet details

vpc:subnets:get

Private network connection page and private network connection request creation

Updating a service

modelarts:service:update

Creating, managing, and deleting private network connections at the service level

Obtaining private network connections

iam: modelarts:intranetConnection:list

Querying the private network connection list

Modifying private network connections

iam: modelarts:intranetConnection:update

Modifying private network connections

Creating private network connections

iam: modelarts:intranetConnection:create

Creating private network connections

Deleting private network connections

modelarts:intranetConnection:delete

Deleting private network connections

You also need to grant the agency permissions below to ModelArts. For details about how to add ModelArts authorization, see Configuring Agency Authorization for ModelArts with One Click.

Table 3 Permissions granted to ModelArts for private network connection

Permission

action

Scenario

Creating endpoints

vpcep:endpoints:create

Creating and changing private network connections

Deleting endpoints

vpcep:endpoints:delete

Deleting private network connections

Querying endpoint details

vpcep:endpoints:get

Creating and changing private network connections

Querying endpoints

vpcep:endpoints:list

Creating and changing private network connections

Process

Step

Description

Step 1: Creating a VPC

Shows how to create a virtual private cloud (VPC).

Step 2: Creating a Private Network Connection

Shows how to create a private network connection for a service.

Step 3: Purchasing an API Gateway

Shows how to purchase an API gateway.

Step 4: Creating an API Through APIG

Shows how to create an API.

Step 5: Creating an Elastic Load Balancer

Shows how to create a load balancer.

Step 6: Adding a Listener

Shows how to add a listener and connect the load balancer to WAF.

Step 7: Using WAF to Protect APIG

Shows how to connect WAF to APIG.

Step 8: Accessing a Real-Time Service from a Public Network

Shows how to access real-time inference services from the public network.

Step 1: Creating a VPC

  1. On the Create VPC page, set the VPC and subnet parameters as prompted. For more information, see Creating a VPC with a Subnet.
  2. Click Create Now.

Step 2: Creating a Private Network Connection

  1. Log in to the ModelArts console. In the navigation pane, choose Model Inference > Real-Time Inference.
  2. Click Private Network Connections.
  3. In the My Requests tab, click Create.
  4. Set parameters and click OK.

    Check the request status in the My Requests tab. If the request status is Connection succeeded, the request is approved.

  5. Obtain Access Address from My Requests.
    Table 4 Parameters for private network connection request

    Parameter

    Description

    Recommended Value

    Service ID

    ID of the inference service that needs to be accessed through the private network.

    You have obtained the real-time service ID on the service details page by clicking the service name in the inference service list.

    Network Type

    Type of the network for which the private network is enabled.

    • User network: Connect the private network between your VPC and inference service.
    • Resource pool network: Connect the private network between your resource pool and inference service.

    User network.

    VPC

    When you select User network, choose a VPC for private network connection.

    Select the VPC created in Step 1: Creating a VPC.

    Subnet

    When you select User network, choose a subnet for private network connection.

    Select the subnet created in Step 1: Creating a VPC.

    Resource Pool

    When you select Resource pool network, choose a resource pool for private network connection.

    N/A.

    Custom Access Address

    Allow users to access a real-time service through a load balancer using a public domain name.

    Domain name provided by the user.

Step 3: Purchasing an API Gateway

To manage real-time services, you need to purchase a dedicated gateway instance, create an API, and bind a domain name to the API.

  1. On the Buy Gateway page, configure the instance information. For more parameter descriptions, see Creating a Gateway.

    Purchase different instances based on service requirements. The final price is subject to the price displayed on the page.

    In this example, the basic edition is used as an example. You can ignore the public network inbound and outbound ports. Select the VPC and subnet created in Step 1: Creating a VPC, and open ports 80 and 443 in the inbound direction of the security group. For more parameter descriptions, see Creating a Gateway.

  2. Click Next.
  3. Confirm the gateway configurations, read and confirm your acceptance of the service agreement, and click Pay Now. The gateway is created with the status displayed on the screen.

Step 4: Creating an API Through APIG

  1. Obtain the private network connection address.
    1. Log in to the ModelArts console. In the navigation pane, choose Model Inference > Real-Time Inference.
    2. Click Private Network Connections.
    3. Click My Requests, find the private network connection created in Step 2: Creating a Private Network Connection, and copy the value in the Access Address column. Use https://1xx.xxx.xxx.xxx/v2/infer/xxx-xxxx-xxxxxxx as an example to create an API.

      Note: The access address is only available when the status is Connection succeeded.

  2. Create a load balance channel for the API.
    1. Log in to the APIG console, select the APIG instance created in Step 3: Purchasing an API Gateway from the drop-down list in the upper left corner, and choose API Management > API Policies in the navigation pane on the left.
    2. Click Load Balance Channels.
    3. Click Create Load Balance Channel and configure basic information. Table 5 describes some parameters.
      For details about more parameters, see (Optional) Creating a Load Balance Channel.
      Table 5 Parameters for creating a load balance channel

      Parameter

      Description

      Recommended Value

      Name

      Select a billing mode based on your service requirements.

      VPC_xxxx

      Port

      Set this parameter based on the private network connection address.

      HTTP: 80

      HTTPS: 443

      443

      Routing Algorithm

      The algorithm to be used to forward requests to cloud servers you select.

      The following routing algorithms are available:

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

      Weighted round robin

      Type

      • Server: API requests will be distributed to ECSs or specified server IP addresses in the channel.
      • Microservice: API requests will be distributed to microservice IP addresses in the channel.
      • Reference: you can reference other existing load balance channels.

      Server

      Mode

      Configure servers if Type is set to Server.

      Specify IP addresses

    4. After entering the basic information, click Create Server Group. In the displayed dialog box, enter the server group information and click OK. For details about more parameters, see (Optional) Creating a Load Balance Channel.
      Table 6 Parameters for creating a server group

      Parameter

      Description

      Value

      Group Name

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

      It can contain 3 to 64 characters, starting with a letter. Only letters, digits, underscores (_), hyphens (-), and periods (.) are allowed.

      service-group-1

      Weight

      Enter the weight of the server group. The larger the weight, the more requests can be forwarded to the servers in the group. The default value is 1. The value ranges from 0 to 100.

      1

      Description

      Enter a brief description of the server group. Enter 1 to 255 characters.

      -

    5. Click Add Backend Server Address and enter a backend server address based on the following table.

      Parameter

      Description

      Value

      Backend Server Address

      IP address of the private network connection address, for example, https://192.xxx.xxx.122.

      /v2/infer/xxx-xxxx-xxxxxxx: Enter 192.xxx.xxx.122.

      192.xxx.xxx.122

      Port

      Enter the following information based on the request protocol of the private network connection address:

      HTTP: 80

      HTTPS: 443

      443

    6. Click Finish.
  3. Create an API.
    1. Log in to the APIG console, select the APIG instance created in Step 3: Purchasing an API Gateway from the drop-down list in the upper left corner, and choose API Management > APIs in the navigation pane on the left.
    2. In the upper right corner of the page, click Create API. Configure the parameters based on the following table. Table 7 describes some parameters. For details about more parameters, see Creating a REST API.
      Table 7 API parameters

      Parameter

      Description

      Value

      API Name

      Enter 3 to 255 characters, starting with a letter or digit. Use only letters, digits, and these special characters: -_./:()

      API_xxxx

      Group

      Select or create an API group.

      DEFAULT

      URL

      Example: https://192.xxx.xxx.122

      /v2/infer/xxx-xxxx-xxxxxxx provides the POST /v1/sse interface.

      Request method: Select the method that matches the API.

      Request protocol: Select the protocol that matches the API.

      Path: The request path can include parameters enclosed with braces ({}) (example: /a/{b}). For prefix match, add a plus sign (+) to the end of a parameter (example: /a/{b+}).

      POST

      HTTPS

      /v2/infer/xxxxx/v1/sse

      Gateway Response

      default

      default

      Type

      Public APIs can be published in the RELEASE environment and sold.

      Private APIs cannot be published for sale.

      Public

      Authentication Mode

      App authentication: Use AppKey & AppSecret authentication.

      IAM authentication: Only authorized users can access the API.

      Custom authentication: Custom authentication is used to control API access.

      No authentication: All users can access the API. This option is not recommended.

      Note: If the request includes valid authentication details, choose None to skip repeated verification by API Gateway, boosting API performance.

      None

    3. Click Next. The backend configuration page is displayed.

      Table 8 describes some parameters. For details about more parameters, see Creating a REST API.

      Table 8 Backend configuration parameters

      Parameter

      Description

      Value

      Backend Type

      Select the backend service type.

      HTTP&HTTPS

      Load Balancing

      Select Single server group.

      DEFAULT

      URL

      Example link https://192.xxx.xxx.122/v2/infer/xxx-xxxx-xxxxxxx provides the POST /v1/sse API.

      Request method: Select the method that matches the API.

      Request protocol: Select the protocol that matches the API.

      Load balance channel: Select the channel created earlier.

      Path: The request path can include parameters enclosed with braces ({}) (example: /a/{b}). For prefix match, add a plus sign (+) to the end of a parameter (example: /a/{b+}).

      POST

      HTTPS

      VPC_xxxx

      /v2/infer/xxxxxx/v1/sse

      Timeout (ms)

      API Gateway limits the maximum response time to 5 minutes. If a longer response time is required, the request cannot be sent to API Gateway. Unit: millisecond.

      5000

    4. Click Finish. Wait until the API debugging page is displayed.
  4. On the API debugging page, click Debug in the upper right corner and use the default domain name provided by API Gateway. If the API responds with 200, the API is configured successfully.
    Figure 3 API debugging

  5. After the API is debugged, click Publish Latest Version in the upper right corner. In the displayed dialog box, select an environment and click OK.

    In this case, select RELEASE.

  6. Bind a domain name. In the navigation pane on the left, choose API Management > API Groups, and click the name of the API group to which the API belongs. The details page is displayed.

    Click Bind Independent Domain Name, enter the prepared independent domain name, and click OK.

Step 5: Creating an Elastic Load Balancer

  1. Log in to the Elastic Load Balance console and click Buy Elastic Load Balancer.
  2. On the Buy Elastic Load Balancer page, set the parameters as prompted. For details about the parameters to be configured, see Table 9. Configure other parameters as required. For details about other parameters, see Creating a Dedicated Load Balancer.
    Table 9 ELB parameters

    Parameter

    Value

    Network Type

    Private IPv4 network.

    VPC

    Select the VPC created in Step 1: Creating a VPC.

    Frontend Subnet

    Select the subnet created in Step 1: Creating a VPC.

    IPv4 Address

    Automatically-assigned IP address.

    Backend Subnet

    Subnet of the load balancer.

    IP as a Backend

    Enabled.

Step 6: Adding a Listener

  1. On the load balancer details page, click the Listeners tab and click Add Listener.
  2. On the Add Listener page, set the parameters according to Table 10. You can configure other parameters as required. For details about more parameters, see Adding an HTTPS Listener.
    Table 10 Parameters for adding a listener

    Parameter

    Value

    Frontend Protocol

    Set this parameter based on the protocol of the service call API of the real-time service.

    For example, if the service call API of the real-time service is HTTP://{host}:8080, set this parameter to HTTP.

    Listening Port

    If Frontend Protocol is HTTP, set this parameter to 80.

    If Frontend Protocol is set to HTTPS, set this parameter to 443.

  3. Click Next: Configure Request Routing Policy and set the parameters. For details, see Table 11. For more information, see Creating a Backend Server Group.
    Table 11 Parameters for configuring a backend server group

    Parameter

    Description

    Value

    Backend Server Group

    Create a backend server group by referring to Creating a Backend Server Group.

    Create new

    Name

    Specifies the name of the backend server group.

    server_group-best-0829

    Backend Server Group Type

    Specifies the type of the backend server group.

    • Hybrid: You can add cloud servers and supplementary network interfaces as backend servers, and add IP addresses as backend servers when IP as a Backend is enabled.

      When you create a hybrid backend server group, you must specify a VPC and associate the backend server group with a load balancer in this VPC.

    • IP as a backend server: Only IP addresses can be added as backend servers.

      You can add IP addresses as backend servers only when IP as a Backend is enabled.

    Hybrid

    Backend Protocol

    Determined by the private network connection in Step 2: Creating a Private Network Connection.

    For example, if the private network connection is https://1xx.xxx.xx.xxx:443/v2/infer/xxxx, select HTTPS.

    HTTPS

  4. Click Next: Add Backend Server in the lower right corner. In this case, you do not need to perform any operation on this page.
  5. Click Next: Confirm, confirm the settings, and click Submit.

    After the listener is created, the listener list page is displayed.

Step 7: Using WAF to Protect APIG

  1. Log in to the WAF console. In the upper right corner of the page, click Buy WAF.
  2. On the Buy Web Application Firewall page, select Dedicated Mode for WAF Mode.
  3. Set other parameters as required.

    In this example, the VPC, subnet, and security group must be those created in Step 1: Creating a VPC. For more parameter description, see Buying Dedicated Mode WAF.

  4. Confirm the parameters and click Buy Now.
  5. On the Confirm Configuration page, confirm the order details, check the boxes before "I have read and agree to the WAF Disclaimer." and "I agree to assign permissions of the following roles to WAF", and click Pay.
  6. After the purchase is successful, click Back to Dedicated Engine List to return to the homepage.
  7. Add to ELB.
    1. On the WAF console, choose Instance Management > Dedicated Engine in the navigation pane on the left. In the dedicated engine list, locate the newly created WAF instance and choose More > Add to ELB in the Operation column.
    2. On the page that appears, select the ELB created in Step 5: Creating an Elastic Load Balancer, the listener created in Step 6: Adding a Listener, and the backend server group. Click Next.
    3. On the Set Ports and Weights page, enter the service port number based on the protocol. For HTTP requests, enter 80. For HTTPS requests, enter 443. Then, click OK.
    4. Return to the ELB page in Step 5: Creating an Elastic Load Balancer, find the corresponding load balancer, and click the listener to go to the basic information page.
    5. In the backend server group area on the basic information page, click the backend server group name.
    6. On the page that appears, click the Backend Servers tab, expand the cloud server drop-down list, and check whether the private IP address is the IP address of the WAF instance.
  8. In the navigation pane on the left of the WAF console, choose Website Settings.
  9. In the upper left corner of the website list, click Add Website, select Dedicated Mode, and click Configure Now.
  10. In the Add Website dialog box, set the parameters described in Table 12, and set other parameters as required. For more information about the parameters, see Add a Website to WAF.
    Table 12 Adding a website

    Parameter

    Description

    Value

    Protected Object

    The domain name of the website you want to protect. It can be a single domain name or a wildcard domain name.

    Enter the prepared domain name.

    www.xxxx.com

    Server Configuration

    Enter the port number and protocol based on the private network connection address.

    HTTP: 80.

    HTTPS: 443.

    VPC: Select the VPC created in Step 1: Creating a VPC.

    Private IP address: APIG IP address. Go to the APIG page and click the created APIG. On the details page, find the VPC access address.

    HTTPS

    HTTPS

    vpc-xxxx

    443

    192.xxx.xxx.xxx (private APIG IP address)

    Layer-7 Proxy Used

    Layer-7 proxy: Web proxy products for layer-7 request forwarding are used, products such as anti-DDoS, CDN, and other cloud acceleration services. Note: If a layer-7 proxy is configured, WAF reads the real client IP address from the related fields in the header.

    No

  11. Click OK. The list page is displayed. Click the domain name added for Protected Object. The detailed configuration page is displayed.
  12. Check whether WAF is normal. For details, see Test Dedicated WAF Instances.

Step 8: Accessing a Real-Time Service from a Public Network

Use a browser or Postman to access the real-time service. If security authentication is configured for the API, the security authentication must be added to the request. In this example, no authentication is used.

Figure 4 Accessing a real-time service through a private network
Table 13 Access address description

Address

Description

www.address.com

Protected domain name added in Step 7: Using WAF to Protect APIG.

/v2/infer/xxx-xxxx-xxxxxxx

API created in Step 4: Creating an API Through APIG.