All Products
Search
Document Center

Mobile Platform as a Service:API traffic limit

Last Updated:May 08, 2023

API traffic limit allows you to configure traffic limit for a single API. You can also set the default traffic limit value for an API and set the total traffic limit value for an application to prevent the backend server from being overwhelmed during peak hours. If you specify both the default value of API traffic limit and the total value of app traffic limit, API traffic limit takes effect based on the traffic limit values.

This topic describes how to configure the default value of API traffic limit and the total value of application traffic limit. To configure traffic limit for a single API, you can configure traffic limit in the traffic limit configuration section on the API details page. For more information, see Configure an API.

Prerequisites

To use the traffic limit configuration, ensure that the traffic limit feature is enabled. Log on to the mPaaS console. In the left-side navigation pane, choose Mobile Gateway Service > Manage gateway. Turn on Limit API traffic.

Default value of API traffic limit

Set the default traffic limit value for an API to apply to all APIs in the current application. The default traffic limit configuration takes effect based on the following rules:

  • If a traffic limit value has been configured for a single API, the traffic limit value of the API is subject to the previously configured traffic limit value.

  • The traffic limit configuration of a single API overwrites the default traffic limit configuration of the API.

  • The modified default traffic limit configuration takes effect for APIs that have previously used the default traffic limit configuration.

To configure a universal filter, perform the following steps:

  1. Turn on API default traffic limit switch.

  2. In the Default traffic limit dialog box, click Edit to configure the traffic limit settings.

    • Default traffic limit: Set a proper traffic limit threshold based on your business requirements. If this value is exceeded, the request is throttled.

      Note

      The traffic limit threshold refers to the maximum number of requests within one second.

    • Traffic limit response: The default response to traffic limit is {"resultStatus":1002,"tips":"Too many customers, please wait"}. To customize a response to traffic limit, use the following format:

        {
            "result": "==This is the custom response content. Enter==",
            "tips": "ok",
            "resultStatus": 1000,
        }

      In the preceding code:

      • result for customized response data, JSON format. The client uses this field for processing only when the resultStatus is 1000.

      • tips is a custom traffic limit prompt. If the resultStatus is 1002, this field will be used to prompt the user.

      • resultStatus the result code returned for traffic limit. For more information, see Gateway result codes.

Total traffic limit of the App

Sets the sum value of traffic limit for all APIs under the current application. If the total traffic limit value of the application is exceeded, all API requests under the current application will be limited.

To configure a universal filter, perform the following steps:

  1. Turn on Total traffic limit of the App switch.

  2. In the Total App Threshold configuration box, click Edit to configure the traffic limit information.

    • Total traffic limit: Set a proper threshold based on your business requirements. Unit: seconds. If this value is exceeded, the request is throttled.

    • Traffic limit response: The default response to traffic limit is {"resultStatus":1002,"tips":"Too many customers, please wait"}. To customize a response to traffic limit, use the following format:

        {
            "result": "==This is the custom response content. Enter==",
            "tips": "ok",
            "resultStatus": 1000,
        }

      In the preceding code:

      • result for customized response data, JSON format. The client uses this field for processing only when the resultStatus is 1000.

      • resultStatus the result code returned for traffic limit. For more information, see Gateway result codes.

      • tips is a custom traffic limit prompt. If the resultStatus is 1002, this field will be used to prompt the user.