-
netflix 孵化的 网关 解决方案的开源组件
-
zuul 1.0 和 zuul 2.0
-
pivotal 公司 发现 并整合 Spring Cloud 生态系统
-
动态路由,监控,弹性,服务治理
-
认证与授权
-
压力控制
-
金丝雀测试
金丝雀发布: 一般先发 1 台,或者一个小比例,例如 2% 的服务器,主要做流量验证用,也称为金丝雀 (Canary) 测试(国内常称灰度测试)。以前旷工开矿下矿洞前,先会放一只金丝雀进去探是否有有毒气体,看金丝雀能否活下来,金丝雀发布由此得名。 是指在黑与白之间,能够平滑过渡的一种发布方式。
-
动态路由
-
负载消减
-
静态相应处理
-
主动流量管理
-
1.0 底层是 Servlet ,一系列 Filter所构成的责任链
-
现在 cloud是2.3.3.RELEASE,zuul 和 gateWay都是 2.2.5。zuul-core 是 1.3.1。
-
spring-cloud-gateway-core 是 2.2.5.RELEASE。
zuul入门案例
xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
开启zuul和配置
@SpringBootApplication
@EnableDiscoveryClient
@EnableZuulProxy
public class ZuulServerApplication {}
bootstrap.yml
spring:
application:
name: zuul-server
server:
port: 5555
undertow:
worker-threads: 4000 #undertow的工作线程
io-threads: 200 #io 线程
eureka:
client:
serviceUrl:
defaultZone: http://${eureka.host:127.0.0.1}:${eureka.port:8888}/eureka/
instance:
prefer-ip-address: true #更喜欢ip
zuul:
SendErrorFilter:
error:
disable: false #zuul 发送 错误 过滤器,错误关闭 为假
host:
max-per-route-connections: 1024 #主机 最大 路由 连接
max-total-connections: 1024 #最大 总共 连接数
management:
security:
enabled: false #管理 安全 打开为假
application.yml
zuul:
routes:
zuul-gateway: #网关路由,zuul网关
path: /client/** #路径 client 的
serviceId: client-a #转发到client-a
host:
socket-timeout-millis: 600 000 #主机 socket 超时 ,毫秒
connect-timeout-millis: 600 000 #连接 超时 毫秒
hystrix:
command:
default:
execution:
timeout:
enabled: false #hystrix 命令 默认 执行 超时 开启,为假
isolation: #隔离 策略 为线程
strategy: THREAD
thread:
timeoutInMilliseconds: 600 000 #线程超时毫秒
ribbon:
ConnectTimeout: 350 000 #ribbon 连接超时
ReadTimeout: 350 000 #读取超时
MaxAutoRetries: 2 #最大重试
MaxAutoRetriesNextServer: 1 #最大重试 下个server
OkToRetryOnAllOperations: true #ok 到 重试 在 所有的 操作 为true
okhttp:
enabled: true #okhttp 打开状态为 开启。
strategy
英 /ˈstrætədʒi/ 美 /ˈstrætədʒi/ 全球(美国)
简明 牛津 新牛津 韦氏 柯林斯 例句 百科
n. 战略,策略
- http://localhost:5555/client/add?a=100&b=400