Menu
Home
Log in / Register
 
Home arrow Computer Science arrow Microservices Flexible Software Architecture
Source

Monitoring with the Hystrix Dashboard

Whether a Circuit Breaker is currently open or closed gives an indication of how well a system is running. Hystrix offers data to monitor this. A Hystrix system provides such data as a stream of JSON documents via HTTP. The Hystrix Dashboard can visualize the data in a web interface. The dashboard presents all Circuit Breakers along with the number of requests and their state (open/closed) (see Figure 13.9). In addition, it displays the state of the thread pools.

A Spring Boot Application needs to have the annotation @EnableHystrixDash- board and a dependency to spring-cloud-starter-hystrix-dashboard to be able to display a Hystrix Dashboard. That way any Spring Boot application might in addition show a Hystrix Dashboard, or the dashboard can be implemented in an application by itself.

Turbine

In a complex microservices environment it is not useful that each instance of a microservice visualizes the information concerning the state of its Hystrix Circuit Breaker. The state of all Circuit Breakers in the entire system should be summarized on a single dashboard. To visualize the data of the different Hystrix systems on one

Example for a Hystrix Dashboard

Figure 13.9 Example for a Hystrix Dashboard

dashboard, there is the Turbine project. Figure 13.10 illustrates the approach Turbine takes: the different streams of the Hystrix enabled microservices are provided at URLs like http:///hystrix.stream. The Turbine server requests them and provides them in a consolidated manner at the URL http:///turbine. stream. This URL can be used by the dashboard in order to display the information of all Circuit Breakers of the different microservice instances.

Turbine runs in a separate process. With Spring Boot the Turbine server is a simple application, which is annotated with @EnableTurbine and @EnableEurekaClient. In the example application it has the additional annotation @EnableHystrixDash- board so that it also displays the Hystrix Dashboard. It also needs a dependency on spring-cloud-starter-turbine.

Which data is consolidated by the Turbine server is determined by the configuration of the application. Listing 13.9 shows the configuration of the Turbine servers of the example project. It serves as a configuration for a Spring Boot application just like application.properties files but is written in YAML. The configuration sets the value ORDER for turbine.aggregator.clusterConfig. This is the application name in Eureka. turbine.aggregator.appConfig is the name of the data stream in the Turbine server. In the Hystrix Dashboard a URL like http://172.17.0.10:8989/turbine. stream?cluster=ORDER has to be used in visualize the data stream. Part of the URL is the IP address of the Turbine server, which can be found in the Eureka Dashboard. The dashboard accesses the Turbine server via the network between the Docker containers.

Listing 13.9 Configuration application.yml

turbine: aggregator: clusterConfig: ORDER appConfig: order

Turbine Consolidates Hystrix Monitoring Data

Figure 13.10 Turbine Consolidates Hystrix Monitoring Data

Try and Experiment

• Terminate Microservices

Using the example application generate a number of orders. Find the name of the “Catalog” Docker container using docke ps. Stop the “Catalog” Docker container with docker kill. This use is protected by Hystrix.

What happens? What happens if the “Customer” Docker container is terminated as well? The use of this microservice is not protected by Hystrix.

• Add Hystrix to “Customer” Microservice

Protect the use of the “Customer” Docker container with Hystrix also. In order to do so change the class CustomerClient from the “Order” project. CatalogClient can serve as a template.

• Change Hystrix Configuration

Change the configuration of Hystrix for the “Catalog” microservice. There are several configuration options.14 Listing 13.8 (CatalogClient from the “Order” Project) shows the use of the Hystrix annotations. Other time intervals for opening and closing of the circuit breakers are, for instance, a possible change.

14. https://github.com/Netflix/Hystrix/wiki/Configuration

 
Source
Found a mistake? Please highlight the word and press Shift + Enter  
< Prev   CONTENTS   Next >
 
Subjects
Accounting
Business & Finance
Communication
Computer Science
Economics
Education
Engineering
Environment
Geography
Health
History
Language & Literature
Law
Management
Marketing
Mathematics
Political science
Philosophy
Psychology
Religion
Sociology
Travel