Giter VIP home page Giter VIP logo

springcloud-gateway-customer-loadbalancer's Introduction

spring-cloud-gateway customer loadbalancer

简化的Spring Cloud Gateway负载均衡,没有使用服务发现组件。

pom 引入loadbalancer依赖

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

自定义服务实例配置

application:
  load-balancer-clients:
    my-service:
      - host: 127.0.0.1
        port: 9001
        secure: false
      - host: 127.0.0.1
        port: 9011
        secure: false
    app-service:
      - host: 127.0.0.1
        port: 9002
        secure: false
      - host: 127.0.0.1
        port: 9022
        secure: false

该配置定义了2个服务实例信息。分别为 my-service, app-service . 默认负载均衡基于轮询算法实现, 实现RoundRobinLoadBalancer

gateway 配置信息

spring:
  cloud:
    loadbalancer:
      ribbon:
        enabled: false
    gateway:
      routes:
        - id: my-service
          uri: lb://my-service
          predicates:
            - Path=/service/**
          filters:
            - RewritePath=/service(?<segment>/?.*), $\{segment}
        - id: app-service
          uri: lb://app-service
          predicates:
            - Path=/app/**
          filters:
            - RewritePath=/app(?<segment>/?.*), $\{segment}

Reference Document :

https://spring.io/guides/gs/spring-cloud-loadbalancer/

https://cloud.spring.io/spring-cloud-commons/reference/html/#spring-cloud-loadbalancer

https://cloud.spring.io/spring-cloud-gateway/reference/html/#reactive-loadbalancer-client-filter

springcloud-gateway-customer-loadbalancer's People

Contributors

oursy avatar ousya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.