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

    Brokers

    What is Brokers?

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

    Introduction

    What is Brokers? Brokers are Kafka servers that store partitions, serve reads/writes, replicate data, and coordinate clients.

    Understanding the topic

    What happens — Brokers:

    • Brokers host topic partitions on disk.
    • One broker is leader per partition.
    • Followers replicate for fault tolerance.
    • Controller broker manages cluster metadata.
    TermDescription
    BrokerKafka server node in the cluster.
    Log directoryDisk path where partition segments live.
    ControllerElected broker for metadata (KRaft).
    RackFailure domain for replica placement.

    Visual explanation

    Pipeline view:

    text
    Producer
    Topic partition log
    Consumer group A
    Consumer group B
    Replay is possible because records are retained

    Step-by-step explanation

    1. Start broker — Load logs and join cluster.
    2. Lead partitions — Serve produce/fetch for assigned leaders.
    3. Replicate — Followers fetch from leaders.
    4. Fail over — New leader elected on failure.

    Informative example

    Example:

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

    Execution workflow

    1Brokers workflow
    1 / 4

    Start broker

    Load logs and join cluster.

    Best practices

    • Design events around business facts: OrderCreated, PaymentAuthorized, InventoryReserved.
    • Pick keys based on ordering and load distribution.
    • Document owner, retention, schema, partitions, and consumers for every topic.
    • Assume duplicate delivery and build idempotent consumers early.

    Common mistakes

    • Expecting global ordering across a topic.
    • Creating one partition because local demos work.
    • Skipping schema governance until multiple teams deploy independently.

    Summary

    Brokers — Start every design with event ownership, topic naming, key choice, schema contract, retention, replay plan, and monitoring.

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