DEV Community

Anjali Gurjar
Anjali Gurjar

Posted on

with answer kafka

  1. Kafka Questions with Answers Q1: What is Kafka, and how does it work? A: Kafka is a distributed event streaming platform used for building real-time data pipelines and applications. It works by producing messages to topics, which are then consumed by subscribers in a publish-subscribe model.

Q2: Explain the key components of Kafka.
A:

Producer: Sends messages to Kafka topics.
Broker: Kafka server that stores messages.
Consumer: Reads messages from topics.
Topic: Logical channel for storing messages.
Partition: Splits topics for parallelism and scalability.
Zookeeper: Coordinates and manages the Kafka cluster (optional in Kafka newer versions).
Q3: What is the role of partitions in Kafka?
A: Partitions allow Kafka to scale horizontally. Each partition can be processed independently, enabling parallelism. They also ensure message ordering within a partition.

Q4: What is an offset in Kafka?
A: Offset is a unique identifier for a message within a partition. It helps consumers keep track of which messages they’ve read.

Q5: How do you ensure message ordering in Kafka?
A: By writing all messages for a key to the same partition. Kafka guarantees order within a single partition.

Q6: What is log compaction?
A: Log compaction retains only the most recent value for a key, removing older messages, reducing storage usage, and keeping the topic size manageable.

Q7: What happens if a Kafka broker fails?
A: If replication is configured, other replicas take over for the failed broker. The leader for affected partitions is reassigned automatically.

Top comments (0)