[英]How to perform a failover with Netflix/Eureka?
我使用Eureka作為我的服務發現和負載均衡器,並且當有兩個服務實例“A”時工作正常,但是當我停止其中一個實例時,Eureka無法識別其中一個實例已關閉,每次負載均衡器嘗試使用死實例時,它都會讓我顯示錯誤頁面。
我已將enableSelfPreservation
為false
以防止這種情況,但是取出注冊該服務需要3到5分鍾,但是我希望我的服務具有高可用性,並且我希望在幾秒鍾內立即執行故障轉移。 這是否可能使用Eureka,如果不是,我怎樣才能實現僅在其他人死亡時使用活動實例。
我正在使用spring boot,這是我對Eureka服務器的配置。
server:
port: 8761
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
server:
enableSelfPreservation: false
您應該為application.yml添加功能區配置。 還建議使用超時設置將hystrix隔離級別設置為THREAD。
注意:此配置應位於客戶端(這通常意味着您的網關服務器),因為功能區(通常是Spring Cloud)是客戶端負載平衡的一種形式。
這是我使用的一個例子:
hystrix:
command:
default:
execution:
isolation:
strategy: THREAD
thread:
timeoutInMilliseconds: 40000 #Timeout after this time in milliseconds
ribbon:
ConnectTimeout: 5000 #try to connect to the endpoint for 5 seconds.
ReadTimeout: 5000 #try to get a response after successfull connection for 5 seconds
# Max number of retries on the same server (excluding the first try)
maxAutoRetries: 1
# Max number of next servers to retry (excluding the first server)
MaxAutoRetriesNextServer: 2
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.