当前位置:网站首页>Service fusing hystrix
Service fusing hystrix
2022-07-05 05:18:00 【Meow xiansen likes fish】
One 、 summary
1.1 The problem of Distributed Computing
Applications in complex distributed architectures have dozens of dependencies , Every dependency will inevitably fail at some point 、
Service avalanche
When calling between multiple microservices , Suppose microservices A Call microservices B Micro service C, Microservices B Micro service C Call other microservices , That's what's called “ Fan out ”. If the call response time of a microservice on the fan out link is too long or unavailable , On the service A More and more system resources will be occupied by the call of , And then cause the system to crash , This is called “ Avalanche effect ”.
For high traffic applications , A single back-end dependency can cause all resources on all servers to saturate in seconds . Worse than failure is , These applications can also lead to increased latency between services , Backup queues , Threads and other system resources are tight , Cause more cascading failures in the whole system . These indicate the need to isolate and manage failures and delays , To the failure of a single dependency , Will not affect the entire application or system . therefore , Usually when you find that an instance under a module fails , At this time, this module will still receive traffic , Then the problematic module calls other modules , So there's a cascading failure , Or an avalanche .
1.2 Hystrix
Hystrix Is an open source library for dealing with latency and fault tolerance in distributed systems , In distributed systems , Many dependencies inevitably fail , For example, timeout. 、 Abnormal etc. .Hystrix To ensure that in the case of a dependency problem , It doesn't cause the overall service to fail , Avoid cascading faults , To improve the flexibility of distributed systems .
“ Circuit breaker ” It's a switching device , When a service unit fails , Through the fault monitoring of the circuit breaker ( Similar to a blown fuse ), Return an expected... To the caller 、 Alternative responses that can be handled (FallBack), Instead of waiting for a long time or throwing an exception that the caller can't handle , This ensures that the threads of the service caller will not be held for a long time 、 Occupy unnecessarily , Thus, it can avoid the fault spreading in the distributed system , Even an avalanche .
1.3 Hystrix effect
- Package request : Use HystrixCommand The calling logic since the package team , Each command is executed in a separate thread . The author used the “ Command mode ”.
- Trip mechanism : When the error rate of a service exceeds a certain threshold ,Hystrix It can trip automatically or manually , Stop requesting the service for a period of time .
- Resource isolation :Hystrix A small thread pool is maintained for each dependency ( Or semaphores ). If the thread pool is full , The request sent to the dependency will be rejected immediately , Instead of waiting in line , So as to speed up the failure determination .
- monitor :Hystrix It can monitor the changes of operation indicators and configurations in near real time , For example, success 、 Failure 、 Overtime , And rejected requests .
- Fallback mechanism : When the request fails 、 Overtime 、 Be rejected , Or when the circuit breaker is on , Perform fallback logic . The fallback logic is provided by the developer , For example, return a default value .
- Self repair : After the circuit breaker is opened for a period of time , Will automatically enter “ half ” state .
1.4 Hystrix Important concepts
1.4.1 Service isolation
It refers to dividing the system into several service modules according to certain principles , Each module is relatively independent , No strong dependence . When something goes wrong , Can isolate problems and impacts within a module , And the risk of non-proliferation , It does not affect other modules , Does not affect the overall system services .
1.4.2 Service failure
The concept of fusing comes from the circuit breaker in Electronic Engineering (Circuit Breaker). In the Internet system , When downstream services respond slowly or fail due to heavy access pressure , Upstream services to protect the overall availability of the system , You can temporarily cut off calls to downstream services . The sacrifice is local , The measure to preserve the whole is called fusing .
1.4.3 service degradation
So called demotion , It's when a service melts , The server will no longer be called , At this point the client can prepare a local one itself fallback Callback , Returns a default value . It can also be understood as telling the truth .
What conditions trigger demotion ?
- The program runs abnormally
- Overtime
- Service fusions trigger service degradation
- Thread pool / If the semaphore is full, the service will be degraded

1.4.4 Service restriction
Flow restriction can be considered as a kind of service degradation , Current limiting is to limit the input and output flow of the system , To protect the system . Generally speaking , The throughput of the system can be measured , In order to ensure the stable operation of the system , Once you reach the threshold you need to limit , We need to limit the flow and take a small amount of measures to achieve the purpose of limiting the flow . example : Put off solving 、 Refuse to resolve , Or partial refusal to solve, etc .
边栏推荐
- 支持多模多态 GBase 8c数据库持续创新重磅升级
- Dotween usage records ----- appendinterval, appendcallback
- 《动手学深度学习》学习笔记
- Programmers' experience of delivering takeout
- 64 horses, 8 tracks, how many times does it take to find the fastest 4 horses at least
- Grail layout and double wing layout
- Applet Live + e - commerce, si vous voulez être un nouveau e - commerce de détail, utilisez - le!
- cocos_ Lua loads the file generated by bmfont fnt
- cocos2dx_ Lua card flip
- Ue4/ue5 illusory engine, material chapter, texture, compression and memory compression and memory
猜你喜欢
![[trans]: spécification osgi](/img/54/d73a8d3e375dfe430c2eca39617b9c.png)
[trans]: spécification osgi

stm32Cubemx(8):RTC和RTC唤醒中断

Quick sort summary
![[to be continued] [depth first search] 547 Number of provinces](/img/c4/b4ee3d936776dafc15ac275d2059cd.jpg)
[to be continued] [depth first search] 547 Number of provinces

Do a small pressure test with JMeter tool

Fragment addition failed error lookup

Chinese notes of unit particle system particle effect

Unity find the coordinates of a point on the circle
![[interval problem] 435 Non overlapping interval](/img/a3/2911ee72635b93b6430c2efd05ec9a.jpg)
[interval problem] 435 Non overlapping interval
![[turn to] MySQL operation practice (I): Keywords & functions](/img/b1/8b843014f365b786e310718f669043.png)
[turn to] MySQL operation practice (I): Keywords & functions
随机推荐
Cocos create Jiugongge pictures
[转]: OSGI规范 深入浅出
[to be continued] [UE4 notes] L1 create and configure items
[allocation problem] 455 Distribute cookies
Grail layout and double wing layout
To be continued] [UE4 notes] L4 object editing
[interval problem] 435 Non overlapping interval
The present is a gift from heaven -- a film review of the journey of the soul
被舆论盯上的蔚来,何时再次“起高楼”?
嵌入式数据库开发编程(五)——DQL
Pause and resume of cocos2dx Lua scenario
Kali 2018 full image download
Download and use of font icons
[leetcode] integer inversion [7]
The difference between heap and stack
十年不用一次的JVM调用
PMP candidates, please check the precautions for PMP examination in July
stm32Cubemx(8):RTC和RTC唤醒中断
BUUCTF MISC
Double pointer Foundation