zoukankan      html  css  js  c++  java
  • springcloud第三篇:Spring Cloud Gateway

    Spring Cloud Gateway是网关。

    网关是直接与客户端(App、H5、小程序等)交互的服务端组件,网关要绝对高可用且不能随便重启。

    网关应该至少具备以下基本功能:

    1、路由转发请求

    2、负载均衡且可以自动感知应用服务器的增加或减少

    3、限流

    4、在更改以上功能策略时不用重启

    额外地,最好还支持断路器。

    在Spring Cloud架构,推荐的网关是Spring Cloud Gateway和Netflix zuul2。

    搭建网关应用

    1、引入网关依赖

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-gateway</artifactId>
    </dependency>

    2、在配置文件配置路由规则。

    路由主要有几部分组成:路由id,要满足什么条件predicate,路由到哪里uri,路由前后的过滤器filter。

    示例:

    server.port=80
    spring.cloud.gateway.routes[0].id=toBaidu
    spring.cloud.gateway.routes[0].uri=http://www.baidu.com
    spring.cloud.gateway.routes[0].predicates[0]=Path=/abc/**
    spring.cloud.gateway.routes[0].filters[0]=StripPrefix=1

    用RouteDefinition类表示路由。RouteDefinition的属性有id、

    疑问

    1、网关集群怎么搭建?单机肯定是不行的

    2、网关各路由如何单独设置负载均衡?

    3、网关各路由的QPS及总请求量数据怎么监控?

  • 相关阅读:
    style实例
    背景小实例
    html表单与输入实例
    列表小知识
    表格的使用
    框架的奥秘
    链接那档子事
    判断网络是否连通
    Python3编码规范
    CentOS 7 安装 Docker-Compose
  • 原文地址:https://www.cnblogs.com/koushr/p/11774143.html
Copyright © 2011-2022 走看看