hi Team,
We are currently building a service that uses grpc as transport protocol.
As part of it we are planning to have a circuit breaker for grpc client
we would like to know if there are any recommendations around building/using circuit breaker library/framework that can be consumed by grpc client?
Hi, if you're open to using an alternative Java client, Armeria supports circuit breakers with grpc. See https://armeria.dev/docs/client-circuit-breaker for an example.
I believe it can also be used in a framework agnostic way, but we use the Armeria client directly.
A circuit breaker in gRPC would just be a client interceptor (and potentially a server interceptor, depending on how the breaking is designed).
I think there are various implementations scattered about. https://github.com/alibaba/Sentinel looks like it has one with interceptors, just as an example.
Can Hystrix/Resilience4j be integrated with grpc client for circuit breaker capabilities?
I don't think we have the expertise to really answer your question. But just taking a cursory glance does provide the "flavor" of what the solutions may look like.
A quick look at Hystrix makes it seem like it is applied "on top" of an API: "Wrapping all calls to external systems (or “dependencies”) in a HystrixCommand." So it would work for anything. But you are calling Hystrix directly at each callsite.
A quick Google search for Resilience4j make it look fairly trivial to integrate as an interceptor: https://gist.github.com/eungju/226274b3dacb3203de3514bcf1c54505
Seems this is answered as best as we can, so closing.
Most helpful comment
Hi, if you're open to using an alternative Java client, Armeria supports circuit breakers with grpc. See https://armeria.dev/docs/client-circuit-breaker for an example.
I believe it can also be used in a framework agnostic way, but we use the Armeria client directly.