ARTICLE AD BOX
I am looking for best practices on how to implement horizontal architecture with the latest Spring gRPC [1] in Kubernetes.
In my Kubernetes cluster, I have one main service, which connects to multiple so-called worker services via gRPC and a load-balancer. However, when executing a simple for-loop to send requests to the workers, only a single one of those receives the requests.
I am asking speficially, because to my understanding, a gRPC channel might contain multiple connections (sub-channels), but our Kubernetes cluster distributes requests to other pods according to channels, not simply connections (sub-channels) therein, i.e., L4 balancing, confer gRPC Load Balancing.
Thus, do I need to setup a pool of gRPC channels [2] manually, as described in a very recent article here: Connection Pool Implementation in Java?
Or can I simply switch to another library, as described in this article Choosing the right grpc library for Spring Boot?
Thanks for any advice in advance.
Edit
According to this Answer, something like this might work. Although than I have the same question: How to configure the pool size?
@Configuration public class GrpcClientFactory { @Bean FooGrpc.FooBlockingStub fooBlockingStub() { var channel = ManagedChannelBuilder.forAddress("<address>", 9090) .executor(Executors.newCachedThreadPool()) .usePlaintext() .build(); return FooGrpc.newBlockingStub(channel); } }[1] spring-grpc
[2] gRPC Guides Performance
