Service Scenario Governance
ServiceComb engines provide unified traffic feature governance based on dynamic configurations for different microservice development frameworks, such as Spring Cloud and Java chassis. You can use the microservice governance function of CSE by introducing related governance components to the development frameworks.
ServiceComb engine governance consists of two steps: creating a service scenario and creating a governance policy. The two steps can be performed before microservice deployment for independent governance planning.
- This section applies to ServiceComb engine 2.x.
- If the ServiceComb engine version is 2.0.0 or later but earlier than 2.4.0, the name of this section is "Microservice Governance".
Prerequisites
- You need to understand the API design of the microservice to be governed and create service scenarios based on the API features.
- 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.
Governance Policies
You can configure the following policies: Rate Limiting, Circuit Breaker, Retry, and Bulkhead. For details, see the following table.
Policy |
Description |
---|---|
Rate Limiting |
In the case of a traffic storm or predictable traffic spikes, rate limiting is performed on non-key service scenarios to prevent service and data breakdown caused by instantaneous heavy traffic. |
Retry |
When a service encounters a non-fatal error (such as occasional timeout), retries can be performed to prevent service failures. |
Bulkhead |
In the case of a large-scale concurrent traffic storm or predictable traffic impact, the concurrent traffic is controlled to prevent service and data breakdown caused by instantaneously large concurrent traffic. |
Circuit Breaker |
When the error rate of a service scenario exceeds the threshold, all requests in the service scenario will be rejected within one minute to ensure the availability of the entire service system. Then 50% of the service requests will be accepted and statistics on the service error rate will be collected until the error rate in the service scenario is reduced to a value lower than the threshold. |
Creating a Service Scenario
When a service scenario is created, the configuration starting with servicecomb.matchgroup. is automatically generated.
- Log in to CSE.
- Choose Exclusive ServiceComb Engines.
- Click the target engine.
- Choose Service Scenario Governance.
If the ServiceComb engine version is 2.0.0 or later but earlier than 2.4.0, choose Microservice Governance.
- In the displayed Security Authentication dialog box, enter the account name and password, and click OK.
- If you connect to the ServiceComb engine for the first time, enter the account name root and the password entered when Creating a ServiceComb Engine.
- For details about how to create an account, see Adding an Account.
- Choose Service Scenarios > Create Service Scenario and set parameters by referring to the following table.
Parameter
Description
Scenario
Enter the service scenario name.
Environment
Select a microservice environment.
Application
Select the application to which the service scenario to be created belongs.
Matching Rule
Click Add Matching Rule to set the request marker.
- Method: Select the method of marking the traffic request feature. The GET, PUT, POST, DELETE, and PATCH methods are supported.
- Path: Set features contained in the traffic request URI.
- Headers: Click Add Headers Rule and set the marker of the traffic request header.
NOTE:- Method and Path are mandatory.
- Headers is optional.
- Click OK.
- Click in the row that contains a service scenario to view the matching rule details.
- Click Edit in the Operation column of a service scenario to edit the service scenario.
- Click Delete in the Operation column of a service scenario to delete the service scenario.
Creating a Governance Policy
- Log in to CSE.
- Choose Exclusive ServiceComb Engines.
- Click the target engine.
- Choose Service Scenario Governance.
If the ServiceComb engine version is 2.0.0 or later but earlier than 2.4.0, choose Microservice Governance.
- In the displayed Security Authentication dialog box, enter the account name and password, and click OK.
- If you connect to the ServiceComb engine for the first time, enter the account name root and the password entered when Creating a ServiceComb Engine.
- For details about how to create an account, see Adding an Account.
- Go to the Governance Policy page and click Create Governance Policy.
- Select a governance mode, click Create Policy, and set parameters.
- Rate Limiting
Parameter
Description
Policy
Enter the name of the governance policy.
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 to create 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 the name of the governance policy.
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 to create 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.
- Exponential: Each interval is selected by the exponential backoff algorithm.
Interval Duration
Set the retry interval duration.
- If Retry Interval is set to Fixed, set the fixed interval.
- If Retry Interval is set to Exponential, set the retry benchmark time and unit (s/ms).
- Bulkhead
Parameter
Description
Policy
Enter the name of the governance policy.
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 to create a service scenario.
Max. Concurrency
Set the maximum number of concurrent requests based on the actual service processing capability of the system.
Block Duration
Set the block duration and unit (s/ms).
When the number of concurrent requests exceeds the maximum, the requests are discarded after the blocking duration.
- Circuit Breaker
Parameter
Description
Policy
Enter the name of the governance policy.
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 to create a service scenario.
Coverage
Sliding Window Type
Select a sliding window type.
- Time: time window
- Requests: request window
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.
- Rate Limiting
- 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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot