Giter VIP home page Giter VIP logo

spring-guides / gs-spring-cloud-loadbalancer Goto Github PK

View Code? Open in Web Editor NEW
28.0 21.0 38.0 383 KB

Client-Side Load-Balancing with Spring Cloud LoadBalancer :: Dynamically select correct instance for the request :: spring-cloud,spring-cloud-loadbalancer,spring-cloud-commons

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

License: Apache License 2.0

Java 96.23% Shell 3.77%
spring-cloud spring-cloud-commons

gs-spring-cloud-loadbalancer's Issues

Request to check using '.withHealthChecks()' on Custom loadbalancer configuration

I have trouble with health-check with custom loadbalancer configuration from "say-hello" and "user" modules from 'complete' folder here.

Can you please check if I have miss something? Or do I need to set more configuration for using '.withHealthChecks()'?

Let me share how I tested.

  1. Download "complete" folder and run "say-hello" with port 8090 and run "user" with port 8888.

  2. Try accessing to "user" : http://localhost:8888/hi

  3. Access localhost:8090, localhost:9092, localhost:8099 following RoundRobin rule (port 8090, 9092, 8099 described on 'https://github.com/spring-guides/gs-spring-cloud-loadbalancer/blob/main/complete/user/src/main/java/hello/SayHelloConfiguration.java')

  4. Modify custom config like below from the file 'https://github.com/spring-guides/gs-spring-cloud-loadbalancer/blob/main/complete/user/src/main/java/hello/SayHelloConfiguration.java'.

    @bean
    @primary
    ServiceInstanceListSupplier serviceInstanceListSupplier(
    ConfigurableApplicationContext context
    ) {
    // return new DemoServiceInstanceListSuppler("say-hello");
    return ServiceInstanceListSupplier.builder()
    .withBase(new DemoServiceInstanceListSuppler("say-hello"))
    .withHealthChecks()
    .build(context);
    }

  5. Run "user" again and try accessing to "user".

  6. Got the error log and can not access to "say-hello".

2021-05-07 11:31:55.619 WARN 63497 --- [ parallel-5] o.s.c.l.core.RoundRobinLoadBalancer : No servers available for service: localhost
2021-05-07 11:31:55.619 WARN 63497 --- [ parallel-5] eactorLoadBalancerExchangeFilterFunction : LoadBalancer does not contain an instance for the service localhost
2021-05-07 11:31:55.619 WARN 63497 --- [ parallel-5] o.s.c.l.core.RoundRobinLoadBalancer : No servers available for service: localhost
2021-05-07 11:31:55.620 WARN 63497 --- [ parallel-5] eactorLoadBalancerExchangeFilterFunction : LoadBalancer does not contain an instance for the service localhost
2021-05-07 11:31:55.620 WARN 63497 --- [ parallel-5] o.s.c.l.core.RoundRobinLoadBalancer : No servers available for service: localhost
2021-05-07 11:31:55.620 WARN 63497 --- [ parallel-5] eactorLoadBalancerExchangeFilterFunction : LoadBalancer does not contain an instance for the service localhost

load balancing not work

I creat new webflux client project run on tomcat without spring boot. but get exception:
Caused by: java.net.UnknownHostException: Failed to resolve 'say-hello' after 3 queries

what is wrong?
image

Missing steps to migrate from Netflix Ribbon to Spring Cloud LoadBalancer

I was hoping to find some migration steps from Netflix Ribbon to Spring Cloud LoadBalancer in https://spring.io/guides/gs/client-side-load-balancing/ or in https://spring.io/guides/gs/spring-cloud-loadbalancer/.

So I have the properties for Netflix Ribbon: https://github.com/Netflix/ribbon/wiki/Getting-Started#the-properties-file-sample-clientproperties

I can group the properties in 3 categories:

  • retry settings
  • timeouts
  • discovery settings

For the timeouts I have a possible solution to create a different load balanced restTemplate for each API called:

@Bean
@LoadBalanced
public RestTemplate restTemplate(RestTemplateBuilder builder, Environment env){
    builder.setReadTimeout(env.getProperty(SERVICE_NAME + ".ribbon.ReadTimeout", Duration.class, Duration.of(3L, ChronoUnit.SECONDS)));
    //builder.additionalInterceptors(...);
    //builder.errorHandler(...)
    return builder.build();
}

For the discovery settings, more exactly the static list of addresses I made a class that implements org.springframework.cloud.client.discovery.DiscoveryClient, but how should I deal with the retry settings, more exactly with MaxAutoRetriesNextServer ?

And is this the best approach to create a different restTemplate for each API called?

Upgrade Spring Boot to the latest version

Update the guide to use the most recent Spring Boot version.

To do so, change the Spring Boot version in:

initial/build.gradle
initial/pom.xml
complete/build.gradle
complete/pom.xml

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.