Hystrix Circuit Breaker Implementation be at Zuul API Gateway Level or at REST API Service Level - spring-boot

For Example, I have two Rest Api services running
https://my-app-one.com/get
https://my-app-two.com/update
After Zuul API Gateway Implementation the requests will be routed to
Zuul Proxy:
Proxy 1 : https://zuul-api-gateway.com/get
Proxy 2 : https://zuul-api-gateway.com/update
Questions:
Can we implement Hystrix Dashboard at Zuul API gateway level?
Can we utilize all Hystrix commands if implemented at API gateway level?
What are the challenges and please provide documentation or examples.
I already have a working example of Hystrix Circuit Breaker and Hystrix Dashboard. All I want to know is if I can move Hystrix implementation at Zuul API gateway level.

#IMNash: Unfortunately, I cannot comment to your original question so I am afraid I have to ask you via an Answer. I am terribly sorry that I need to do that but I don't have enough reputation points yet.
Is it mandatory for you to go the Zuul way? If not, you might want to consider using Spring Cloud Gateway. The relevant post from Baeldung is an eye opener. See the below snippet:
//...route definition
.route(r -> r.path("/articles")
.filters(f -> f.hystrix("some-command"))
.uri("http://baeldung.com")
.id("hystrix_route")
I have tested this myself and yes, it's that easy to apply Hystrix.
The next step would be to configure the Hystrix filter as per your needs (e.g. timeouts, max semaphores, etc.).

I think we can only implement hystrix at individual rest service level. we can't implement hystrix at zuul routing level.

Related

Mixed Gateway HTTP-WEBSOCKET in a Spring Boot Application

In your opinion, in a hybrid architecture (WEBSOCKET + HTTP) is it good practice to use 2 gateways: Zuul for HTTP communication and Spring Cloud Gateway for WEBSOCKET communication in a Spring Boot application? Alternatively, in this scenario is it recommended to use only Spring Cloud Gateway?
Thanks.
is it recommended to use only Spring Cloud Gateway Yes because
Spring Cloud does not provide any out of the box integration with Zuul2. Gateway has many features that are not available in the public version of Zuul2 such as Rate limiting, etc. Also, with the gateway you can have custom filters defined per route and there are tons of built-in filters defined as well, which helps a lot to get started. Reference
Reference: I think SCG is the way to go due to the agreements between Netflix and Pivotal, with the former leaning more toward the spring boot/cloud ecosystem as stated in https://medium.com/netflix-techblog/netflix-oss-and-spring-boot-coming-full-circle-4855947713a0

How to handle hystrix fallback in zuul?

I'm beginer to micro-services, so please help me out on this issue,
I'm working on simple micro service project with spring boot, zuul, hystrix and eureka. One of service calls data from another service. But when the service is down, response is 500, so it needs to be send request again to get the expected result.
But end user shouldn't it see. So is there a way to send a http request for the failed service again with zuul if the previous request is failed/short circuited.
Thanks in advance.
First for an unavailable service http code 503 is probably more suitable.
Then Zuul is an api gateway not a service mesh. I think you mix up both concepts here.
The goal of an api gateway is to accept traffic from outside your network and distributes it internally...and so abstract his complexity(it is actually a distributed facade/router).
Example: zuul, spring cloud gateway
A Service mesh acts as a proxy between microservices and bring on communications aspects like automatic retries, circuit breaker, tracing, logging.
Example Istio, Linkerd
But you can go without service mesh to implement this concern. Your caller microservice can protect itself by implementing timeout, retries and circuit breakers by embed a powerful library like resilience4j.(hystrix is actually at the end of his life)
This library will provide you an api allowing you to wrap communications with outside (other microservices) through a special proxy that will handle retries or/and circuit breakers for you.
You should have a look : https://github.com/resilience4j/resilience4

load balancer and Circuit Breaker

I search to use spring boot, spring-cloud-gateway, netflix eureka.
Is there anything to do to have a load balancer and circuit breaker for micro-service instance?
I found few information ex ribbon when spring gateway is used instead of zuul.
Actually I have an application for the gateway, another for eureka, another for thymeleaf client
security is not yet choose, probabley jwt
With Spring Cloud Gateway, you can currently use the Hystrix Gateway Filter.
Consider using Hystrix. It is extremely good for microservices and aligns well with Spring cloud stack. Also, take a look at Feign, due to its simplistic approach to communication between microservices and integration with hystrix and ribbon.

how to use hystrix to monitoring all microservices

I'm new on microservices and I have seen a tutorial(from udemy) where shows technologies like eureka, feign,spring cloud config,hystrix and zuul, but after make some examples I don't understand very well how hystrix monitor and zuul works, In the examples I noticed that hystrix is used by a main application that it access to microservices and in that way I can monitoring my microservices, but with zuul I noticed that it works like a proxy but this is calling the same microservices like the other application, so my question is how can I monitoring the microservices with hystrix if are called by zuul and by the another application, am I need two hystrix monitor or can I have one general?
Thanks in advance.
After read some examples I noticed that zuul is always the start for applications so I can add hystrix monitor to zuul and call the microservices, but I still have doubt about the circuit breaker in use with zuul so I will keep searching.

Circuit Breaker in a Microservices Architecture

What is the best way to add a Circuit Breaker pattern in a Microservices Architecture. Should it be on the microservice side (inside each microservice), inside an ELB or insider the Api Gateway? What would be the best design pattern?
I think is not use in each microservice, but in your BFF (backend for frontend) who use microservice. You can find a good implementation and exemple in this book https://pragprog.com/book/mnee/release-it. Solution with API Gateway is good, see Kong https://getkong.org/ for that.
There are at least 3 options (illustrated below). In the general case, the circuit breaker "protects" calls to an http service. If we think this service is the microservice, the circuit breaker is never in the microservice itself.
API Gateway
In this case, you use an API gateway product that has circuit breaking support. Ambassador and Axway are examples. An alternative would be to provide circuit breaking in a BFF service that gets the calls to your backend service.
Service mesh
In this case, you use a service mesh product that has support for circuit breaking. Istio with Envoy are an example. In this example, the insurance quote service calls the customer history service. The proxy sidecar container does the circuit breaking.
Circuit breaker lib
Here you use a library that provides circuit breaker support. Resilience4J is the one we use at work (in some Spring Boot apps that call http services).
Your design
Which is best? It depends on your application requirements and infrastructure constraints. Things to remember:
Not all service interactions require circuit breaking.
See if a fallback mechanism (e.g., default response) can be used when the circuit is open.
Log/monitor circuit changes to detect problematic connections and services.
I would suggest you to delegate the circuit breaking concerns to a external library like Hystrix , rather than implementing it yourself.
Hystrix exposes a lot of properties that give you full control in tuning the circuit breaking capabilities.

Resources