liveBook · Manning

Apache Kafka

As explained in Apache Kafka in Action

Apache Kafka is a distributed event-streaming platform for publishing, storing, processing, and subscribing to streams of records.

When an online store changes a product price, inventory and sales analysis both need the update—but they need not call each other. Apache Kafka lets a producer publish the change once and lets independent consumers read it. Kafka is an open-source, distributed event-streaming platform built around persistent logs, so consumers can also revisit retained events after a failure or for later analysis. section 1.1 section 2.4

A producer writes records to a topic, which organizes a stream of related data. Kafka divides topics into partitions across brokers. A record has a value and may have a key, timestamp, and headers; records with the same key go to the same partition. An offset identifies a record’s position within its partition. Consumers read records, while a consumer group shares partitions among its members to process work in parallel. section 1.3 section 3.3 section 4.5

Figure 1.2 The components and data flow of Kafka
A screenshot of a computer game

AI-generated content may be incorrect.

Follow a record from its producer through a topic partition and broker to a consumer; the diagram also shows the components involved in replication. section 1.3

Replication places partition copies on multiple brokers. A leader handles a partition’s reads and writes, and followers provide resilience if a broker fails. Adding partitions supports parallel work; adding brokers distributes storage and load. Those gains depend on topic design and a healthy cluster, not merely on publishing more records. section 1.3 section 4.5 section 1.4

Watch a price stream from two terminals

With Kafka running and the topic `products.prices.changelog` available, start `kafka-console-consumer.sh --topic products.prices.changelog --bootstrap-server localhost:9092` in one terminal. In another, run `kafka-console-producer.sh --topic products.prices.changelog --bootstrap-server localhost:9092` and enter `coffee pads 11`. The consumer displays the update. Start a second consumer with `--from-beginning` to read retained earlier prices independently. Stop the producer with Ctrl-D and consumers with Ctrl-C. section 2.0 section 2.4

Kafka is an exchange between systems, not a replacement for their databases or search engines. Its asynchronous model loosens service dependencies, but consumers must decide how to use the data, and retention or cleanup limits how far back they can read. For production, plan reliable brokers and networking, monitoring, schemas, access controls, and capacity. Managed hosting reduces infrastructure work but does not remove the need for Kafka expertise. section 4.5 section 17.2.1 section 1.4 section 13.4

How Apache Kafka in Action covers it

How deep it goes
Explains topics, partitions, offsets, replication, clients, and cluster operation, extending to message persistence and governance.
Examples
Uses parallel console producers and consumers to send price changes and reread them from the beginning.
What it assumes
Starts with basic Kafka components but assumes an installed cluster for the first command-line exercise.
What you can do after
Operate/configure it by producing and consuming records, designing topics, and planning reliable cluster infrastructure.
How it connects
Links event-driven architecture and publish-subscribe messaging to distributed logs, consumer groups, replication, schemas, and asynchronous communication.

Also explained in

Compare how 6 books explain Apache Kafka →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Apache Kafka in Action. The section links point to the parts of the book it draws on.