Kafka MirrorMaker's consumer not fetching all messages from topics
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Apache Kafka is a complex distributed system designed for high throughput and scalability, which includes tools like MirrorMaker for replicating topics between Kafka clusters. However, sometimes MirrorMaker consumers might not fetch all messages from the source topics, leading to various operational challenges. This often manifests as data inconsistency or data loss between the source and target clusters.
Understanding Kafka MirrorMaker
MirrorMaker works by using consumer instances to fetch data from a source Kafka cluster and then producing it to a target Kafka cluster. These operations are pivotal in scenarios like geo-replication, disaster recovery, and aggregated data streaming across different locations or data centers.
Common Causes for Fetching Issues
- Consumer Configuration: If consumers are not properly configured, they might not be able to fetch all messages.
- Cluster Overload: High load on the Kafka cluster can lead to delays or failures in message delivery.
- Network Issues: Latency or instability in the network between the source and target clusters can cause losses in data transmission.
- Topic Configuration Mismatch: Differences in topic configurations (like retention policies or number of partitions) between clusters can lead to inconsistent replication.
- Offset Management: Incorrect handling or committing of offsets can result in missing messages during the replication process.
Technical Explanations and Solutions
Consumer Configuration
Kafka consumers need correct settings to ensure all messages are fetched. Key configurations include:
group.id: Ensures the consumer is part of a specific group to maintain load balance.auto.offset.reset: Controls the behavior when no initial offset is found or if the current offset does not exist anymore.max.poll.records: Adjusts the number of records the consumer can fetch in a single poll request.
A suboptimal setting in these configurations can lead the consumer to skip messages. Ensure these are aligned with the expected volume and characteristics of the data.
Handling Network Issues
Network problems can be mitigated by:
- Improving network infrastructure between the source and target Kafka clusters.
- Using Kafka’s built-in retries by configuring
retriesandretry.backoff.msto manage temporary network failures gracefully.
Correct Topic Configuration
Ensure that topic configurations (like partition, replication.factor, and retention.ms) are consistent across both the source and target clusters to avoid any data inconsistency. These can be adjusted using Kafka's topic management tools or administrative scripts.
Efficient Offset Management
Managing consumer offsets is critical. Ensure that the MirrorMaker setup commits offsets properly by configuring enable.auto.commit and setting appropriate auto.commit.interval.ms. Mismanagement here can lead to reprocessing of messages or losing track of which messages have been successfully replicated.
Troubleshooting and Monitoring
Implement comprehensive logging and monitoring to detect issues early. Tools like Kafka’s JMX metrics, alongside external monitoring tools like Prometheus or Datadog, can provide insights into system health and operation.
Summary Table
| Issue Category | Common Causes | Suggested Fixes |
| Consumer Configuration | Incorrect group.id, auto.offset.reset, max.poll.records settings | Verify and align consumer configurations |
| Cluster Overload | High traffic, inadequate resources | Scale resources, optimize performance settings |
| Network Issues | Latency, instability | Improve infrastructure, configure retries |
| Topic Configuration Mismatch | Inconsistent settings | Align topic configurations across clusters |
| Offset Management | Poor offset handling | Properly configure offset management settings |
Additional Considerations
- Version Compatibility: Ensure that both source and target clusters, along with the MirrorMaker version, are compatible.
- Consumer Group Monitoring: Regularly check the lags and health of consumer groups involved in the replication to preemptively tackle potential fetching issues.
By understanding and meticulously managing each component of the Kafka ecosystem involved in the replication process, including MirrorMaker's consumers, you can significantly mitigate issues related to not fetching all messages.
Related reading
- kafka Missing required configuration zookeeper.connect which has no default value
- Kafka Monitoring JMX Attributes Count or MeanRate?
- kafka Multi-Datacenter with high availability
- Kafka Multi Node setup Unreasonable length in Zookeeper logs
- kafka new producer is not able to update metadata after one of the broker is down
- Kafka No message seen on console consumer after message sent by Java Producer
- Kafka multiple consumers for a partition
- Kafka multiple partition ordering

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.