Isolation rules ensure system stability by controlling the number of concurrent threads for interfaces or dependencies. These rules are useful when an application or its downstream dependencies become unstable, for example, due to slow SQL statements or increased response times from downstream applications. This topic describes how to configure and manage isolation rules.
Prerequisites
Activate Enterprise Edition. For more information, see Upgrade Microservice Administration to Enterprise Edition.
The microservice application has been onboarded to the MSE administration center. For more information, see:
Background information
If a method or interface with strong dependencies becomes unstable, you can limit its concurrency by configuring the number of concurrent threads. This isolates the instability. If the response time for a request increases, the number of concurrent threads also increases. When the number of concurrent threads exceeds the threshold, MSE rejects new requests. MSE continues to reject requests until the stacked tasks are complete and the number of concurrent threads falls below the threshold. This isolates the abnormal behavior and improves stability.
To set the concurrency threshold, consider the following:
Number of concurrent threads = Expected queries per second (QPS) × Response time + Buffer.
For example, assume the expected running time of an SQL statement is 20 ms and the expected number of requests per second is 20. The maximum concurrency is 6. You can set the number of concurrent threads using this logic: Max(20/1000 × 20, 6) = 6. Add a buffer of 2. This results in a recommended concurrency threshold of 8.
After you configure the rule, if the SQL statement encounters a deadlock or performance issue, it becomes a slow SQL statement. Even if requests continue to arrive, they will occupy a maximum of 8 threads. This prevents incoming requests that cannot be processed quickly from using all active threads in the process.
When the SQL statement returns to normal, the number of concurrent threads quickly decreases. When the concurrency falls below the threshold, the system stops rejecting requests and the application's processing capacity recovers quickly. This method automatically adjusts based on response time and isolates unstable applications.
Isolation rule configurations are typically used for scenarios that require strong dependency isolation.
Accessing the feature
-
Log on to the MSE console, and select a region in the top navigation bar.
-
In the left-side navigation pane, choose Microservices Governance > Application Governance.
-
On the Application list page, click the resource card of the desired application.
On the application details page, create an isolation rule using one of the following methods:
In the navigation pane on the left, click Application Overview. Then, click the Through QPS TOP tab and click Isolation in the Actions column for the target interface.
In the navigation pane on the left, click API Details. On the Concurrency Isolation tab, click Add isolation rule.
In the navigation pane on the left, click Traffic management. On the page that appears, click the Flow protection tab, then the Concurrency Isolation tab, and then click Add isolation rule.
In the Add Isolation Protection Rule or Add Rule dialog box, configure the settings and click New.
NoteFor more information about the parameters, see More information.
Example: Ensure sufficient resources
If the response time for a request increases, the number of concurrent threads also increases. When the number of concurrent threads exceeds the threshold, MSE rejects new requests until the stacked tasks are complete and the number of concurrent threads falls below the threshold. This isolates the abnormal behavior and improves stability. For example, assume the running time of an SQL statement is 20 ms and the expected number of requests per second is 20.
In the Add Isolation Protection Rule or Add Rule dialog box, configure the following parameters:
Enter the Interface Name.
Set Concurrency threshold to 10.
After you configure the rule, if the SQL statement encounters a deadlock or performance issue, it becomes a slow SQL statement. Even if requests continue to arrive, they will occupy a maximum of 10 threads. This prevents incoming requests that cannot be processed quickly from using all active threads in the process. When the SQL statement returns to normal, the number of concurrent threads quickly decreases. When the concurrency falls below the threshold, the system stops rejecting requests and the application's processing capacity recovers quickly. This method automatically adjusts based on response time and isolates unstable applications.
More information
The following table describes the configuration items in the Add Isolation Protection Rule or Add Rule dialog box.
Configuration item | Description |
Interface Name | The name of the resource to isolate. |
Concurrency threshold | The threshold for the number of concurrent threads for the resource. This is the number of threads that are currently executing the resource. |