spring cloud zuul网关配置实践

zuul:
  okhttp:
    enabled: true # 使用okhttp方式请求,正常来说okhttp比较速度快一点
  semaphore:
    max-semaphores: 500 # 并发处理数,值越大越好,但到到达一个临界点之后,就不会提高响应速度了
  host:
    socket-timeout-millis: 30000 # socket超时时间,如果使用service-id方式是不用配置的
    connect-timeout-millis: 30000 # 连接时间semaphores
    max-total-connections: 5000  # 最大连接数,值越大越好,但到到达一个临界点之后,就不会提高响应速度了
    max-per-route-connections: 5 # 每个router最大连接数,降低请求时间,越小越好,但达到一定层级就没用了

hystrix:
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 30000 # Hystrix超时时间
          strategy: THREAD

ribbon:
  ReadTimeout: 20000 # 处理时间
  ConnectTimeout: 20000 # 连接时间
  MaxAutoRetries: 0 #最大自动重试次数
  MaxAutoRetriesNextServer: 1 # 换实例重试次数
  MaxTotalHttpConnections: 2000 # 最大http连接数,越大越好,但到到达一个临界点之后,就不会提高响应速度了
  MaxConnectionsPerHost: 1000 # 每个host连接数

timeout-in-milliseconds这样编写是不会生效的,需要改为timeoutInMilliseconds,起初认为是Spring的BUG,之后,发现由于default是一个key,是一个Map类型,依照源码中使用的是timeoutInMilliseconds,所以必须timeoutInMilliseconds。

在我真实的项目中连接时间都没有给这么大,给的还是相对较小的。

引用
网关配置实践

posted @ 2019-09-09 17:56  沧海红心_田帅  阅读(23)  评论(0)    收藏  举报  来源