Kafka Exception BufferExhaustedException
org.apache.kafka.clients.producer.BufferExhaustedException
Retriable
Producer
This exception is thrown if the producer cannot allocate memory for a record within max.block.ms due to the buffer being too full. In earlier versions a TimeoutException was thrown instead of this. To keep existing catch-clauses working this class extends TimeoutException.
Common Causes
- The producer's record accumulator hit buffer.memory (default 32MB) and could not allocate space within max.block.ms
- max.block.ms is set low (or 0) so send() fails fast instead of blocking when the buffer is full
- Records are produced faster than the broker can acknowledge them (slow brokers, large batches, or throttling), so the buffer fills up
Solutions
- Increase buffer.memory and/or max.block.ms to give send() room to wait for buffer space
- Throttle the produce rate, enable compression (compression.type), and tune batch.size/linger.ms so batches drain efficiently
- Investigate broker-side slowness or quotas — a BufferExhaustedException is usually a symptom of the send path not keeping up
Example Stack Trace
org.apache.kafka.clients.producer.BufferExhaustedException: Failed to allocate 16384 bytes within the configured max blocking time 0 ms. Total memory: 33554432 bytes. Available memory: 0 bytes. Poolable size: 16384 bytesRelated
Related Producer exceptions: InvalidProducerEpochException · OutOfOrderSequenceException · RecordBatchTooLargeException · RecordTooLargeException · TransactionAbortedException · UnknownProducerIdException · UnsupportedForMessageFormatException
Hitting
BufferExhaustedException in production? Conduktor Console gives you real-time visibility into clients, consumer groups, and broker health. Browse every Kafka exception or protocol error code.