Updated on 2025-08-29 GMT+08:00

Creating a Governance Policy

A governance policy is a method used for microservice governance. Each governance policy can be bound to a service scenario. A policy cannot be bound to multiple service scenarios. Different governance policies can be bound to the same service scenario.

Prerequisites

  • You have created a service scenario by referring to Creating a Service Scenario.
  • You need to enable the dynamic configuration-based traffic feature governance function for the development framework of the microservice to be governed. If the function is not enabled, the microservice governance function can still be used, but the governance has no effects.

Creating a Governance Policy

  1. Click the target engine.
  2. Choose Service Scenario Governance.

    If the ServiceComb engine version is 2.0.0 or later but earlier than 2.4.0, choose Microservice Governance.

    • For engines with security authentication disabled, go to 4.
    • For engines with security authentication enabled, if the login VDC user is the user imported in Importing an IAM Account, go to 4. For other users, go to 3.

  3. In the displayed Security Authentication dialog box, enter the account name and password, and click OK.

  4. Go to the Governance Policy page and click Create Governance Policy.
  5. Select a governance mode, click Create Policy, and set parameters.

    • Rate limiting

      Parameter

      Description

      Policy

      Enter a governance policy name. Enter up to 32 characters.

      Service Scenarios

      Set the service scenarios to which the governance policy applies.

      • Click Select Service Scenario and select the created service scenario.
      • Click Create Service Scenario. For details, see Creating a Service Scenario.

      Requests per Unit

      Set the number of requests and time segment.

      When the number of requests sent by the rate limiting object to the current service instance within the specified period exceeds the specified value, the excess requests are limited and error code 429 is returned.

    • Retry

      Parameter

      Description

      Policy

      Enter a governance policy name. Enter up to 32 characters.

      Service Scenarios

      Set the service scenarios to which the governance policy applies.

      • Click Select Service Scenario and select the created service scenario.
      • Click Create Service Scenario. For details, see Creating a Service Scenario.

      Response Error Code

      Enter response error codes to define the error types that trigger retries.

      Retry Attempts

      Set the number of retries.

      Retry Interval

      Select a retry policy.

      • Fixed: The retry interval is fixed. For example, if the retry interval is set to 500 ms, the interval between two consecutive retries remains 500 ms regardless of the number of retries.
      • Exponential: Each retry interval is randomly determined based on an algorithm. Generally, the retry interval increases exponentially with the number of retries. For example, the retry interval may be 100 ms for the first retry, 200 ms for the second retry, and 400 ms for the third retry.

      Interval Duration

      Set the retry interval duration.

      • If Retry Interval is set to Fixed, set the fixed retry interval. The value is an integer ranging from 1 to 60,000, in seconds or milliseconds.
      • If Retry Interval is set to Exponential, set the retry benchmark time. The value ranges from 1 to 60,000, in seconds or milliseconds.
    • Bulkhead

      Parameter

      Description

      Policy

      Enter a governance policy name. Enter up to 32 characters.

      Service Scenarios

      Set the service scenarios to which the governance policy applies.

      • Click Select Service Scenario and select the created service scenario.
      • Click Create Service Scenario. For details, see Creating a Service Scenario.

      Max. Concurrency

      Set the maximum number of concurrent requests based on the actual service processing capability of the system.

      Block Duration

      When the number of concurrent requests exceeds the maximum, the requests are discarded after the blocking duration. The value is an integer ranging from 1 to 300,000, in seconds or milliseconds.

    • Circuit breaker

      Parameter

      Description

      Policy

      Enter a governance policy name. Enter up to 32 characters.

      Service Scenarios

      Set the service scenarios to which the governance policy applies.

      • Click Select Service Scenario and select the created service scenario.
      • Click Create Service Scenario. For details, see Creating a Service Scenario.

      Coverage

      Sliding Window Type

      Select a sliding window type. Sliding window: range of request call times. The system monitors calls within this range to trigger the circuit breaker when they exceed the baseline.

      • Time: The window range is determined by time.
      • Requests: The window range is determined by the number of requests.

      Sliding Window Size

      Set the size of the sliding window.

      • If Sliding Window Type is set to Time, the calls in the last n seconds or minutes are recorded and collected.
      • If Sliding Window Type is set to Requests, the latest n calls are recorded and collected.

      n is the size of the sliding window.

      Calls Baseline

      Set the baseline of the number of calls, that is, the minimum number of calls required for collecting statistics on the call error rate.

      For example, if Calls Baseline is set to 10, at least 10 call must be recorded to collect statistics on the error rate.

      Triggers

      Error Threshold

      Percentage of call errors. This parameter is valid when Set circuit breaker to trigger at an error threshold is selected.

      When the call error rate is greater than or equal to the error threshold, circuit breaker occurs and response code 429 is returned.

      Slow Request Ratio

      This parameter is valid when Set circuit breaker to trigger at a specific request speed and ratio is selected. Set the following parameters:

      • Slow Speed: defines the slow request threshold. If the response time of a request exceeds the threshold, the request is a slow request.
      • Slow Threshold: When the specified slow request ratio is reached, circuit breaker occurs and response code 429 is returned.

  6. Click Create to make the governance policy take effect.

    In the governance policy list, click in the row where the service scenario is located:

    • Click Enable in the Operation column of a governance policy to enable the policy.
    • Click Disable in the Operation column of a governance policy to disable the policy.
    • Click Edit in the Operation column of a governance policy to edit the policy.
    • Click Delete in the Operation column of a governance policy to delete the policy.