重新定义cloud 第7章 Srping cloud zuul基础篇.md

  • 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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值