Class HelixLatencyAdaptiveGroupRoutingStrategy


public class HelixLatencyAdaptiveGroupRoutingStrategy extends HelixGroupRoutingStrategy
Latency-adaptive Helix group routing strategy for the fast client. Instead of winner-take-all least-loaded selection it does a latency-driven weighted-random draw across groups, sharing the selection math with the router via LatencyAdaptiveGroupSelector.

Latency is populated by HelixGroupRoutingStrategy.trackRequest(com.linkedin.venice.fastclient.RequestContext) (multi-key, non-retry requests). In the size-agnostic mode it comes from the shared HelixGroupStats.getGroupResponseWaitingTimeAvg(int); in the size-aware mode each request's latency is attributed to the key-count bucket it falls into and read back per bucket, so a group that is fast for small batches but slow for large ones is routed accordingly. A group with no datapoint yet (or too few samples in a bucket) is treated as neutral so it is neither flooded nor starved before it has been measured.

  • Constructor Details

    • HelixLatencyAdaptiveGroupRoutingStrategy

      public HelixLatencyAdaptiveGroupRoutingStrategy(InstanceHealthMonitor instanceHealthMonitor, io.tehuti.metrics.MetricsRepository metricsRepository, String storeName, double evenUntilLatencyMs, double fullSkewAtLatencyMs, double skewRampExponent)
    • HelixLatencyAdaptiveGroupRoutingStrategy

      public HelixLatencyAdaptiveGroupRoutingStrategy(InstanceHealthMonitor instanceHealthMonitor, io.tehuti.metrics.MetricsRepository metricsRepository, String storeName, NavigableMap<Integer,Integer> fullSkewMsByLowerBound, double evenUntilFraction, double skewRampExponent, long minSampleCount, IntUnaryOperator retryThresholdMicrosByKeyCount)
      Size-aware construction: latency is tracked and skewed per key-count bucket. When retryThresholdMicrosByKeyCount is non-null each request's full-skew threshold follows it, so routing tracks the effective retry policy; otherwise the per-bucket thresholds apply.
  • Method Details

    • getHelixGroupId

      public int getHelixGroupId(long requestId, int groupIdForOriginalRequest)
      Overrides:
      getHelixGroupId in class HelixGroupRoutingStrategy
    • getHelixGroupId

      public int getHelixGroupId(long requestId, int groupIdForOriginalRequest, int keyCount)
      Pick a group by a latency-adaptive weighted-random draw, excluding groupIdForOriginalRequest so a retry lands on a different group than the one already tried (-1 on the original request excludes nothing). In size-aware mode the draw is skewed by the bucket keyCount falls into.
      Overrides:
      getHelixGroupId in class AbstractClientRoutingStrategy
    • shouldRecordLatency

      protected boolean shouldRecordLatency(RequestContext requestContext, Throwable throwable)
      Only healthy completions feed the signal so a fast failure does not make a group look fast. Partial-success (streaming) requests complete normally even when routes failed, so those are excluded too. Retried requests are skipped because part of the response may have come from a different group than the one selected.
      Overrides:
      shouldRecordLatency in class HelixGroupRoutingStrategy
    • recordLatencySample

      protected void recordLatencySample(int groupId, int keyCount, double latency)
      Description copied from class: HelixGroupRoutingStrategy
      Records a group's measured latency. The base strategy feeds the shared response-waiting-time metric (also consumed by least-loaded routing); the latency-adaptive strategy overrides this to record into its dedicated per-(group, bucket) routing metric when it is configured size-aware.
      Overrides:
      recordLatencySample in class HelixGroupRoutingStrategy