Small class D - + service load balancing policy between micro Docker advanced tutorial _4-04 length of service calls springcloud new version of the actual adjustment

notes

4, call the Superior length of service load balancing strategy adjustment combat
    Description: combat adjust the default load balancing strategy combat

    custom load balancing strategy: http: //cloud.spring.io/spring-cloud-static/Finchley.RELEASE/single /spring-cloud.html#_customizing_the_ribbon_client_by_setting_properties

    in the configuration file yml inside, custom load balancing strategy
        # custom load balancing strategy
        Product-Service:
          Ribbon:
            NFLoadBalancerRuleClassName: com.netflix.loadbalancer.RandomRule

    policy options:
        1, if each machine configuration Like, it is recommended not to modify the policy (recommended)
        2, if the strong part of the machine configuration, you can instead WeightedResponseTimeRule

Start

First review process on lesson

chose a method which has getServer method

getServer layers of calls, finally returns policy loadBalancer load balancer

loadBalance there are methods to increase addServer services, chooseServer select service approach

also get all of the services the method of the list of getAllServers

find the implementation class BaseLoadBalancer

baseLoadBalance choose which method here rule strategy





IRule is the interface

strategies there are many, you can select the


default strategy is a way of polling. Always turn the port in the way of access to the three services

Change Policy


Official documents address
http://cloud.spring.io/spring-cloud-static/Finchley.RELEASE/single/spring-cloud.html#_customizing_the_ribbon_client_by_setting_properties



find IRule implementation class, package name to copy

the configuration of the package is the full path name + class mode name

 

verification


Here add breakpoints to test

access interface

Note that this intermediate product-service is a horizontal line of

the current model is random

now is random, not in accordance with the three services in turn to


 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/11444179.html