Tutorial: Use Circuit Breaker Dashboard with Azure Spring Apps

Warning

Hystrix is no longer in active development and is currently in maintenance mode.

Note

The Basic, Standard, and Enterprise plans will be deprecated starting from mid-March, 2025, with a 3 year retirement period. We recommend transitioning to Azure Container Apps. For more information, see the Azure Spring Apps retirement announcement.

The Standard consumption and dedicated plan will be deprecated starting September 30, 2024, with a complete shutdown after six months. We recommend transitioning to Azure Container Apps.

This article shows you how to use Netflix Turbine and Netflix Hystrix on Azure Spring Apps. Spring Cloud Netflix Turbine is widely used to aggregate multiple Netflix Hystrix metrics streams so that streams can be monitored in a single view using Hystrix dashboard.

Note

Netflix Hystrix is widely used in many existing Spring apps but it's no longer in active development. If you're developing a new project, you should use Spring Cloud Circuit Breaker implementations like resilience4j instead. Different from Turbine shown in this tutorial, the new Spring Cloud Circuit Breaker framework unifies all implementations of its metrics data pipeline into Micrometer, which is also supported by Azure Spring Apps. For more information, see Collect Spring Cloud Resilience4J Circuit Breaker Metrics with Micrometer (Preview).

Prepare your sample applications

The sample is forked from this repository.

Clone the sample repository to your develop environment:

git clone https://github.com/Azure-Samples/azure-spring-apps-samples.git
cd azure-spring-apps-samples/hystrix-turbine-sample

Build the three applications that are in this tutorial:

  • user-service: A simple REST service that has a single endpoint of /personalized/{id}
  • recommendation-service: A simple REST service that has a single endpoint of /recommendations, which is called by user-service.
  • hystrix-turbine: A Hystrix dashboard service to display Hystrix streams and a Turbine service aggregating Hystrix metrics stream from other services.
mvn clean package -D skipTests -f user-service/pom.xml
mvn clean package -D skipTests -f recommendation-service/pom.xml
mvn clean package -D skipTests -f hystrix-turbine/pom.xml

Provision your Azure Spring Apps instance

Follow the steps in the Provision an instance of Azure Spring Apps section of Quickstart: Deploy your first application to Azure Spring Apps.

Deploy your applications to Azure Spring Apps

These apps don't use Config Server, so there's no need to set up Config Server for Azure Spring Apps. Create and deploy as follows:

az configure --defaults \
    group=<resource-group-name> \
    spring=<Azure-Spring-Apps-instance-name>

az spring app create --name user-service --assign-endpoint
az spring app create --name recommendation-service
az spring app create --name hystrix-turbine --assign-endpoint

az spring app deploy \
    --name user-service \
    --artifact-path user-service/target/user-service.jar
az spring app deploy \
    --name recommendation-service \
    --artifact-path recommendation-service/target/recommendation-service.jar
az spring app deploy \
    --name hystrix-turbine \
    --artifact-path hystrix-turbine/target/hystrix-turbine.jar

Verify your apps

After all the apps are running and discoverable, access user-service with the path https://<Azure-Spring-Apps-instance-name>-user-service.microservices.azure.cn/personalized/1 from your browser. If the user-service can access recommendation-service, you should get the following output. Refresh the web page a few times if it doesn't work.

[{"name":"Product1","description":"Description1","detailsLink":"link1"},{"name":"Product2","description":"Description2","detailsLink":"link3"},{"name":"Product3","description":"Description3","detailsLink":"link3"}]

Access your Hystrix dashboard and metrics stream

Verify using public endpoints or private test endpoints.

Using public endpoints

Access hystrix-turbine with the path https://<SERVICE-NAME>-hystrix-turbine.microservices.azure.cn/hystrix from your browser. The following figure shows the Hystrix dashboard running in this app.

Screenshot of the Hystrix Dashboard that shows the Delay and Title details.

Copy the Turbine stream url https://<SERVICE-NAME>-hystrix-turbine.microservices.azure.cn/turbine.stream?cluster=default into the text box, and select Monitor Stream. This action displays the dashboard. If nothing shows in the viewer, hit the user-service endpoints to generate streams.

Screenshot of the Hystrix stream page that shows the Circuit and Thread Pools details.

Note

In production, the Hystrix dashboard and metrics stream should not be exposed to the Internet.

Using private test endpoints

Hystrix metrics streams are also accessible from test-endpoint. As a backend service, we didn't assign a public end-point for recommendation-service, but we can show its metrics with test-endpoint at https://primary:<KEY>@<SERVICE-NAME>.test.microservices.azure.cn/recommendation-service/default/actuator/hystrix.stream

Screenshot of the Hystrix test-endpoint stream page.

As a web app, Hystrix dashboard should be working on test-endpoint. If it isn't working properly, there may be two reasons: first, using test-endpoint changed the base URL from / to /<APP-NAME>/<DEPLOYMENT-NAME>, or, second, the web app is using absolute path for static resource. To get it working on test-endpoint, you might need to manually edit the <base> in the front-end files.

Next steps