Skip to content

Commit

Permalink
Add overall consumer poll rate.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hao Xu committed Feb 7, 2025
1 parent 010a17c commit 3065958
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.linkedin.venice.utils.RedundantExceptionFilter;
import com.linkedin.venice.utils.Utils;
import com.linkedin.venice.utils.concurrent.VeniceConcurrentHashMap;
import com.linkedin.venice.utils.lazy.Lazy;
import io.tehuti.metrics.MetricConfig;
import io.tehuti.metrics.stats.Rate;
import java.util.HashMap;
Expand Down Expand Up @@ -66,6 +67,8 @@ class ConsumptionTask implements Runnable {
private final Map<PubSubTopicPartition, Rate> messageRatePerTopicPartition = new VeniceConcurrentHashMap<>();
private final Map<PubSubTopicPartition, Rate> bytesRatePerTopicPartition = new VeniceConcurrentHashMap<>();
private final Map<PubSubTopicPartition, Rate> pollRatePerTopicPartition = new VeniceConcurrentHashMap<>();

private final Lazy<Rate> overallConsumerPollRate;
private final RedundantExceptionFilter redundantExceptionFilter;
private final Map<PubSubTopicPartition, Long> lastSuccessfulPollTimestampPerTopicPartition =
new VeniceConcurrentHashMap<>();
Expand Down Expand Up @@ -105,6 +108,7 @@ public ConsumptionTask(
this.taskId = taskId;
this.offsetLagGetter = offsetLagGetter;
this.redundantExceptionFilter = redundantExceptionFilter;
this.overallConsumerPollRate = Lazy.of(() -> createRate(System.currentTimeMillis()));
this.consumptionTaskIdStr = Utils.getSanitizedStringForLogger(consumerNamePrefix) + " - " + taskId;
this.LOGGER = LogManager.getLogger(getClass().getSimpleName() + "[ " + consumptionTaskIdStr + " ]");
}
Expand Down Expand Up @@ -196,6 +200,7 @@ public void run() {
consumedDataReceiver.write(topicPartitionMessages);
checkSlowPartitionWithHighLag(pubSubTopicPartition);
}
overallConsumerPollRate.get().record(1, lastSuccessfulPollTimestamp);
aggStats.recordTotalConsumerRecordsProducingToWriterBufferLatency(
LatencyUtils.getElapsedTimeFromMsToMs(beforeProducingToWriteBufferTimestamp));
aggStats.recordTotalNonZeroPollResultNum(polledPubSubMessagesCount);
Expand Down Expand Up @@ -302,15 +307,17 @@ private void checkSlowPartitionWithHighLag(PubSubTopicPartition pubSubTopicParti
Long offsetLag = offsetLagGetter.apply(pubSubTopicPartition);
Double messageRate = getMessageRate(pubSubTopicPartition);
Double pollRate = getPollRate(pubSubTopicPartition);
Double consumerPollRate = overallConsumerPollRate.get().measure(metricConfig, System.currentTimeMillis());
String slowTaskWithPartitionStr = consumptionTaskIdStr + " - " + pubSubTopicPartition;
if (offsetLag > 200000 && messageRate < 200
&& !redundantExceptionFilter.isRedundantException(slowTaskWithPartitionStr)) {
LOGGER.warn(
"Slow partition with high lag detected: {}. Lag: {}, Message Rate: {}, Poll Rate: {}",
"Slow partition with high lag detected: {}. Lag: {}, Message Rate: {}, Poll Rate: {},Consumer Poll Rate: {}",
pubSubTopicPartition,
offsetLag,
messageRate,
pollRate);
pollRate,
consumerPollRate);
}
}

Expand Down

0 comments on commit 3065958

Please sign in to comment.