All Products
Search
Document Center

Microservices Engine:Create a throttling rule

Last Updated:Nov 07, 2024

A throttling rule is used to immediately block traffic if the system detects that the queries per second (QPS) of a monitored application or service reaches a threshold that you specify. This prevents breakdown of the application due to traffic surges and ensures high availability of the application. This topic describes how to create a throttling rule and provides a sample throttling rule for a common scenario.

Prerequisites

Background information

Throttling is a common concept in network transmission and is used to adjust the sending of network packets. The requests that the system needs to process are random and uncontrollable. However, the request processing capability of the system is limited. Therefore, throttling must be implemented based on the request processing capability of the system.

Procedure

  1. Log on to the MSE console, and select a region in the top navigation bar.

  2. In the left-side navigation pane, choose Microservices Governance > Application Governance.

  3. On the Application list page, click the resource card of the destination application.

  4. On the details page of the application, create a throttling rule by using one of the following methods:

    • In the left-side navigation pane, click Application overview. On the page that appears, click the Through QPS TOP tab. On the Through QPS TOP tab, find the interface to which you want to apply the throttling rule and click Flow Control in the Actions column.

    • In the left-side navigation pane, click API Details. On the WEB service tab of the page that appears, click the Interface Flow Control tab. On the Interface Flow Control tab, click Add Throttling Rule.

    • In the left-side navigation pane, click Traffic management. On the page that appears, click the Flow protection tab. On the Flow protection tab, click the Interface Flow Control tab. On the Interface Flow Control tab, click Add Throttling Rule.

  5. In the Add Throttling Protection Rule or Add Rule dialog box, configure the rule parameters. For more information about the rule parameters, see the Parameters section of this topic.

  6. Click New.

Common scenario: Implement peak-load shifting to process requests at a constant speed

Request traffic fluctuates during peak and off-peak hours. You can implement throttling to delay peak traffic for a specific period of time, namely, the queuing time, for processing. This ensures that all the requests can be processed without affecting user experience.

In the Add Throttling Protection Rule or Add Rule dialog box, create a throttling rule by using the following parameter settings:

  • Set the Stand-alone QPS threshold parameter to 5.

  • Set the Flow control effect parameter to Waiting in line.

  • Set the Timeout parameter to 5000. Unit: milliseconds.

The system processes a request every 200 milliseconds and the accumulated requests are queued up. The queueing timeout period is set to 5000 milliseconds. If a request is queued for longer than 5,000 milliseconds, the request fails, and the default information such as texts and static pages to be displayed due to throttling is directly returned.

Parameters

The following table describes the parameters that you must configure in the Add Throttling Protection Rule or Add Rule dialog box.

Parameter

Description

Interface name

The name of the interface to which you want to apply the throttling rule.

Whether to open

Specifies whether to enable the throttling rule. The throttling rule is immediately enabled or disabled after you turn on or off the switch.

Stand-alone QPS threshold

The QPS threshold that triggers the throttling rule.

Flow control effect

The method that is used to process the blocked requests. Valid values:

  • Fast failure: Requests are immediately blocked if the QPS threshold is reached. The content returned varies based on the configurations of the adaptation module in the system settings of the application.

  • Waiting in line: Requests are processed at a constant speed and the accumulated requests are queued up. In most cases, this value is specified for scenarios such as peak-load shifting. You must specify a queueing timeout period for requests. If the queueing time of a request exceeds the queueing timeout period, the request fails.