首先,我只有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 似乎一直在实例化。