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.

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay