1. Concept
Turbine is a tool for the aggregation server to send event stream data to monitor the metrics of hystrix under the cluster.
2. Introduce dependencies
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-turbine</artifactId>
</dependency>
3. Create an application
TurbineApplication
@SpringBootApplication
@EnableTurbine
public class TurbineApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(TurbineApplication.class).web(true).run(args);
}
}
4. Corresponding configuration information
server.port=8031
spring.application.name=turbine
turbine.appConfig=app01,app02
turbine.aggregator.clusterConfig= app
turbine.clusterNameExpression= metadata['cluster']
turbine.appConfig configures the application that needs to be aggregated
turbine.aggregator.clusterConfig turbine needs to aggregate the cluster name Access turbine.clusterNameExpression through http://localhost:8031/turbine.stream?cluster=app to
get the cluster name expression, here means to get metadata The cluster data in the app01 and app02 is the configuration corresponding information
5. Create EurekaServer service
6. Create application app01
@Configuration
@EnableAutoConfiguration
@EnableDiscoveryClient
@EnableCircuitBreaker
@RestController
public class App01 {
public static void main(String[] args) {
SpringApplication.run(App01.class, args);
}
@Autowired
private HelloService service;
@RequestMapping("/")
public String hello() {
return this.service.hello();
}
@Component
public static class HelloService {
@HystrixCommand(fallbackMethod = "fallback")
public String hello() {
return "Hello World";
}
public String fallback() {
return "Fallback";
}
}
}
Corresponding configuration:
server.port= 8091
spring.application.name=app01
eureka.instance.hostname=localhost
eureka.instance.metadata-map.cluster=app
7. Create application app02
Corresponding configuration:
server.port= 8092
spring.application.name=app02
eureka.instance.hostname=localhost
eureka.instance.metadata-map.cluster=app
8. The three applications are registered to EurekaServer at the same time, and then start the large disk service, enter http://localhost:9031/turbine.stream?cluster=app in the large disk service to get the monitoring interface;
9. The meaning of each indicator of the monitoring interface
Circle Color and Size : Represents Health and Flow
Polyline : Changes in throughput over 2 minutes
hosts : the number of nodes in the cluster
median : median of each request time
mean : the average time spent per request
subscriberGetAccount :
Green 200545: Represents the number of successful requests
Blue 0: Represents the number of disconnections
Yellow 19: Represents the number of threads that have timed out
Violet 94: Represents the number of thread pool rejections, that is, the number of threads is not enough
Red 0: The number of failures or exceptions
Gray 0%: The last 10 Error rate per secondhost : the average request throughput per second for each node
cluster : the request throughput per second of the cluster
circuit : represents the state of the circuit breaker, namely: whether to open the circuit breaker 90th, 99th, 99.5th:
the percentage of various delays in the last minute. As shown in the figure: 90% of the requests are less than 10ms; 99% of the requests are less than 44ms, and 99.5% of the requests are completed in 61ms.
10. Summary
Through turbine, you can monitor the request volume of the cluster, and you can know the peak request period of the system, so as to better know where the shortcomings of the system are.