I have set up a Kafka scenario, including three servers: one with a Kafka producer, one with a Kafka server, and one with a consumer application.
Now, I need to measure the average end-to-end latency of Kafka messages from the producer to the consumer, including the latency of each part. My partition replication factor is 1, so there are no followers.
Based on the official documentation, I believe the composition of end-to-end latency and corresponding JMX metrics are as follows:
- Network transmission time from the producer to the Kafka server (unknown).
- Time spent waiting in the request queue on the Kafka server (
kafka.network:type=RequestMetrics,name=RequestQueueTimeMs
). - Leader processing time on the Kafka server (
kafka.network:type=RequestMetrics,name=LocalTimeMs,request=Produce
). - Time spent waiting to be fetched within the Kafka server (unknown).
- Network transmission time from the Kafka server to the consumer (
fetch-latency-avg
for consumers -kafka.network:type=RequestMetrics,name=TotalTimeMs,request=FetchConsumer
, divided by 2). - Actual consumption time by the consumer (measured by the application).
The overall latency (1-6) can be obtained by calculating timestamps.
Is my understanding correct? Are there any methods to measure the latencies of parts 1 and 4?