2017-06-14 829 views
1

我想爲zuul version 1.1.2做負載測試。配置maxSemaphores zuul服務器

但是,在運行負載測試後,我幾分鐘後不斷收到以下問題。

Caused by: com.netflix.hystrix.exception.HystrixRuntimeException: book could not acquire a semaphore for execution and no fallback available. 
    at com.netflix.hystrix.AbstractCommand$21.call(AbstractCommand.java:783) ~[hystrix-core-1.5.3.jar:1.5.3] 

我的問題是我該如何通過配合來增加maxSemaphores

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds= 20000000 
zuul.hystrix.command.default.execution.isolation.strategy= SEMAPHORE 
zuul.hystrix.command.default.execution.isolation.semaphore.maxConcurrentRequests= 10 
zuul.hystrix.command.default.fallback.isolation.semaphore.maxConcurrentRequests= 10 
zuul.semaphore.maxSemaphores=3000 

zuul.eureka.book.semaphore.maxSemaphore = 30000

我曾嘗試在搜索的Intenet很多的選擇,但這些作品之一,我

請告知

回答

1

我能夠配置maxSemaphores的特定server_id'本書'如下:

zuul.eureka.book.semaphore.maxSemaphores=30000 

但是我想設置的默認值所有色帶客戶路由到後端微服務,類似如下一個

zuul.eureka.default.semaphore.maxSemaphores=30000 

但它不會採取任何影響。

我還檢查了RestClientRibbonCommand類的代碼,有趣的是它只支持server_id基礎。

代碼片段

protected static HystrixCommand.Setter getSetter(String commandKey) { 
     // we want to default to semaphore-isolation since this wraps 
     // 2 others commands that are already thread isolated 
     String name = ZuulConstants.ZUUL_EUREKA + commandKey + ".semaphore.maxSemaphores"; 
     DynamicIntProperty value = DynamicPropertyFactory.getInstance().getIntProperty(
       name, 100); 
     HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter() 
       .withExecutionIsolationStrategy(ExecutionIsolationStrategy.SEMAPHORE) 
       .withExecutionIsolationSemaphoreMaxConcurrentRequests(value.get()); 
     return Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RibbonCommand")) 
       .andCommandKey(HystrixCommandKey.Factory.asKey(commandKey)) 
       .andCommandPropertiesDefaults(setter); 
    } 

這是很奇怪的Zuul意味着對動態路由,所以我不希望配置爲每一個服務。

請指教?

0

原來我使用舊版本。對於後來的版本,我們可以在Zuul級別設置信號量。下面是設置maxSemaphores 3000爲默認路由到每個代理的業務

zuul.semaphore.maxSemaphores = 3000

0

的實際屬性是MAX-信號量(這將是與YAML配置)的一個例子:

zuul: 
    semaphore: 
    #com.netflix.hystrix.exception.HystrixRuntimeException: "microservice" could not acquire a semaphore for execution and no fallback available. 
    max-semaphores: 2000