All Products
Search
Document Center

Microservices Engine:CreateCircuitBreakerRule

Last Updated:Nov 20, 2024

Creates a circuit breaking rule.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
mse:CreateCircuitBreakerRulecreate
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
NamespacestringYes

The microservice namespace to which the application belongs.

default
AppNamestringYes

The application name.

spring-cloud-a
ThresholdfloatYes

A percentage threshold for triggering circuit breaking. Valid values: 0-1. These values represent 0% to 100%.

0.8
EnablebooleanYes

Specifies whether to enable the rule.

Valid values:

  • true

  • false

true
ResourcestringYes

The name of the interface to which the rule applies. The interface name must be the same as the name on the interface details page in the console.

/a
AppIdstringNo

The ID of the application.

hkhon1po62@c3df23522bXXXXX
RegionIdstringNo

The region in which the instance resides.

cn-hangzhou
StrategyintegerYes

The threshold type.

Valid values:

  • 0

    :

    slow call proportion

  • 1

    :

    abnormal proportion

0
RetryTimeoutMsintegerNo

The period in which circuit breaking is implemented. Unit: milliseconds. If circuit breaking is implemented on the requests for the route, the calls to all the requests for the route fail in the configured circuit breaking period. The value must be an integral multiple of 1,000. Default value: 10000. This value indicates 10 seconds.

10000
StatIntervalMsintegerNo

The length of the time window. Unit: milliseconds. The valid range is from 1 second to 120 minutes. The default value is 20000. This value indicates 20 seconds.

20000
MaxAllowedRtMsintegerNo

The maximum response time (RT). Unit: milliseconds. If the RT of a request is greater than the value of this parameter, a slow call is counted. If you set Strategy to 0, you must specify this parameter.

200
MinRequestAmountintegerNo

The minimum number of requests to trigger circuit breaking. If the number of requests in the current time window is less than the value of this parameter, circuit breaking is not triggered even if the circuit breaking rule is met. Default value: 10.

10
HalfOpenBaseAmountPerStepintegerNo

The minimum number of requests that can be passed in each step after circuit breaking recovers. Default value: 1.

5
HalfOpenRecoveryStepNumintegerNo

The number of circuit breaking recovery steps. Default value: 1.

1
ResourceTypeintegerNo

The resource type.

Valid values:

  • 0: custom interface
  • 1: web
  • 2: RPC
  • 3: route
  • 4: SQL
Enumeration Value:
  • 0: .
  • 1: WEB.
  • 2: RPC.
  • 3: ROUTE.
  • 4: SQL.
0
AcceptLanguagestringNo

The language of the response. Valid values:

  • zh: Chinese
  • en: English
zh

Response parameters

ParameterTypeDescriptionExample
object
Messagestring

The message returned.

OK
RequestIdstring

The request ID.

EE5C32A1-BC0E-4B79-817C-103E4EDF****
Codestring

The response code returned.

200
Dataobject

The details of the rule.

Namespacestring

The microservice namespace to which the application belongs.

default
Idlong

The ID of the rule.

1
AppNamestring

The name of the application.

spring-cloud-a
Resourcestring

The name of the interface to which the rule is applicable. The interface name must be the same as the name on the interface details page in the console.

/a
StatIntervalMsinteger

The length of the time window. Unit: milliseconds. The valid range is from 1 second to 120 minutes.

20000
Thresholdfloat

A percentage threshold for triggering circuit breaking. Valid values: 0-1. These values represent 0% to 100%.

0.8
Enableboolean

Indicates whether the rule is enabled.

true
Strategyinteger

The threshold type.

Valid values:

  • 0

    :

    Slow call ratio

  • 1

    :

    Abnormal proportion

0
RetryTimeoutMsinteger

The period in which circuit breaking is implemented. Unit: milliseconds. If circuit breaking is implemented on the requests for the route, the calls to all the requests for the route fail in the configured circuit breaking period.

10000
AppIdstring

The ID of the application.

hkhon1po62@c3df23522bXXXXX
RegionIdstring

The region in which the instance resides.

cn-hangzhou
MaxAllowedRtMsinteger

The maximum response time (RT). Unit: milliseconds. If the RT of a request is greater than the value of this parameter, a slow call is counted. If you set Strategy to 0, you must specify this parameter.

200
MinRequestAmountinteger

The minimum number of requests to trigger circuit breaking. If the number of requests in the current time window is less than the value of this parameter, circuit breaking is not triggered even if the circuit breaking rule is met.

10
HalfOpenBaseAmountPerStepinteger

The minimum number of requests that can be passed in each step after circuit breaking recovers.

5
HalfOpenRecoveryStepNuminteger

The number of circuit breaking recovery steps.

1
Successboolean

Indicates whether the request was successful.

Valid values:

  • true

  • false

true

Examples

Sample success responses

JSONformat

{
  "Message": "OK",
  "RequestId": "EE5C32A1-BC0E-4B79-817C-103E4EDF****",
  "Code": "200",
  "Data": {
    "Namespace": "default",
    "Id": 1,
    "AppName": "spring-cloud-a",
    "Resource": "/a",
    "StatIntervalMs": 20000,
    "Threshold": 0.8,
    "Enable": true,
    "Strategy": 0,
    "RetryTimeoutMs": 10000,
    "AppId": "hkhon1po62@c3df23522bXXXXX",
    "RegionId": "cn-hangzhou",
    "MaxAllowedRtMs": 200,
    "MinRequestAmount": 10,
    "HalfOpenBaseAmountPerStep": 5,
    "HalfOpenRecoveryStepNum": 1
  },
  "Success": true
}

Error codes

HTTP status codeError codeError messageDescription
400IllegalRequestInvalid request:%sInvalid request: %s
400InvalidParameterParameter error:%sRequest parameter error: %s
403NoPermissionYou are not authorized to perform this operation:%sYou do not have the permission to use this interface:%s
404NotFoundNot found:%sThe resource does not exist:%s
500InternalErrorConsole error. Try again later:%sConsole error. Try again later: %s

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-05-22The internal configuration of the API is changed, but the call is not affectedView Change Details
2023-12-19The request parameters of the API has changedView Change Details