gpt4 book ai didi

httpclient - zuul 代理缓慢 - RibbonLoadBalancingHttpClient

转载 作者:行者123 更新时间:2023-12-03 17:38:57 25 4
gpt4 key购买 nike

首先,我只有Java的基本知识。我有一些微服务,目前使用 zuul/eureka 来代理这些服务。

注意到直接调用微服务时的吞吐量比通过 zuul 调用时快 3 倍。所以我想知道我的zuul配置是否错误。

ab 输出:

直接调用微服务:

Concurrency Level:      10
Time taken for tests: 5.938 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 37750000 bytes
HTML transferred: 36190000 bytes
Requests per second: 1684.20 [#/sec] (mean)
Time per request: 5.938 [ms] (mean)
Time per request: 0.594 [ms] (mean, across all concurrent requests)
Transfer rate: 6208.84 [Kbytes/sec] received

通过zuul调用:
Concurrency Level:      10
Time taken for tests: 15.049 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 37990000 bytes
HTML transferred: 36190000 bytes
Requests per second: 664.52 [#/sec] (mean)
Time per request: 15.049 [ms] (mean)
Time per request: 1.505 [ms] (mean, across all concurrent

祖尔配置:
server:
port: 7001

zuul:
#Services will be mapped under the /api URI
prefix: /api
sslHostnameValidationEnabled: false
host:
maxTotalConnections: 800
maxPerRouteConnections: 200

endpoints:
restart:
enabled: true
shutdown:
enabled: true
health:
sensitive: false

eureka:
instance:
hostname: localhost
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/

ribbon:
eureka:
enabled: true

spring:
application:
name: zuul-server
id: zuul-server

请注意,与微服务本身相比,zuul 占用大量 CPU。所以进行了线程转储。我怀疑 RibbonLoadBalancingHttpClient 似乎一直在实例化。

线程转储: https://1drv.ms/t/s!Atq1lsqOLA98mHjh0lSJHPJj5J_I

最佳答案

您指定的 zuul.host.* 属性仅适用于直接指定“url”的 zuul 路由,不适用于从 Eureka 获取的 serviceIds 路由。 See here .您可能希望增加功能区级别的总 HTTP 连接数和每个主机的连接数,然后重新运行您的测试。这是一个示例配置 -

ribbon:
ReadTimeout: 30000
ConnectTimeout: 1000
MaxTotalHttpConnections: 1600
MaxConnectionsPerHost: 800

在我对 Zuul 的测试中,我确实记得看到一些请求的最大响应时间比 zuul 绕过的直接目标请求高得多,但是第 95 个和第 99 个百分位数总是与直接请求相比大约有大约 200 毫秒的差异到目标服务器。

关于httpclient - zuul 代理缓慢 - RibbonLoadBalancingHttpClient,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40947267/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com