SYSTEM-DESIGN
    advanced

    Kafka Replication & Leader Election

    Software Engineer path · lesson 82 of 99
    Committed (HWM): 0ISR: 3/3
    Producerwrites to leader
    KRaft Controller

    Broker 1

    Leader
    Partition 0 replica
    empty
    in ISRLEO 0

    Broker 2

    Follower
    Partition 0 replica
    empty
    in ISRLEO 0

    Broker 3

    Follower
    Partition 0 replica
    empty
    in ISRLEO 0
    committed (in all ISR) replicated but not yet committed leader handles reads/writes
    Event Log
    Produce records, then kill the leader to watch failover…

    Key insight

    With acks=all, a record (green) is only committed once every in-sync replica has copied it — so when the leader dies, the controller can elect any ISR member and no acknowledged data is lost. Replication factor 3 tolerates 1 broker failure and keeps writes flowing — min.insync.replicas=2 is satisfied (with min.insync.replicas=2).

    A write with acks=all

    Sequence

    Order what happens between send and acknowledgement.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    1. 1Drop a step here
    2. 2Drop a step here
    3. 3Drop a step here
    4. 4Drop a step here
    5. 5Drop a step here
    5 pieces left to place

    Test your knowledge

    21 questions
    Question 1 of 21
    Score: 0

    Under acks=all, when is a produced record considered committed?

    The short version

    A replicated partition is like a document with one author (the leader) and proofreaders (followers) keeping live copies. If the author quits, a proofreader who has every page so far takes over — nothing already published is lost.

    In more depth

    Kafka Replication & ISR

    Kafka replicates every partition across replication.factor brokers. One replica is the leader (serves all reads/writes); the rest are followers that fetch from the leader.

    In-Sync Replicas (ISR)

    The ISR is the set of replicas fully caught up with the leader. With acks=all a record is only committed (advancing the high-water mark) once every ISR member has copied it — so an elected leader never loses acknowledged data.

    Failover

    When the leader crashes, the KRaft controller elects the first eligible in-sync replica as the new leader. unclean.leader.election=false ensures only ISR members are eligible, trading availability for durability.

    Interview Questions

    Confluent
    LinkedIn
    Stripe
    LinkedIn
    Amazon
    Confluent
    Meta
    Stripe
    Datadog

    Love this visualization?

    Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.

    100% free • No credit card required