序文
ゲートウェイステータスの前で関連記事ゲートウェイは、ゲートウェイはとても重要であるため、それは保証の安定とゲートウェイの信頼性の高い動作にも、記載されています。いわゆる安定性と信頼性は、このような災害復旧クラスタリング、パフォーマンスチューニング、負荷分散などのようにいくつかの領域、より多くの何物でもありません。この記事では、ゲートウェイプロジェクト、最適化性能へのゲートウェイをチューニングする、いくつかのパラメータチューニングのためになります。
準備
複雑な支出記事春の雲の高度道路| 6:サービスゲートウェイは(zuul + Hystrixダッシュボード)監視回路ブレーカ統合 xmall製品、xmall-AUTH:すべての作品 、xmallゲートウェイを。
チューニングパラメータ
チューニングパラメータZuulゲートウェイ、以下の分野:コンテナ、zuul、hystrix、リボン、11、のようなふりを以下に説明しました。
コンテナ(Tomcatの)
調整MAX-スレッド、MIN-スペアスレッド、MAX-接続、MAX-HTTPヘッダサイズTomcatの例です。自己のストレステストの結果、特定の値が徐々に調整します。
server:
tomcat:
max-threads: 2000
min-spare-threads: 400
max-connections: 30000
max-http-header-size: 10MB
zuul
ホストパラメータ、最大あたりのルート接続を調整し 、MAX-全接続、接続タイムアウト-ミリ秒、ソケットタイムアウトミリ秒、接続要求タイムアウト-ミリ秒、生存時間を。時間単位は、調整された時間単位のパラメータを変更するために必要な場合。
zuul:
host:
max-per-route-connections: 500
max-total-connections: 6000
connect-timeout-millis: 70000
socket-timeout-millis: 60000
# connection-request-timeout-millis: -1
# time-to-live: -1
# time-unit: milliseconds
関連するパラメータのhystrixを調整します
hystrixのデフォルトの隔離政策でzuul SEMAPHORE。スレッドプールを使用してhystrix分離戦略として、あなたはリボン型分離戦略パラメータTHREADを調整する必要があります。セマフォのセマフォ、もし。このような単離戦略THREADとして、あなたには、configure hystrix関連するパラメータ(次のセクションを参照)に必要です。分離戦略は、セマフォである、zuul.semaphore.max-セマフォを調整することによって達成することができます。
zuul:
# hystrix 隔离策略
ribbon-isolation-strategy: thread
# zuul hystrix semaphore配置
# semaphore:
# max-semaphores: 5000
# zuul hystrix thread pool配置
# thread-pool:
# use-separate-thread-pools: false
# thread-pool-key-prefix: test-
hystrix
デフォルトの隔離政策THREAD。パラメータhystrix.command.default.execution.isolation.strategyを調整することによって。その他の詳細な構成はHystrixCommandPropertiesを見つけることができます。
hystrix:
command:
default:
execution:
isolation:
strategy: THREAD
ストレステスト結果の特定の値によって、coreSize、MaximumSizeを、maxQueueSizeを最適化する分離戦略を、スレッド、徐々に調整しました。
# hystrix 默认线程池配置
threadpool:
default:
coreSize: 600
maximumSize: 1000
maxQueueSize: -1
また、必要がtimeoutInMilliseconds値を最適化します。
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 300000
注:この値は、方法で計算された記事を参照して以下リボンタイムアウトエラーよりHystrixタイムアウトを導入しました。
リボン
ニーズがMaxConnectionsPerHost、MaxTotalConnections、のconnecttimeout、ReadTimeout、MaxAutoRetries、MaxAutoRetriesNextServerを最適化します。connecttimeoutの1、ReadTimeout、MaxAutoRetries、MaxAutoRetriesNextServer問題hystrix.timeoutInMilliseconds計算の詳細は、以下で紹介したリボンタイムアウトエラーよりも記事Hystrixのタイムアウトを見ていることに注意してください。詳細な構成は、DefaultClientConfigImpl、IClientConfig、IClientConfigKeyを参照してください。
ribbon:
MaxConnectionsPerHost: 500
MaxTotalConnections: 2000
ConnectTimeout: 60000
ReadTimeout: 60000
# MaxAutoRetries: 0
# MaxAutoRetriesNextServer: 1
見せ掛けます
まず、装うクライアント構成のconnecttimeout、readTimeoutを最適化する必要があります。詳細な構成FeignClientConfigurationを参照してください。
feign:
hystrix:
enabled: true
client:
config:
default:
connectTimeout: 60000
readTimeout: 40000
loggerLevel: full
あなたが設定のために別のサービスが必要な場合は、デフォルトのサービス名はでき置き換えることができます。
feign:
hystrix:
enabled: true
client:
config:
xmall-auth:
connectTimeout: 60000
readTimeout: 40000
loggerLevel: full
feign.client実装について、okhttp選択します。しかし、どんなにオプションの実装は、接続タイムアウト、max-connectionsの、max-connectionsのあたりのルートを最適化するために必要とされています。okhttp例に:
feign:
httpclient:
enabled: false
connection-timeout: 60000
max-connections: 2000
max-connections-per-route: 500
# 启用okhttp
okhttp:
enabled: true
最終的な構成
作品のこのシリーズでは、例えば、圧力SOAPUIの60年代同時ストレステストの結果に応じて、パラメータは次のように、著者の試みの結果である調整:60年代10000スレッド、メモリの8G、単一の例では、ストレスのないことができます。
server:
port: 5566
tomcat:
max-threads: 2000
min-spare-threads: 400
max-connections: 30000
max-http-header-size: 10MB
zuul:
prefix: /gateway
sensitive-headers:
routes:
auth:
path: /auth/**
service-id: xmall-auth
strip-prefix: true
product:
path: /product/**
service-id: xmall-product
strip-prefix: true
host:
max-per-route-connections: 500
max-total-connections: 6000
connect-timeout-millis: 70000
socket-timeout-millis: 60000
# connection-request-timeout-millis: -1
# time-to-live: -1
# time-unit: milliseconds
# hystrix 隔离策略
ribbon-isolation-strategy: thread
# zuul hystrix semaphore配置
# semaphore:
# max-semaphores: 5000
# zuul hystrix thread pool配置
# thread-pool:
# use-separate-thread-pools: false
# thread-pool-key-prefix: test-
hystrix:
command:
default:
execution:
isolation:
strategy: THREAD
thread:
timeoutInMilliseconds: 300000
# hystrix 默认线程池配置
threadpool:
default:
coreSize: 600
maximumSize: 1000
maxQueueSize: -1
# hystrix 服务自定义线程池配置
# xmall-auth:
# coreSize: 600
# maximumSize: 1000
# maxQueueSize: -1
# ribbon配置
ribbon:
MaxConnectionsPerHost: 500
MaxTotalConnections: 2000
ConnectTimeout: 60000
ReadTimeout: 60000
security:
oauth2:
resource:
user-info-uri: http://localhost:7777/oauth/user
prefer-token-info: false
feign:
hystrix:
enabled: true
client:
config:
default:
connectTimeout: 60000
readTimeout: 40000
loggerLevel: full
httpclient:
enabled: false
connection-timeout: 60000
max-connections: 2000
max-connections-per-route: 500
# 启用okhttp
okhttp:
enabled: true
management:
endpoints:
web:
exposure:
include: '*'
ソース
githubの
https://github.com/liuminglei/SpringCloudLearning/tree/master/17/
gitee
https://gitee.com/xbd521/SpringCloudLearning/tree/master/17/
この記事は重版のための記事で、[ギャラクシー]オリジナルの建築家である明白なの著者とソースを明記してください。
マイクロチャンネルサーチ[建築家]ギャラクシーは、よりエキサイティングなコンテンツを見つけます。