N
Velvet Digest

What is poll in Kafka?

Author

Eleanor Gray

Updated on May 04, 2026

Kafka Consumer Poll method The poll method returns fetched records based on current partition offset. The poll method is a blocking method waiting for specified time in seconds. If no records are available after the time period specified, the poll method returns an empty ConsumerRecords.

.

Hereof, what is poll in Kafka consumer?

A consumer requests messages from Kafka by calling Consumer. poll() regularly. The consumer calls poll() , receives a batch of messages, processes them promptly, and then calls poll() again. When a consumer processes a message, the message is not removed from its topic.

Additionally, is Kafka consumer thread safe? The Kafka consumer is NOT thread-safe. All network I/O happens in the thread of the application making the call. It is the responsibility of the user to ensure that multi-threaded access is properly synchronized. Un-synchronized access will result in ConcurrentModificationException .

Keeping this in view, is Kafka pull or push?

With Kafka consumers pull data from brokers. Other systems brokers push data or stream data to consumers. Messaging is usually a pull-based system (SQS, most MOM use pull). A pull-based system has to pull data and then process it, and there is always a pause between the pull and getting the data.

What is Max Poll records in Kafka?

Kafka consumer has a configuration max. poll. records which controls the maximum number of records returned in a single call to poll() and its default value is 500.

Related Question Answers

How do you scale Kafka consumers?

There are 2 things you can scale up: Kafka, or the consumers. If your producers produce more messages on one topic, you might want to multiply the number of consumers so they can cover more work at the same time, you're going to scale horizontally.

How does Kafka work?

Distributed. A distributed system is one which is split into multiple running machines, all of which work together in a cluster to appear as one single node to the end user. Kafka is distributed in the sense that it stores, receives and sends messages on different nodes (called brokers).

Does Kafka write to disk?

1 Answer. Kafka always writes directly to disk, but remember one thing the I/O operations are really carried out by the Operating System. In case of Linux it seems the data is written to the page cache until it can be written to the disk.

How does Kafka offset work?

The offset is a simple integer number that is used by Kafka to maintain the current position of a consumer. That's it. The current offset is a pointer to the last record that Kafka has already sent to a consumer in the most recent poll. So, the consumer doesn't get the same record twice because of the current offset.

How do I get data from Kafka?

Quickstart
  1. Step 1: Download the code. Download the 2.4.
  2. Step 2: Start the server.
  3. Step 3: Create a topic.
  4. Step 4: Send some messages.
  5. Step 5: Start a consumer.
  6. Step 6: Setting up a multi-broker cluster.
  7. Step 7: Use Kafka Connect to import/export data.
  8. Step 8: Use Kafka Streams to process data.

How consumer group works in Kafka?

Kafka consumers belonging to the same consumer group share a group id. The consumers in a group then divides the topic partitions as fairly amongst themselves as possible by establishing that each partition is only consumed by a single consumer from the group. The messages are broadcast to all consumer groups.

What is Kafka technology?

kafka.apache.org. Apache Kafka is an open-source stream-processing software platform developed by LinkedIn and donated to the Apache Software Foundation, written in Scala and Java. The project aims to provide a unified, high-throughput, low-latency platform for handling real-time data feeds.

What is bootstrap server in Kafka?

Bootstrap Servers are a list of host/port pairs to use for establishing the initial connection to the Kafka cluster. These servers are just used for the initial connection to discover the full cluster membership.

Why is Kafka so fast?

Although this approach makes them fast, the cost of RAM is much more than disk. Such systems are usually costlier to run when you have 100s of GBPS data flowing through the system. Kafka relies on the filesystem for the storage and caching. Modern operating systems allocate most of their free memory to disk-caching.

Does Kafka support queues?

Using Kafka as a message queue. Apache Kafka is a very popular publish/subscribe system, which can be used to reliably process a stream of data. The central concept in Kafka is a topic, which can be replicated across a cluster providing safe data storage. It is not possible to acknowledge individual messages.

Should I use Kafka or RabbitMQ?

RabbitMQ is a general purpose message broker that supports protocols including, MQTT, AMQP, and STOMP. Kafka is a durable message broker that enables applications to process, persist and re-process streamed data. Kafka has a straightforward routing approach that uses a routing key to send messages to a topic.

Can Kafka pull data?

Kafka itself doesn't pull any data. It is a data persistence store.

Can one Kafka consumer subscribe to multiple topics?

There is no need for multiple threads, you can have one consumer, consuming from multiple topics. Offsets are maintained by zookeeper, as kafka-server itself is stateless. So even in case of kafka failure, consumer will start consuming from the next of last commited offset.

What is ZooKeeper in Kafka?

Kafka Architecture: Topics, Producers and Consumers Kafka uses ZooKeeper to manage the cluster. ZooKeeper is used to coordinate the brokers/cluster topology. ZooKeeper is a consistent file system for configuration information. ZooKeeper gets used for leadership election for Broker Topic Partition Leaders.

What is consumer in Kafka?

Kafka Consumer Review A consumer group is a group of related consumers that perform a task, like putting data into Hadoop or sending messages to a service. Consumer groups each have unique offsets per partition. Different consumer groups can read from different locations in a partition.

What is Kafka cluster?

A Kafka cluster consists of one or more servers (Kafka brokers), which are running Kafka. Producers are processes that publish data (push messages) into Kafka topics within the broker. A consumer of topics pulls messages off a Kafka topic.

Where are offsets stored in Kafka?

Offset Storage - Kafka Offsets in Kafka are stored as messages in a separate topic named '__consumer_offsets' . Each consumer commits a message into the topic at periodic intervals.

What is Kafka producer and consumer?

or every new category of messages, users should define a new topic name. Kafka Producer: It is a client or a program, which produces the message and pushes it to the Topic. Kafka Consumer: It is a client or a program, which consumes the published messages from the Producer.