zuul proxy slowness - RibbonLoadBalancingHttpClient

时间:2016-12-03 11:33:14

标签: httpclient netflix-zuul netflix-eureka netflix-ribbon

首先,我只掌握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 

Zuul config:

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

1 个答案:

答案 0 :(得分:0)

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

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

在我与Zuul的测试中,我确实记得看到最大响应时间的一些请求远远高于zuul-bypasssed直接目标请求,但第95和第99百分位数总是可以与大约200ms的差异相比较直接请求到目标服务器。