Isolation rules control the number of concurrent threads for interfaces and dependencies to ensure system stability. They are typically used in scenarios where an application's internal processes or downstream dependencies become unstable, such as slow SQL statements or increased response times from downstream applications. This topic describes how to configure and manage isolation rules.
Prerequisites
Microservices Engine (MSE) Enterprise Edition is activated.
The Microservices Governance feature of MSE is enabled for your microservices applications. For more information, see the following topics:
Background information
If a method or interface of a strong dependency becomes unstable, you can limit its concurrent threads to isolate the issue. When the response time for a request increases, the number of concurrent threads also increases. If the number of concurrent threads exceeds the threshold, MSE rejects excess requests until the stacked tasks are complete and the thread count decreases. This method isolates exceptions and improves stability.
Use the following information to set the concurrency threshold:
Concurrency = Expected Queries Per Second (QPS) × Response time + Redundancy.
For example, assume the expected SQL running time is 20 ms, the expected QPS is 20, and the maximum concurrency is 6. Set the concurrency threshold based on the following logic: Max(20/1000 × 20, 6) = 6. Add a redundancy of 2. The recommended concurrency threshold is 8.
After you set the threshold, if a deadlock or performance issue causes the SQL statement to run slowly, it occupies only 8 threads. This prevents incoming requests that cannot exit quickly from exhausting the active threads of the process.
When the SQL statement returns to normal, the number of concurrent threads quickly decreases. Once the number drops below the threshold, the system stops rejecting requests, and the application's processing capability quickly recovers. This method automatically adjusts based on response time and isolates unstable applications.
Isolation rules are typically used for strong dependency isolation scenarios.
Procedure
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. On the page that appears, click the Through QPS TOP tab. Find the target interface and click Isolation in the Actions column.
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 Flow protection tab, click the Concurrency Isolation tab, and then click Add isolation rule.
In the Add Isolation Protection Rule or Add Rule dialog box, configure the parameters and click Add.
NoteFor more information about the parameters, see More information.
Example: Ensure sufficient resources
When the response time for a request increases, the number of concurrent threads also increases. If the number of concurrent threads exceeds the threshold, MSE rejects excess requests until the stacked tasks are completed and the thread count decreases. This method isolates exceptions and improves stability. For example, the running time of an SQL statement is 20 ms, and the expected QPS is 20.
In the Add Isolation Protection Rule or Add Rule dialog box, set the following parameters:
Set the Interface name parameter.
Set the Concurrency threshold to 10.
After the configuration is complete, if a deadlock or performance issue causes the SQL statement to run slowly, it occupies only 10 threads. This prevents incoming requests that cannot exit quickly from exhausting the active threads of the process. When the SQL statement returns to normal, the number of concurrent threads quickly decreases. Once the number drops below the threshold, the system stops rejecting requests, and the application's processing capability quickly recovers. This method automatically adjusts based on response time and isolates unstable applications.
More information
The following table describes the parameters to configure in the Add Isolation Protection Rule or Add Rule dialog box.
Configuration item | Description |
Interface name | The name of the resource to be isolated. |
Concurrency threshold | The threshold for the number of concurrent threads for the resource. This is the number of threads that are running for the resource. |