Kafka Topic as a Log

Learn how messages are stored in a Kafka topic.

We have already encountered the term topic, albeit not formally. We know that a topic is a channel with a name to which we can produce messages and from which we can consume messages. But how is data actually stored in a topic? Before we answer this question, let’s talk about logs.

Logs

Think about a log file produced by an application—each line:

  • Has a line number or an index.

  • Can not be changed after it was written, i.e., it is immutable.

  • Is appended at the end of the file, making the log file an ordered sequence of events.

You can see it for yourself! Consider the following commands—each line starting with echo will write the value in quotes to the students.log file (>> means append to file).

Get hands-on with 1400+ tech skills courses.