What Kafka broker metrics should be monitored if producer side ack lag is very high
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
When monitoring Apache Kafka, especially in the context of experiencing high acknowledgment (ack) lag on the producer side, it is critical to keep an eye on several broker metrics that can help identify bottlenecks or inefficiencies in message processing. Ack lag typically refers to the delay between when a producer sends a message and when it receives an acknowledgment from the broker that the message has been committed. A high ack lag can significantly affect the throughput and performance of your Kafka producer.
Key Kafka Broker Metrics to Monitor
1. Broker-Level Byte Rate Metrics
Monitoring the byte rate at which messages are sent and received by the broker gives a clear idea of the throughput capability of your Kafka setup. There are two primary metrics to look at:
- Bytes In Per Second: This reflects the total bytes received by the broker per second.
- Bytes Out Per Second: This indicates the total bytes sent by the broker per second.
If these metrics are abnormally low or show sudden drops, it might indicate network issues, broker performance problems, or backpressure from slow consumers which can, in turn, affect producer ack times.
2. Request Metrics
High producer ack lag might be due to delays in request handling by brokers. Key metrics include:
- Request Queue Time: The average time requests spend waiting in the request queue before being processed. A longer queue time can indicate broker overload.
- Request Latency: Measures the time taken to handle requests. High latency can indicate processing delays which contribute to ack lag.
3. Replication Metrics
Since Kafka's durability guarantees are often enforced through replication, monitoring replication metrics is vital:
- Replication Lag: The delay between a message being committed in the leader partition and its replication to the followers. High replication lag can delay acks when
acks=allis used by the producer. - Under Replicated Partitions: The count of partitions where the number of replicas holding the partition's data is less than the configured replication factor.
4. Log Flush Metrics
Kafka writes data to logs before it is committed. The log flush rate can impact ack timing:
- Log Flush Rate and Time: How often and how quickly the logs are flushed. Delays in flushing can increase ack lag, especially when durability is prioritized.
5. Consumer Lag
While primarily a consumer-side metric, consumer lag (the delay between what has been produced and what has been consumed) can inform about overall system health which indirectly impacts producer performances.
Practical Steps for Monitoring
Setting up effective monitoring involves configuring your Kafka system to periodically fetch and store these metrics, using tools such as JMX Exporter, Prometheus, and Grafana for visualization. Setting alerts for anomalies in these metrics can help in proactively managing and mitigating issues before they critically impact the system.
Summary Table of Metrics
| Metric Name | Description | Relevance to Producer Ack Lag |
| Bytes In Bytes Out | Data rate metrics for the broker | Directly correlated |
| Request Queue Time Request Latency | Time metrics for request processing | High values increase ack lag |
| Replication Lag | Measures delay in replicating to follower brokers | High values increase ack lag |
| Under Replicated Partitions | Number of under-replicated partitions | Can cause delays and failures |
| Log Flush Rate Log Flush Time | Frequency and duration of log flushes | Delays can increase ack lag |
Conclusion
Monitoring Kafka at the broker level for the above metrics provides a holistic view of the system's performance, particularly in addressing high producer ack lag. It’s crucial to assess not just individual metrics but their interactions and the broader system context to diagnose and optimize Kafka deployments effectively. Keeping these metrics within optimal thresholds ensures that Kafka can handle high throughput and maintain low latency communications, which are critical for real-time data processing systems.

