SpringCloud監(jiān)控&保護(hù)之->Hystrix+Dashboard+turbine
一、demo項(xiàng)目搭建
引用網(wǎng)絡(luò)資源: https://blog.csdn.net/forezp/article/details/81041113
具體的demo項(xiàng)目搭建可參見(jiàn)以上網(wǎng)絡(luò)資源。"史上最簡(jiǎn)單的SpringCloud教程 "
二、基本知識(shí)點(diǎn)
基本上看完以下兩圖就足夠了
圖片
圖片
三、Dashborad配置
http://ip:port/hystrix 打開(kāi)以下頁(yè)面
圖片
四、hystrix參數(shù)配置
以下這個(gè)博客已經(jīng)對(duì)參數(shù)使用及分類說(shuō)的非常詳細(xì)了
引用網(wǎng)絡(luò)資源:https://blog.csdn.net/tongtong_use/article/details/78611225
我本地demo的一個(gè)配置可以參考下:
#feign開(kāi)啟hystrix
feign.hystrix.enabled=true
#全局超時(shí)配置,單位ms,默認(rèn)值1000ms
hystrix.command.default.execution.isolation.thread.timeoutInMillisecnotallow=10000
#熔斷觸發(fā)的最小個(gè)數(shù)/10s,時(shí)間默認(rèn)是10s
hystrix.command.default.circuitBreaker.requestVolumeThreshold=5
#ribbon的超時(shí)時(shí)間
ribbon.ReadTimeout=10000
ribbon.Cnotallow=10000
#同一實(shí)例最大重試次數(shù),不包括首次調(diào)用。默認(rèn)值為0
ribbon.MaxAutoRetries = 0
#同一個(gè)服務(wù)其他實(shí)例的最大重試次數(shù),不包括第一次調(diào)用的實(shí)例。默認(rèn)值為1
ribbon.MaxAutoRetriesNextServer = 0
#是否所有操作都允許重試。默認(rèn)值為false
ribbon.OkToRetryOnAllOperations = false五、相關(guān)問(wèn)題
1、HystrixCommandKey到底是個(gè)啥?
圖片
就是:類名#方法名() 就是dashboard這里顯示出來(lái)的名字
圖片
2、hystrix.command.default.circuitBreaker.requestVolumeThreshold是時(shí)間是多長(zhǎng)的,默認(rèn)是10s
3、hystrix.command.default.execution.isolation.thread. timeoutInMilliseconds設(shè)置了超時(shí)時(shí)間為什么沒(méi)生效?
需要考慮到feign最終還是要經(jīng)過(guò)ribbon,ribbon有個(gè)默認(rèn)重試1次的設(shè)置,同時(shí)也有默認(rèn)超時(shí)時(shí)間1s。考慮到這2點(diǎn)就能正確的設(shè)置timeoutInMilliseconds的值了。
4、hystrix與springbootadmin
springbootadmin已經(jīng)有個(gè)比較有好的管理界面,1.x的springbootadmin有把dashboard集成到springbootadmin中作為admin的一個(gè)菜單(在依賴中增加spring-boot-admin-server-ui-hystrix就可以)??垂俜轿臋n好像springbootadmin 2.x已經(jīng)去掉了。















 
 
 










 
 
 
 