Enum Class GcpManagedChannelOptions.ChannelPickStrategy

java.lang.Object
java.lang.Enum<GcpManagedChannelOptions.ChannelPickStrategy>
com.google.cloud.grpc.GcpManagedChannelOptions.ChannelPickStrategy
All Implemented Interfaces:
Serializable, Comparable<GcpManagedChannelOptions.ChannelPickStrategy>, Constable
Enclosing class:
GcpManagedChannelOptions

public static enum GcpManagedChannelOptions.ChannelPickStrategy extends Enum<GcpManagedChannelOptions.ChannelPickStrategy>
Strategy for picking the least busy channel from the pool.

This controls how a channel is selected when there is no affinity key or when a new affinity binding is being established.

  • Enum Constant Details

    • LINEAR_SCAN

      public static final GcpManagedChannelOptions.ChannelPickStrategy LINEAR_SCAN
      Scans all channels and picks the one with the fewest active streams. Ties are broken by iteration order (lowest index wins). This is the legacy behavior.

      This strategy finds the global minimum but is susceptible to the thundering herd problem: under burst traffic, all concurrent callers observe the same minimum and pile onto the same channel.

    • POWER_OF_TWO

      public static final GcpManagedChannelOptions.ChannelPickStrategy POWER_OF_TWO
      Picks two channels at random and returns the one with fewer active streams. Ties are broken by preferring the more recently active channel (warmth-preserving).

      This is the default strategy. It avoids the thundering herd problem while keeping warm channels preferred under low traffic. The trade-off is that it may not always find the global minimum, but in practice the difference is negligible because stream counts are inherently racy.

  • Method Details

    • values

      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null