Class HelixGroupLatencyAdaptiveStrategy
- All Implemented Interfaces:
HelixGroupSelectionStrategy
HelixGroupLeastLoadedStrategy. The share/skew math is shared
with the fast client in LatencyAdaptiveGroupSelector; this class only adds the router's
HelixGroupSelectionStrategy plumbing on top.
HelixGroupLeastLoadedStrategy first picks the group(s) with the fewest in-flight requests, then breaks
ties by lowest latency. At low per-router in-flight the counters are almost always tied at ~0, so the tie-break fires
on nearly every request and over-concentrates traffic on whichever group is momentarily fastest. This strategy keeps
latency as the signal for which group is fast but turns it into a per-group target share and a weighted-random draw,
routing evenly while the groups are close and shedding traffic off a group only as its latency pulls ahead. See
LatencyAdaptiveGroupSelector for the formula and knobs.
The counter-leak protection via TimeoutProcessor and the synchronized in-flight accounting are preserved
from HelixGroupLeastLoadedStrategy; the counters are kept for leak protection and observability
(HelixGroupStats.recordGroupPendingRequest(int, int)) and do not influence the target share.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doublestatic final doublestatic final doublestatic final doublestatic final longstatic final intstatic final doublestatic final double -
Constructor Summary
ConstructorsConstructorDescriptionHelixGroupLatencyAdaptiveStrategy(TimeoutProcessor timeoutProcessor, long timeoutInMS, HelixGroupStats helixGroupStats) HelixGroupLatencyAdaptiveStrategy(TimeoutProcessor timeoutProcessor, long timeoutInMS, HelixGroupStats helixGroupStats, IntToDoubleFunction latencyProvider, double evenUntilLatencyMs, double fullSkewAtLatencyMs, double interpolationExponent, DoubleSupplier randomSupplier) Knobs and latency source are forwarded toLatencyAdaptiveGroupSelector; see it for their meaning and the validated invariants (0 <= evenUntilLatencyMs < fullSkewAtLatencyMs,interpolationExponent > 0).HelixGroupLatencyAdaptiveStrategy(TimeoutProcessor timeoutProcessor, long timeoutInMS, HelixGroupStats helixGroupStats, NavigableMap<Integer, Integer> fullSkewMsByLowerBound, double evenUntilFraction, double interpolationExponent, long minSampleCount, DoubleSupplier randomSupplier) Size-aware (bucketed) construction: latency is tracked and skewed per key-count bucket, reading and recording the dedicated per-(group, bucket) routing metric so a group that is fast for small batches but slow for large ones is routed accordingly. -
Method Summary
Modifier and TypeMethodDescriptionvoidfinishRequest(long requestId, int groupId, double latency) Notify the corresponding Helix Group that the request is completed, and the implementation will decide whether any cleanup is required or not.voidfinishRequest(long requestId, int groupId, int keyCount, double latency) Size-aware request completion: records the latency under the request'skeyCountso a size-aware strategy can attribute it to the matching bucket.voidfinishRequest(long requestId, int groupId, int keyCount, double latency, boolean success) Success-aware request completion:successisfalsewhen the request failed (error or throttled) response, letting a latency-adaptive strategy keep the latency sample out of its routing signal so a fast-failing group is not mistaken for a fast-serving one.intselectGroup(long requestId, int groupCount) Select a Helix Group for the current request.intselectGroup(long requestId, int groupCount, int keyCount) Size-aware group selection:keyCountis the number of keys in the request, letting a strategy route by request size.
-
Field Details
-
MAX_ALLOWED_GROUP
public static final int MAX_ALLOWED_GROUP- See Also:
-
DEFAULT_EVEN_UNTIL_LATENCY_MS
public static final double DEFAULT_EVEN_UNTIL_LATENCY_MS -
DEFAULT_FULL_SKEW_AT_LATENCY_MS
public static final double DEFAULT_FULL_SKEW_AT_LATENCY_MS -
DEFAULT_INTERPOLATION_EXPONENT
public static final double DEFAULT_INTERPOLATION_EXPONENT -
DEFAULT_EVEN_UNTIL_FRACTION
public static final double DEFAULT_EVEN_UNTIL_FRACTION -
DEFAULT_MIN_SAMPLE_COUNT
public static final long DEFAULT_MIN_SAMPLE_COUNT -
MIN_LATENCY_MS
public static final double MIN_LATENCY_MS -
PROBE_FLOOR_FRACTION
public static final double PROBE_FLOOR_FRACTION
-
-
Constructor Details
-
HelixGroupLatencyAdaptiveStrategy
public HelixGroupLatencyAdaptiveStrategy(TimeoutProcessor timeoutProcessor, long timeoutInMS, HelixGroupStats helixGroupStats) -
HelixGroupLatencyAdaptiveStrategy
public HelixGroupLatencyAdaptiveStrategy(TimeoutProcessor timeoutProcessor, long timeoutInMS, HelixGroupStats helixGroupStats, IntToDoubleFunction latencyProvider, double evenUntilLatencyMs, double fullSkewAtLatencyMs, double interpolationExponent, DoubleSupplier randomSupplier) Knobs and latency source are forwarded toLatencyAdaptiveGroupSelector; see it for their meaning and the validated invariants (0 <= evenUntilLatencyMs < fullSkewAtLatencyMs,interpolationExponent > 0).
-
-
Method Details
-
selectGroup
public int selectGroup(long requestId, int groupCount) Description copied from interface:HelixGroupSelectionStrategySelect a Helix Group for the current request.- Specified by:
selectGroupin interfaceHelixGroupSelectionStrategy
-
selectGroup
public int selectGroup(long requestId, int groupCount, int keyCount) Description copied from interface:HelixGroupSelectionStrategySize-aware group selection:keyCountis the number of keys in the request, letting a strategy route by request size. Defaults to the size-agnosticHelixGroupSelectionStrategy.selectGroup(long, int)so strategies that do not care about request size (round-robin, least-loaded) need no change.- Specified by:
selectGroupin interfaceHelixGroupSelectionStrategy
-
finishRequest
public void finishRequest(long requestId, int groupId, double latency) Description copied from interface:HelixGroupSelectionStrategyNotify the corresponding Helix Group that the request is completed, and the implementation will decide whether any cleanup is required or not.- Specified by:
finishRequestin interfaceHelixGroupSelectionStrategy
-
finishRequest
public void finishRequest(long requestId, int groupId, int keyCount, double latency) Description copied from interface:HelixGroupSelectionStrategySize-aware request completion: records the latency under the request'skeyCountso a size-aware strategy can attribute it to the matching bucket. Defaults to the size-agnosticHelixGroupSelectionStrategy.finishRequest(long, int, double).- Specified by:
finishRequestin interfaceHelixGroupSelectionStrategy
-
finishRequest
public void finishRequest(long requestId, int groupId, int keyCount, double latency, boolean success) Description copied from interface:HelixGroupSelectionStrategySuccess-aware request completion:successisfalsewhen the request failed (error or throttled) response, letting a latency-adaptive strategy keep the latency sample out of its routing signal so a fast-failing group is not mistaken for a fast-serving one. Group bookkeeping still happens regardless. Defaults to the success-agnosticHelixGroupSelectionStrategy.finishRequest(long, int, int, double).- Specified by:
finishRequestin interfaceHelixGroupSelectionStrategy
-