Import and export service throttling rules

更新时间:
复制 MD 格式

You can import and export service throttling rules to apply them to multiple applications.

Export service throttling rules

  1. Log on to the SOFAStack console.

  2. In the navigation pane on the left, choose Middleware > Microservice Platform > Microservice > Service Governance.

  3. Click Service Throttling. In the application list, find the target application and choose More > Export.

    The exported file is in JSON format and is saved to the default download folder of your browser.import

Import service throttling rules

You can import the exported rules to other applications to quickly create new service throttling rules.

  1. On the Service Throttling page, find the target application in the application list and choose More > Import.

  2. Click Browse, select the target file, and then click Open.

Service throttling rule file format

The exported service throttling rule file is in JSON format. The file content is as follows:

[
    {
        "actionConfig":{
            "actionType":"LIMIT_EXCEPTION",
            "responseContent":"ssssssssss"
        },
        "calculationConfigs":[
            {
                "calculationType":"INVOKE_BY_TIME",
                "maxAllow":1,
                "period":1000
            }
        ],
        "desc":"GuardianApp.query",
        "enable":false,
        "globalLimit":false,
        "limitStrategy":"QpsLimiter",
        "limitType":"GENERIC_LIMIT",
        "maxBurstRatio":0,
        "resourceConfigs":[
            {
                "baseName":"com.alipay.antcloud.dsrconsole.core.service.guardian.facade.GuardianAppFacade.query",
                "resourceType":"METHOD",
                "ruleIds":[

                ]
            },
            {
                "baseName":"11.22",
                "resourceType":"METHOD",
                "ruleIds":[

                ]
            }
        ],
        "resourceType":"METHOD",
        "runMode":"CONTROL",
        "trafficType":"ALL"
    }
]

The following table describes the parameters:

Parameter

Description

actionConfig

The post-processing action. It includes the following parameters:

  • actionType: The type of post-processing action.

  • responseContent: If the action type is a throttling exception, this field contains the exception message.

calculationConfigs

The throttling configuration. It includes the following parameters:

  • calculationType: The type of throttling calculation.

  • maxAllow: The throttling threshold.

  • period: The throttling calculation period.

desc

The description of the throttling rule.

enable

Specifies whether to enable the throttling rule. Exported rules are disabled by default.

limitStrategy

The type of throttling algorithm.

maxBurstRatio

The burst coefficient for the token bucket algorithm.

resourceConfigs

The throttling object. It includes the following parameters:

  • baseName: The name of the throttling object, such as an interface name plus a method name, or the URI of a web request.

  • resourceType: The type of the target object, such as an interface method or a web request.

runMode

The run mode, such as Block Mode or Monitoring Mode.

For more information, see Add service throttling rules.