Spring Cloud 各元件調優引數

2022-05-10 01:51:12 字數 3125 閱讀 8407

spring cloud整合了各種元件,每個元件往往還有各種引數。本文來詳細**spring cloud各元件的調優引數。

tomcat配置引數

1 server:

2 tomcat:

3 max-connections: 0 # 預設值

4 max-threads: 0 # 預設值

hystrix配置引數

1 hystrix.threadpool.default.coresize: 10

2 hystrix.threadpool.default.maximumsize: 10

3 hystrix.threadpool.default.maxqueuesize: -1 # 如該值為-1,那麼使用的是synchronousqueue,

4 否則使用的是linkedblockingqueue。

5 注意,修改mq的型別需要重啟。例如從-1修改為100,需要重啟,因為使用的queue型別發生了變化

如果想對特定的hystrixthreadpoolkey進行配置,則將default改為hystrixthreadpoolkey即可。

1 hystrix.command.default.execution.isolation.strategy: semaphore

2 hystrix.command.default.execution.isolation.semaphore.maxconcurrentrequests: 10 # 預設值

如果想對指定的hystrixcommandkey進行配置,則將default改為hystrixcommandkey即可。

feign配置引數

feign預設沒有執行緒池。

當使用httpclient時,可如下設定:

4 max-connections: 200 # 預設值

5 max-connections-per-route: 50 # 預設值

**詳見:

當使用okhttp時,可如下設定:

5 max-connections: 200 # 預設值

6 max-connections-per-route: 50 # 預設值

**詳見:

zuul配置引數

我們知道hystrix有隔離策略:thread以及semaphore,預設是semaphore

隔離策略

1 zuul:

2 ribbon-isolation-strategy: thread

最大訊號

當zuul的隔離策略為semaphore時:

設定預設最大訊號量:

1 zuul:

2 semaphore:

3 max-semaphores: 100 # 預設值

設定指定服務的最大訊號量:

1 zuul:

2 eureka:3:

4 semaphore:

5 max-semaphores: 100 # 預設值

參考:zuul引數

edgware及之後的版本中,當zuul的隔離策略為thread時,可為hystrix配置獨立執行緒池:

參考:如果不設定獨立執行緒池,那麼hystrixthreadpoolkeyribboncommand

hystrix併發配置引數請參考《hystrix併發配置引數一節》

zuul內建的filter

對於形如:

1 zuul:

2 routes:

3 user-route: # 該配置方式中,user-route只是給路由乙個名稱,可以任意起名。

4 url: http://localhost:8000/ # 指定的url

5 path: /user/** # url對應的路徑。

的路由,可使用如下方式配置併發引數:

1 zuul:

2 host:

3 max-total-connections: 200 # 預設值

4 max-per-route-connections: 20 # 預設值

1 serviceid:

2 ribbon:

3 maxtotalconnections: 0 # 預設值

4 maxconnectionsperhost: 0 # 預設值

相關**:org.springframework.cloud.netflix.ribbon.support.abstractloadbalancingclient子類的createdelegate方法。

**自:

Spring Cloud各元件總結歸納

spring cloud技術應用從場景上可以分為兩大類 潤物無聲類和獨挑大樑類。潤物無聲,融合在每個微服務中 依賴其它元件並為其提供服務。獨挑大樑,獨自啟動不需要依賴其它元件。每個元件都不是平白無故的產生的,是為了解決某一特定的問題而存在。特殊成員zipkin,之所以特殊是因為從jar包和包名來看它...

springcloud中各元件彙總

a 服務註冊中心 eureka x zookeeper,consul,nacos b 服務呼叫 ribbon,loadbanlancer,feign x openfeign c 服務熔降級 hystrix x resilience4j,sentinel 阿里 d 服務閘道器 zuul x zuul2...

Spring Cloud各元件重試總結

spring cloud中的重試機制應該說是比較混亂的,不同的版本有一定區別,實現也不大一樣,好在spring cloud camden之後已經基本穩定下來,dalston中又進行了一些改進,詳情暫且不表。下面我們來詳細 筆者使用的版本是spring cloud dalston sr4,同樣適應於e...