Zuul配置详解

1.路由中参数path、url和path、serviceId配置区别

Spring Cloud Zuul默认包含了对Hystrix和Ribbon的依赖,所以Zuul拥有线程隔离断路器的自我保护功能,以及对客户端的负载均衡能力。但是,需要注意在使用path和url的映射关系来配置路由规则时,对于路由转发的请求不会采用HystrixCommand机制,所以这类路由请求没有线程隔离和断路器的保护以及负载均衡的能力。所以使用Zuul的时候尽量使用path和serviceId的方式配置。
在这里插入图片描述

2.策略选择(Semaphore/ThreadPool)

在这里插入图片描述
在这里插入图片描述

3.prefix 和 strip-prefix使用

prefix :前缀,当请求匹配前缀时会进行代理。
strip-prefix :代理前缀默认会从请求路径中移除,通过该设置关闭移除功能。
例如:
1.当 stripPrefix=true 的时 (会移除),默认为true
http://127.0.0.1:7001/api/userdemo/list 变为http://192.168.1.100:8080/userdemo/list)
2.当stripPrefix=false的时(不会移除)
http://127.0.0.1:7001/api/userdemo/list 变为http://192.168.1.100:8080/api/userdemo/list

 # 将请求/api/userdemo/test 转发到user-demo的 /api/test
  prefix: /api   # 访问网关路径的前缀(在映射路径的前面,一般用于区别开发的版本)
  strip-prefix: false
  ##路由代理
  routes:
    user-token:
      path: /userdemo/**
      serviceId: user-demo
      ------------------------------------------------------------------------
# 将请求/api/userdemo/test 转发到user-demo的 /userdemo/test
  prefix: /api   # 访问网关路径的前缀(在映射路径的前面,一般用于区别开发的版本)
  ##路由代理
  routes:
    user-token:
      path: /userdemo/**
      strip-prefix: false
      serviceId: user-demo
	

4.相关调优

参考链接:
1.http://www.itmuch.com/spring-cloud-sum/spring-cloud-concurrent/
2.https://www.jianshu.com/p/ebd62bac2ed4
3.https://blog.csdn.net/w1014074794/article/details/88571880

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值