Many students know Meituan comments, I was responsible for security platform for the development of stability, one of the functions of the platform has the service of fusing relegation, filed a fusing downgrade, you may be familiar with the Hystrix Netflix open source components, but we don’t have secondary development on the basis of it, but lu a again, may be someone said, Isn’t it a waste of time reinventing the wheel? So don’t be afraid to build a wheel. Only with constant innovation can you make continuous progress.
Why do you need a circuit breaker downgrade in the first place?
The stability of the service is the cornerstone for the sustainable development of the company, with the rapid development of business, some normal operation of the service at ordinary times, there will be a variety of contingencies, and in a distributed system, each service itself and there are a lot of uncontrollable factors, such as thread pool processing is slow, lead to request timeout, insufficient resources, lead to the request is rejected, Even direct service is unavailable, down, database is down, cache is down, message system is down…
For some non-core services, if a large number of exceptions occur, you can use technical means to degrade the services and provide damaging services to ensure the flexible availability of services and avoid avalanche effect.
If ServiceD ServiceD ServiceD consistently fails to be invoked by ServiceA, or if there is a high rate of failure, “a mechanism” can be used to ensure that ServiceD ServiceD ServiceD is not invoked by subsequent requests, but by a downgrade logic.
The mechanism here is circuit breaker downgrade. The implementation principle of circuit breaker downgrade is also very simple, as shown in the following figure:
1. Monitor the health value of the interface in real time and automatically start the fuse when the fuse condition is reached. 2. Every once in a while, a request is released to the server for detection, and if the back-end service has been restored, it is automatically restored
Of course, the implementation, I won’t go into details here.
Here, why did not use Hystrix for secondary development, mainly for the following considerations: 1. Built-in parameter configuration cannot be dynamically modified; 2. Complex code design, which makes it difficult to expand new functions; 3
Through self-development, you are free to control any detail and integrate seamlessly with the internal framework.
Advertise for your own planet and look forward to your participation
You pay for it, but it’s worth it