Apache Kafka 00:00:01 A receipt at offset seven A shop records that an order has been paid. Billing and fulfillment both need the news, and either service might go offline for an hour. The producer sends an event to a Kafka topic using the order identifier as its key. In this example the selected partition has a leader. It appends the record at offset seven. That number names a position inside this particular partition. Other partitions have their own offset seven. Two follower replicas fetch new records from the leader. They put this event at offset seven in their local copies. The shop must now decide what evidence of replication counts as a successful write. 00:00:44 Decide what an acknowledgement means With acknowledgements set to all, the leader waits for the current in-sync replicas to acknowledge. The producer’s success response and a downstream worker finishing the order are two different events. Suppose the topic has three replicas and requires at least two in sync. Once a failed follower leaves the in-sync set, two healthy replicas can still satisfy that write policy. A second failure leaves just one in-sync broker. An all-acknowledgements write can now be refused. The shop has chosen to surface a write problem instead of accepting a record with fewer copies than promised. 00:01:23 Two teams read the same history Billing and fulfillment use different consumer groups. Each group can read the paid event without removing it for the other. Within a group, the ordinary partition assignment puts one consumer in charge of a given partition at a time. The fulfillment consumer asks for records at or beyond its position. It receives offset seven and prepares a shipment. Fetching the event did not physically remove the event from the broker’s retained log. Once the work is complete, the group commits position eight. It says that the next record to read is eight. A restarted consumer can resume from that position while the required data is retained. 00:02:04 Choose which failure you can repair Now put three records at offsets ten, eleven and twelve. A consumer has received the batch. Picture a crash exactly between recording progress and doing something visible outside Kafka. First suppose it finishes ten and eleven and then crashes before committing. A replacement sees the older committed position. The broker is entitled to offer those processed records again. Replaying an event must not create a second shipment. The fulfillment database can enforce one shipment per order identifier, committing the identifier and the shipment together. Redelivery then meets a completed record. 00:02:43 What a transaction covers When the work consists of reading Kafka records and publishing new Kafka records, a producer can put the outputs into a Kafka transaction. Consumers configured to read committed data see only committed transactional outputs. The transaction can also include the consumer group’s new offsets. Commit and the output and position advance together. A failed transaction can be aborted so its partial output stays hidden from committed readers. An outside shipping provider does not suddenly join that transaction. The original paid event was one immutable position in one partition. Copies protect the record, group offsets track each reader, and a separate delivery contract protects the real shipment.