Apache Kafka Tutorial 0/111 lessons ~6 min read Lesson 7

    Topics

    What is Topics?

    Course progress0%
    Focus
    9 guided sections
    Practice signal
    Examples included
    Career prep
    Foundation builder

    Introduction

    What is Topics? Topics are named streams of records.

    Understanding the topic

    What happens — Topics:

    • Create a topic with a name and partition count.
    • Producers publish to the topic.
    • Records land in one partition each.
    • Many consumer groups can read the same topic.
    TermDescription
    TopicLogical name for a stream of records.
    Partition countParallelism and ordering boundaries.
    Replication factorNumber of copies per partition.
    RetentionHow long records are kept.

    Visual explanation

    Pipeline view:

    text
    Input topic
    filter/map/join/window
    state store + changelog
    output topic

    Step-by-step explanation

    1. Create topic — Define partitions, RF, retention.
    2. Publish — Producers send keyed records.
    3. Store — Brokers append per partition.
    4. Subscribe — Consumers join groups and read.

    Informative example

    Example:

    bash
    kafka-topics --bootstrap-server localhost:9092 --create --topic topics --partitions 6 --replication-factor 3
    kafka-console-producer --bootstrap-server localhost:9092 --topic topics
    kafka-console-consumer --bootstrap-server localhost:9092 --topic topics --from-beginning
    kafka-consumer-groups --bootstrap-server localhost:9092 --describe --group topics-service

    Execution workflow

    1Topics workflow
    1 / 4

    Create topic

    Define partitions, RF, retention.

    Best practices

    • Choose keys before joins and aggregations.
    • Name internal topics and state stores clearly.
    • Test topology with realistic ordering and late events.
    • Monitor processing latency, commit rate, and restore time.

    Common mistakes

    • Unexpected repartition topics from wrong key choices.
    • Ignoring late-arriving events in windows.
    • Underestimating state-store disk and restore time.

    Summary

    Topics — Design topology around keys, state stores, window boundaries, changelog topics, and exactly-once needs.

    Ready to mark this lesson complete?Track your journey across the entire course.