gRPC Java 1.44.0 switches default load‑balancing policy from pick_first to round_robin
0 reputation · 21 Apr 2023, 11:11 UTC
0 reputation · 21 Apr 2023, 11:11 UTC
The goal is to keep a local developer setup repeatable so that a gRPC Java client always connects to the same backend instance during debugging and testing.
Starting with version 1.44.0 the library changed the channel‑level default from pick_first to round_robin unless an explicit policy is supplied. This alters the connection‑establishment pattern seen against a static list of local server ports and may affect latency observations or fail‑over behavior in environments that previously relied on the pick_first semantics.
What approach should be taken to preserve the original pick_first behavior in a repeatable development environment? Should the gRPC‑Java version be pinned to a pre‑1.44.0 release, or is it preferable to explicitly set the load‑balancing policy via channel arguments or a service config? How does this decision impact consistency across CI pipelines and local workstations?
30275 reputation · 21 Apr 2023, 21:10 UTC
Do not pin gRPC-Java to a pre-1.44.0 release. Pinning forgoes security and bug fixes and creates dependency drift with protobuf and Netty. Make the policy explicit in your channel construction and share that construction code across local workstations and CI.
For a repeatable local debug setup the robust approach is:
ManagedChannelBuilder.forAddress(...).defaultLoadBalancingPolicy("pick_first")That gives deterministic behavior independent of library defaults and avoids version pinning.
ManagedChannelBuilder.defaultLoadBalancingPolicy(String) to override the channel-level default.defaultServiceConfig or by a name resolver can set loadBalancingConfig. That service config overrides the builder default.The claim that gRPC-Java 1.44.0 changed the channel-level default from pick_first to round_robin could not be confirmed from available knowledge. The documented channel-level default has long been pick_first, and the 1.44.0 change is treated as unverified until checked against the official 1.44.0 release notes and LoadBalancer documentation. Behavior may also differ by resolver type.
defaultLoadBalancingPolicy("pick_first") documents intent in code and survives library upgrades.Service config is an alternative, but it is more verbose for a local dev case. If you already use a shared service config, set loadBalancingConfig to pick_first there instead of relying on builder defaults.
One diagnostic detail that changes the recommendation: are you using a name resolver such as DNS or xDS that provides a service config for the target? If yes, the service config can override defaultLoadBalancingPolicy, and the policy must be set in the service config rather than only on the builder.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.