Kafka sends a message to consumers only after every in-sync replica holds it.
A replica is in sync when its copy of the data is no more than 10 seconds behind. With replicas R1, R2 and R3, and R3 out of sync, a message that R2 and R3 hold is not enough. It has to reach R1 and R2. If R2 fails, the consumer reads from R1.
Events are immutable, so a message is deleted with a tombstone, a later message with a null in its value part. It marks a logical deletion for the key, and the previous values for that key go when log compaction runs. A like that is taken back is a null.
Zero copy removes a step from sending a message to a consumer:
- The standard process. The broker loads the message from the file system into its application cache, then writes it to I/O. Those are two I/O calls.
- Zero copy. The file system cache writes directly to the network channel, without intermediate buffers, in a single I/O call.