I am receiving data at a regular interval, say every second, and I have different consumers for different data. How do you define consumers that will pick only 10 records from each broker for each topic?
💡 Model Answer
In Kafka, the consumer controls how many records it pulls from the broker in each poll via the max.poll.records configuration. Setting max.poll.records=10 ensures that each poll returns at most 10 records. If you need to enforce that each consumer instance only processes 10 records per second, you can combine this with a rate limiter or a scheduled poll loop that sleeps for the remainder of the second. Additionally, you can use multiple consumer instances in the same group to parallelize consumption across partitions. Each consumer will automatically be assigned a subset of partitions, so you can isolate data by topic or partition. Remember to commit offsets after processing to avoid re‑processing. This approach gives you fine‑grained control over the number of messages consumed per broker and per topic.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.
Get Assisting AI — Starts at ₹500