All Products
Search
Document Center

Limit API traffic

Last Updated: Mar 10, 2021

API traffic limiting refers to limiting the access to a specific API to prevent the backend server from being overwhelmed at request peak.

Prerequisites

To use the traffic limit configuration, you must enable the API traffic limiting function on the Manage gateway Service page:

  1. Log in to the mPaaS console, and from the navigation bar on the left, click Mobile Gateway Service.
  2. Click the Manage gateway tab, and switch Limit API traffic on.

About this task

Traffic limit configuration includes traffic limit mode, traffic limit value, and traffic limit response:

  • Traffic limit mode
    • Off: API calls are not restricted.
    • Intercept: When the calls frequency exceeds the traffic limit value, the request is intercepted.
  • Traffic limit value
    Set a reasonable traffic limit threshold (in seconds) according to business requirements. When the traffic limit mode is Intercept and exceeds this value, the request will be restricted.-Traffic limit response
    The default response for traffic limiting is: {"resultStatus":1002,"tips":"Too many customers, please wait for a moment"}
    To customize the traffic limit response, use the following format:
    1. {
    2. "result": "==This is the customized response content, please fill in==",
    3. "tips": "ok",
    4. "resultStatus": 1000
    5. }
    Among them,
    • result is customized response data, in JSON format. The client only take this field for processing when resultStatus is 1000.
    • tips is customized traffic limit tips. If resultStatus is 1002, this field will be used to prompt the user.
    • resultStatus is the result code returned by the traffic limit. For the specific meaning, please refer to Gateway result codes.