What is Apache Kafka?
Solution and explanation
What it is
Apache Kafka is a **distributed event-streaming platform**. Applications write events (records) to it, Kafka stores them durably on disk in an ordered, replicated log, and any number of applications read them, at their own pace, now or later. It was built at LinkedIn in 2011 and is now used by banks, Uber, Swiggy, Zerodha, Netflix and most large backends.
Kafka combines three capabilities:
- **Publish and subscribe** to streams of records (like a message system).
- **Store** streams durably and fault-tolerantly for as long as configured (days, or forever).
- **Process** streams as they arrive (Kafka Streams, ksqlDB, Flink).
Core vocabulary
| Term | Meaning |
|---|---|
| Record/event | key, value, timestamp, headers |
| Topic | named stream, e.g. payments.completed |
| Partition | ordered, append-only log; a topic has many |
| Offset | position of a record in a partition |
| Broker | a Kafka server storing partitions |
| Producer / Consumer | writes / reads records |
| Consumer group | consumers sharing the work of reading a topic |
Why it is fast
- Sequential disk writes and reads (append-only log) instead of random I/O.
- Relies on the OS page cache and **zero-copy** (
sendfile) to send data from disk to network. - Batching and compression of records.
- Horizontal scaling through partitions spread over brokers.
Example
producer.send(new ProducerRecord<>("orders.placed", orderId, orderJson));
The inventory, payment, notification and analytics services each read orders.placed independently.
Summary
Kafka is a durable, replicated, partitioned commit log that lets many systems publish and consume event streams at very high throughput with ordering per partition.
