Poll Interval for Kafka Connect SourceTask
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Apache Kafka Connect is a component of Apache Kafka that streamlines integrating external systems with Kafka. It provides a framework for connecting Kafka with external systems like databases, key-value stores, search indexes, and file systems. Using Kafka Connect, you can ingest entire databases into Kafka topics and make all your data systems easily accessible through the Kafka ecosystem.
One of the fundamental concepts within Kafka Connect is the SourceTask, which is responsible for polling data from a source system and pushing it into Kafka. Understanding the poll interval in Kafka Connect SourceTasks is crucial for optimizing the performance and efficiency of data ingestion.
What is the Poll Interval?
In Kafka Connect, the poll interval is the frequency at which the SourceTask queries or checks its source system for new data. This interval is crucial because it balances the load on the source system and the timeliness of the data in Kafka. If the interval is too short, it could overwhelm the source system or lead to excessive CPU usage and network traffic. Conversely, if too long, it may cause delays in data availability in Kafka, affecting downstream applications.
Configuring the Poll Interval
The poll interval in Kafka Connect SourceTasks is set using the poll.interval.ms configuration. This setting specifies the minimum amount of time (in milliseconds) the SourceTask should wait between polls. The configuration is set in the Kafka Connect properties file or passed as parameters when starting a connector.
For example, setting a poll interval of 5000 milliseconds could be configured as follows in a connector’s configuration:
In this example, the SourceTask associated with the inventory-connector will check for new changes from the MySQL database every 5000 milliseconds (or 5 seconds).
Impact of Poll Interval Settings
The setting of the poll.interval.ms impacts several aspects of a Kafka Connect deployment:
- Source System Load: More frequent polling can increase the load on the source system, potentially affecting its performance.
- Data Freshness: A shorter poll interval means that data changes in the source system are captured more quickly and propagated to Kafka topics, improving the freshness of the data.
- Resource Usage: More frequent polling can lead to higher CPU and memory usage on the Kafka Connect nodes, as they need to handle more frequent data checks and transfers.
Best Practices for Setting Poll Interval
- Understand the Source System: Know the capabilities and limits of your source system. Some systems may handle frequent polls without issues, while others may need more breathing room.
- Evaluate Data Requirements: Determine how critical real-time data is for your application. If data needs to be as fresh as possible, consider a lower poll interval.
- Monitor Performance: Always monitor the source and Kafka Connect system performance as you adjust the poll interval. Use monitoring tools to watch for increased load or slowdowns.
Poll Interval Considerations in Different Scenarios
The optimal setting for poll.interval.ms can vary based on specific use cases and source system behavior. Here’s how different scenarios might influence the poll interval decision:
- High-Transaction Databases: For a database with high transaction volumes, you might opt for a lower poll interval to ensure timely data updates and reduce the peak load on data querying.
- Batch Updates: If the source system receives data in batches (e.g., hourly updates from a batch job), setting the poll interval slightly below the batch update interval could be effective.
Summary Table
| Consideration | Impact on Source System | Impact on Data Freshness | Recommended Action |
| High transaction volume | High | High | Lower poll.interval.ms |
| Lower transaction volume | Lower | Low | Increase poll.interval.ms |
| Critical real-time data | High | Critical | Lower poll.interval.ms |
| Non-critical batch updates | Moderate | Moderate | Match poll.interval.ms to batch update cycle |
Conclusion
Setting the correct poll interval for a Kafka Connect SourceTask is a balance between system performance and data availability. By carefully considering the characteristics of your source system and the needs of your data consumers, you can optimize this setting to ensure efficient and timely data ingestion into your Kafka ecosystem. Monitoring and adjusting based on performance metrics are key to finding the right configuration for your environment.
Related reading
- Poor performance of log4j2 in combination with Kafka
- Poor performance with Spark streaming, Kafka and multiple topics
- Porting Kafka's murmur2 implementation to Go
- PRECONDITION_FAILED Delivery Acknowledge Timeout on Celery & RabbitMQ with Gevent and concurrency
- Prevent Kafka broker from closing idle connection
- Prevent kafka consumer from timing out for long process
- Print Kafka Stream Input out to console?
- problem path for truststore inside docker with spring boot and kafka

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.