In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Then in the previous article, the needle made some summary of the common problems of Spring Cloud again.
1. The first request failed after integrating Hystrix
1.1 cause analysis
The default timeout for Hystrix is 1 second, and if you don't get a response within 1 second, you will enter the fallback logic.
To understand the springcloud architecture, please add: 3536247259, due to the lazy loading mechanism of Spring.
The first request tends to be slow, so on some machines (especially those with low configuration), the first request may take more than 1 second.
1.2 solution
There are many ways to solve this problem. Here are some relatively simple solutions:
1) method 1: configure hunger loading for Ribbon.
Ribbon: eager-load: enabled: true clients: client1,client2
For Zuul:
Zuul: ribbon: eager-load: enabled: true
2) method 2: extend the timeout of Hystrix. The example is as follows
Hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds:5000
This configuration changes the timeout of Hystrix to 5 seconds.
3) method 3: disable Hystrix timeout, as shown in the following example
Hystrix.command.default.execution.timeout.enabled: false
Method 4: for Feign, you can also disable Hystrix for Feign. The example is as follows
Feign.hystrix.enabled: false
This enables Hystrix support to be disabled globally for Feign. However, this method is extreme and is generally not recommended.
2. Turbine aggregate data is incomplete
This problem occurs with Turbine in some versions of Spring Cloud, such as Brixton SR5. The direct view of this problem is as follows:
Turbine is used to aggregate multiple micro-services, but only some of the monitoring data of micro-services can be seen on Hystrix Dashboard.
Phenomenon description:
For example, the configuration of Turbine is as follows:
Turbine is supposed to aggregate the monitoring data of the two micro-services cloud-consumer-movie,cloud-consumer-movie-feign-hystrix-fallback-stream. However, when you open Hystrix Dashboard, you will find that only part of the monitoring data of micro-services are displayed on Dashboard.
Solution:
This problem occurs when Turbine-aggregated microservices are deployed on the same host.
Solution one:
Configure different hostname for each microservice, and set preferIpAddress to false or not.
Eureka: client: serviceUrl: defaultZone: http://127.0.0.1:8001/eureka/ instance: hostname:ribbon # configure hostname
Solution 2:
Set turbine.combine-host-port = true
Turbine: appConfig: cloud-consumer-movie,cloud-consumer-movie-feign-hystrix-fallback-stream clusterNameExpression: "'default'" combine-host-port:true
Method 3:
Upgrade Spring Cloud to Camden or later. Of course, you can also upgrade Spring Cloud Netflix to the latest stable version above 1.2.0 separately (it is generally not recommended to upgrade Spring Cloud Netflix separately, as it may conflict with other components of Spring Cloud).
This is because the default value for turbine.combine-host-port in older versions is false. Spring Cloud is aware of the problem, so the default value for this property is set to true in the new version. The solution and method are essentially the same.
Related code
Org.springframework.cloud.netflix.turbine.TurbineProperties.combine-HostPort org.springframework.cloud.netflix.turbine.CommonsInstanceDiscovery.getInstance (String, Boolean)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.