First, preface
For the soon-to-be open source surging by many. NET classmates, also by the. NET Core Learning Group, invited to join the. NET China Foundation to facilitate the promotion of domestic. NET core open source projects, I accepted the invitation to join the team to Exchange learning, and recently updated the new version of surging.
Update content:
1. Castle.core compatibility issue, the next version will be removed, to solve some users of the first compilation vs card death problem
2. Increased fault-tolerant demotion
3. Routing Fault-tolerant refactoring, for failed retries and failures without retries, failed callbacks,
4. Add some functional unit tests
5. Upgrade supports. NET CORE 2.0
Latest Address: https://github.com/dotnetcore/surging
Ii. Service-tolerant degradation Introduction and Example 1. Service-Tolerant Downgrade introduction
For the micro-service reliability mentioned in the previous article, for fault tolerance and degraded ellipsis, this article introduces fault tolerance and demotion
When microservices are not available, fault-tolerant processing is required based on the policies that are provisioned, and most of the fault tolerance and policies are public and therefore can be implemented in a framework.
Service Fault Tolerance
When the microservices call fails, the fault-tolerant mechanism can be used to realize the automatic fault-tolerant processing of microservices and improve the reliability of the system.
Surging fault tolerant strategies include:
Failure auto-switching mechanism (Failover): MicroServices invocation failure auto-switching policy refers to re-routing when a service invocation exception occurs, finding the next available microservices provider. When MicroServices are released, you can specify a cluster fault tolerance policy for the service. Consumers can override the general configuration of the service provider and implement a personalized fault-tolerant strategy.
Failure callback mechanism (injection): After a microservices call fails, provide an exception callback interface or inject script to execute the service consumer's custom failure handling logic.
Service downgrade
Service for some reason is not available, but the process can not directly fail, the need for local injection server implementation, such as the end of the year to purchase tickets 12306 large-scale access, resulting in the query train ticket service does not work properly, this time to do business to pass, return the last cache record or null, rather than return failure.
Common policies for demotion:
1, the service route short-circuit, directly return NULL. For example injection = "return null;".
3, service routing short-circuit, directly execute the local analog interface implementation class. injection = "true;".
Fault Tolerant Demotion
When the service is not available, you can service the business logic and let the service run properly
Automatic fault-tolerant demotion: The trigger is automatically matched against the defined Kanbao value, and the associated policy is called for demotion.
Forced demotion: triggered manually by operations based on the operation of the system.
2. Service Tolerance Degradation Example
Create a service fault tolerance downgrade, select injection policy script injection, and return null directly
[Command (strategy= strategytype.injection, injection = @ "return null;")]
Create a service fault tolerance downgrade, select injection policy script injection, and return directly to Task<usermodel>
[Command (strategy= strategytype.injection, injection = @ "Return Task.fromresult (new Surging.IModuleServices.Common.Models.UserModel { name= "" Fanly "", age=18
Create a service fault tolerance downgrade, select the injection policy direct local module call
Create a service fault tolerance downgrade, select the failover policy, and automatically switch to retry the remote call
Configuring related parameter lists
parameter |
action |
remarks |
< P style= "margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px ">strategy |
Fault tolerant strategy |
Includes failover and injection |
< P style= "margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px ">failovercluster |
failover Count |
|
Executiontimeoutinmilliseconds |
Execution time-out |
Default value: 1000 |
Requestcacheenabled |
Whether to turn on caching |
Default off |
Injection |
script injection |
&NBSP; |
|
inject namespace |
|
|
error rate to achieve how many turn on fuse protection |
default value: |
Breakesleepwindowinmilliseconds |
How many seconds after the fuse to try to request |
Default value: 60000 |
Breakerforceclosed |
Whether to force the fuse off |
|
|
at least how many requests fail within 10 seconds, the fuse is functioning |
default value: |
Maxconcurrentrequests |
Maximum number of concurrent |
10 |
Three. Testing
Test environment
Cpu:intel Core I7-4710MQ
Memory: 16G
HDD: 1T ssd+512g HDD
Network: LAN
The test results are as follows:
Iii. Summary
Surging next version to increase cache demotion, configure services for file fault tolerance, downgrade, and so on, add unit test, for API Gateway is developing, such as interested please pay more attention or join QQ Group: 615562965
Based on the. NET Core MicroServices framework-talk about service-tolerant degradation of surging