Skip to content
Middle–Middle+7 viewsAsked at 2 companies

And what about Kafka? Could you tell me what its main components are and how they interact?

Practice

AI answer

The main Kafka entities:

  • Broker — a Kafka server; multiple brokers form a cluster.
  • Topic — a logical category of messages. A topic is divided into partitions — ordered message logs; ordering is guaranteed only within a single partition.
  • Producer — publishes messages to a topic. Kafka typically chooses a partition based on the message key, so using the same key helps preserve ordering for related events.
  • Consumer — reads messages and tracks its read position using an offset.
  • Consumer group — multiple consumers that process a topic together: within a group, at most one consumer reads a given partition at any moment. When the group membership changes, partitions may be reassigned.
  • Replication — copying partitions to other brokers for fault tolerance; a partition has a leader that handles reads and writes, as well as replicas.

A typical flow: a producer writes an event to a partition, Kafka stores it, and a consumer in a group reads it and acknowledges processing by advancing its offset. Kafka typically provides at-least-once delivery, so consumers need to be able to safely process a message again; exactly-once is possible only with appropriate configuration and supported mechanisms.