IntermediateInternals
What is Kafka's RecordAccumulator and how does it buffer messages?
Reference answer
The RecordAccumulator is the producer-side in-memory buffer that batches records before sending. It maintains a deque of ProducerBatch objects per topic-partition. Incoming records are appended to the current batch. When a batch reaches batch.size or linger.ms expires, the Sender thread drains it and sends a ProduceRequest. If the buffer fills up (buffer.memory) and the batch can't complete within max.block.ms, BufferExhaustedException is thrown. Monitor producer-metrics:buffer-available-bytes to catch buffer pressure.
Expected key concepts: RecordAccumulator, buffer, ProducerBatch, topic-partition, batch.size, linger.ms, Sender thread, buffer.memory, max.block.ms, BufferExhaustedException