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

Configuring a Circuit Breaker Policy

If an exception occurs when a microservice consumer accesses a provider, for example, the instance network is disconnected or the request times out, and the exception accumulates to a certain extent, the consumer needs to stop accessing the provider and return an exception or a default value to prevent the avalanche effect.

Prerequisites

You have created a microservice by referring to Creating a Microservice. After the microservice starts, the service instance is registered with the corresponding service based on the configurations in the YAML file. If the microservice is not created in advance or has been deleted, the microservice is automatically created when the service instance is registered.

Configuring Circuit Breaker

  1. Click the target engine.
  2. 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. Click the target microservice. Click Circuit Breaker.
  5. Click New and select a proper policy. The following table describes the configuration items of circuit breaker.

    Figure 1 Configuring circuit breaker (for microservices accessed through Spring Cloud)
    Figure 2 Configuring circuit breaker (for microservices accessed through Java chassis)

    Parameter

    Description

    Downstream Microservice

    This configuration applies to microservices accessed through Spring Cloud.

    Configure circuit breaker for the microservice to invoke the downstream microservice. You can select a downstream microservice from the drop-down list.

    Circuit Breaker Object

    This configuration applies to microservices accessed through Java chassis.

    Microservice or method called by the application.

    Request Path

    This configuration applies to microservices accessed through Spring Cloud.

    You can click and set Method (such as GET, POST, and PUT), Path (request path), and Headers to filter requests.

    Circuit Breaker Time Window

    Circuit breaker duration. No response is sent within the time window. Unit: ms.

    Circuit Breaker Rate

    Percentage of failed requests within the specified number of window requests. For example, if Window Requests is set to 20 and Circuit Breaker Rate is set to 50%, circuit breaker is triggered when 10 of the 20 (50%) requests fail.

    Window Requests

    Number of requests received within the time window. Circuit breaker is triggered only when Circuit Breaker Rate and Window Requests both reach their thresholds.

  6. Click OK.