Replication
- Compare leadership, in-sync replicas and the write contract across three brokers.
Select a component to trace its direct connections. Drag to pan · Ctrl + wheel or pinch to zoom.
- Each row is one partition, with one replica per rack. The leader accepts writes. Followers fetch records from it. Arrows follow the copied records.
- ISR means in-sync replicas, including the leader. Broker C is catching up on P0 while its copy of P1 is in sync.
- With acks=all and a minimum ISR of two, a P0 write waits for A and B. A P1 write waits for all three in-sync copies.
Reading
- If A fails, P0 must elect a leader and restore a second in-sync replica to acknowledge new writes with these settings. P1 retains its leader B and two in-sync copies.
Partition replication and acknowledgments
Partition replication and acknowledgments
Apache Kafka 4.1 · illustrative cluster and offsets
Read the two partition placements
- The topic has two partitions, each with one replica on A, B and C. A leads P0, B leads P1. Place replicas on separate racks or zones when those failures must be tolerated.
- Followers fetch from their partition leader. ISR membership tracks a replica’s ability to keep up. A running broker can have a lagging replica outside the ISR.
- The map shows record-copy direction. The high watermark tracks replicated progress. Open transactions can further delay read-committed consumers.
Replica placement and acknowledgment casesjson
{
"topic": "orders",
"assumptions": ["stable ISR during each case", "acks=all", "min.insync.replicas=2", "unclean.leader.election.enable=false"],
"partitions": [
{"id": 0, "replicas": ["A","B","C"], "leader": "A"},
{"id": 1, "replicas": ["B","C","A"], "leader": "B"}
],
"cases": [
{"partition": 0, "isr": ["A","B","C"], "requiredCopiesForAck": 3, "writesAllowed": true},
{"partition": 0, "isr": ["A","B"], "requiredCopiesForAck": 2, "writesAllowed": true},
{"partition": 0, "isr": ["A"], "requiredCopiesForAck": null, "writesAllowed": false}
],
"note": "A timeout or a change of ISR during an attempt can leave its outcome uncertain."
}
When a P0 write can succeed
| Stable P0 ISR | Result with acks=all and min.insync.replicas=2 |
|---|---|
| A, B and C | All three current members must replicate the write for acknowledgment. |
| A and B | Both must replicate it. C can continue catching up. |
| A only | The minimum fails. The producer can receive a replication error. |
- A timeout or ISR change after append can leave the caller uncertain. Bound delivery time and use producer idempotence for compatible retries. Recreating a business operation can still create a duplicate effect.
- Kafka 4.1 supports eligible leader replicas (ELR). A controller may promote a safe tracked candidate outside the current ISR. Forcing an unclean election can lose committed data. Check effective feature/configuration before a recovery decision.
Size and test for one loss
- Two partitions × three replicas create six partition logs. With balanced ingress of 10 MiB/s per partition, each broker stores about 20 MiB/s of log payload before overhead. Leader outbound replication totals roughly 40 MiB/s across brokers when all followers keep up.
- Disk, network, retention, compaction and traffic skew change real requirements. Extra replicas increase write IO, usable durability and failover options. Additional partitions change key placement and per-partition parallelism.
- Compare P0 and P1 independently when A is unavailable. P0 needs a leader change. P1 can keep its leader and loses one replica.