SpringCloud of Feign and Ribbon selection (five)

Ribbon

Ribbon is based on a client's HTTP and TCP load balancer which can be configured ribbonServerList (list server) on the client, then a polling request to achieve load balancing ribbonServerList it will be overwritten when used in the combination DiscoveryEnabledNIWSServerList Eureka, extended to the Eureka registration Center for the server list and it will be replaced with NIWSDiscoveryPing iPing, it duties entrusted to Eureka to determine whether the services have been started.

Feign

Spring Cloud Netflix's services are in the form of micro-HTTP interface exposed, so you can use Apache's HttpClient or Spring of RestTemplate to call and Feign is more convenient to use a HTTP client, it uses up the same way as a local call if , just fail to see is a remote method invocation summed up: publish to party registry service interface is HTTP, that can not or Feign Ribbon, direct browsers to access just Ribbon or Feign convenient to call up the most important thing is: Talia soft support load balancing.

Note: spring-cloud-starter-feign which already contains a spring-cloud-starter-ribbon (Feign also used in the Ribbon)

ribbon and feign two differences and choose

  • Select feign

    • The default integrated ribbon

    • To write more clear thinking and convenient

    • Annotations using configuration mode, configuration to facilitate fusing, etc.

  • In the product-service classes, was added

    try {
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException e) {
                e.printStackTrace();
         }

     

    Will this happen:


 Cause: By default optons readtimeout is 60, but because hystrix default is 1 second timeout.

Solution :

# Modify call timeout 
#ribbon timeout
Ribbon :
ReadTimeout : 3000
the ConnectTimeout : 3000

 

Guess you like

Origin www.cnblogs.com/dalianpai/p/11695040.html