Circuit breaker for gRPC java client

2,015 views
Skip to first unread message

lpamb...@gmail.com

unread,
Jun 20, 2016, 5:36:53 AM6/20/16
to grpc.io
Hi,

Is there any in-build feature in gRPC java client to handle circuit breaking ? 

Best Regards,
Pamb

Carl Mastrangelo

unread,
Jun 22, 2016, 12:39:46 PM6/22/16
to grpc.io
Not currently, assuming you are talking about running out of memory.  Our servers/ services tend to have hard memory limits that are preallocated on start up and are never broken.  If a server is running out of memory, the solution is to just spin up more servers.  

That said, grpc Java tries to avoid memory allocation and usage, so the overhead for the library is pretty small.  You can implement your own marshaller using SoftReferences if you would like.  There is an advanced example showing how to write your own marshaller here.  Be warned that this is pretty advanced and you shouldn't use it until you really need to.  

Lasantha

unread,
Jun 30, 2016, 6:34:24 AM6/30/16
to grpc.io
Hello Carl,

Thanks for the reply. 

Actually I was looking for some thing like https://github.com/Netflix/Hystrix. However Hystrix is specific to Java and it does not support streaming APIs. I want to know whether there is any inbuilt mechanism in gRPC to handle this irrespective of the language of the client stubs. 

Example
-------------

Lets say I have two mircro-services deployed separately. TaxService (Go) and PricingService (Java), which PricingService depends on TaxService.

service PricingService {
rpc getPrice (PricingRequest) returns (PricingResponse) {}
}

message PricingRequest {
    string productId = 1;
}

message PricingResponse {
double price = 1;
double tax = 2;
}

I will call TaxService to get the tax amount when calculating the price. However if  TaxService is not available I want a fallback mechanism in the client side (ie within PricingService implementation). Basically I should be able to set something like a fallback handler in the TaxServiceClient stub for the getTax method.

If there are too much fallbacks happening then client will automatically break the circuit between PricingService and TaxService for some time to prevent escalating failures.

Best Regards
Pamb

jfuen...@gmail.com

unread,
Jun 10, 2017, 9:09:19 AM6/10/17
to grpc.io
Hi Pamb, 

Any update about this? I'm looking in the same direction.

Cheers, 
Jorge

Derek Perez

unread,
Jun 10, 2017, 12:10:01 PM6/10/17
to jfuen...@gmail.com, grpc.io
this is also interesting to me.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/8da02fa3-a528-4712-baed-891e6857e57b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

saada...@gmail.com

unread,
Jun 10, 2020, 6:47:42 PM6/10/20
to grpc.io
Hi Pamb,

Do we have any update on this? 
Reply all
Reply to author
Forward
0 new messages