Apache Kafka
Apache Kafka is a distributed platform that stores streams of events. Applications publish records to shared logs, and different readers can process or replay those records independently.
Also known as: Kafka, кафка
Think of it as a shared, durable log
When a customer pays for an order, the checkout service can publish a record of the payment instead of calling every service that needs to know about it. Shipping and reporting can read that record independently. In Kafka, the application that writes records is a producer, the one that reads them is a consumer, and a named stream such as orders is a topic.
Why topics have partitions
A topic is split into partitions. Each partition is an append-only log, and a record's offset identifies its position in that partition. Kafka orders records within a partition, not across the entire topic. If two records must be read in the order they were written, they need to land in the same partition.
Kafka servers are called brokers. Splitting a topic into partitions lets different brokers serve parts of the workload. Replication serves a different purpose: it keeps copies of a partition on multiple brokers so that another replica can take over if the leader fails, provided an eligible replica is available.
How readers share work and track progress
A consumer group lets multiple instances of an application split the work. Within a group, each partition is assigned to at most one consumer at a time. If a topic has three partitions and the group subscribes only to that topic, adding a fourth consumer won't increase read parallelism. A second group gets its own assignments and can read the same records independently.
Consumers commit offsets to record where their group should resume. A committed offset is a checkpoint, not a deletion request: with Kafka's delete retention policy, records are removed based on configured time or size limits, not because a group read them. A group can replay data by seeking back to an offset that is still available.
Example: routing order events
Suppose OrderPlaced and OrderPaid both use order-42 as their record key. With the default key-based partitioning and an unchanged partition count, both go to the same partition. If the producer appends OrderPlaced first, Kafka exposes it before OrderPaid in that partition. The shipping and reporting applications use separate groups, so a reporting backlog doesn't move shipping's read position.
Where it fits and what interviewers test
Kafka is useful when multiple systems need the same stream, such as when forwarding database changes, feeding analytics pipelines, or sharing events between microservices. Unlike a typical work queue, one reader's progress doesn't prevent other groups from reading or replaying the retained data.
A common interview scenario is a worker that writes to a database and crashes before committing its offset. The next worker may process the same record again, so the database operation needs to tolerate repeats. Kafka transactions can atomically commit consumed offsets together with results written back to Kafka; they do not automatically include an external database write.