Essential Apache Kafka Interview Preparation Guide

Pushkaraj OgalePushkaraj Ogale
2 min read
  1. Broker:

    • A Kafka cluster is made up of multiple brokers.

    • These are just individual servers (they can be physical or virtual).

    • Each broker is responsible for storing data and serving clients.

    • The more brokers you have, the more data you can store and the more clients you can serve.

  2. Partition

    • Each broker has a number of partitions.

    • Each partition is an ordered, immutable sequence of messages that is continually appended to -- think of like a log file.

    • Partitions are the way Kafka scales as they allow for messages to be consumed in parallel.

  3. Topic

    • A topic is just a logical grouping of partitions.

    • Topics are the way you publish and subscribe to data in Kafka.

    • When you publish a message, you publish it to a topic, and when you consume a message, you consume it from a topic.

    • Topics are always multi-producer; that is, a topic can have zero, one, or many producers that write data to it

  4. Producers and consumers

    • Producers are the ones who write data to topics

    • consumers are the ones who read data from topics.

While Kafka exposes a simple API for both producers and consumers, the creation and processing of messages is on you, the developer. Kafka doesn't care what the data is, it just stores and serves it.

💡
A topic is a logical grouping of messages. A partition is a physical grouping of messages. A topic can have multiple partitions, and each partition can be on a different broker. Topics are just a way to organise your data | while partitions are a way to scale your data
💡
Kafka can be used as message queue or a stream. The only meaningful difference is with how consumers interact with the data. In a message queue, consumers read messages from the queue and then acknowledge that they have processed the message. In a stream, consumers read messages from the stream and then process them, but they don't acknowledge that they have processed the message. This allows for more complex processing of the data.
0
Subscribe to my newsletter

Read articles from Pushkaraj Ogale directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Pushkaraj Ogale
Pushkaraj Ogale