max.block.ms — Kafka Producer Configuration
The configuration controls how long the KafkaProducer's send(), partitionsFor(), initTransactions(), sendOffsetsToTransaction(), commitTransaction() and abortTransaction() methods will block. For send() this timeout bounds the total time waiting for both metadata fetch and buffer allocation (blocking in the user-supplied serializers or partitioner is not counted against this timeout).
Description
The configuration controls how long the KafkaProducer's send(), partitionsFor(), initTransactions(), sendOffsetsToTransaction(), commitTransaction() and abortTransaction() methods will block. For send() this timeout bounds the total time waiting for both metadata fetch and buffer allocation (blocking in the user-supplied serializers or partitioner is not counted against this timeout). For partitionsFor() this timeout bounds the time spent waiting for metadata if it is unavailable. The transaction-related methods always block, but may timeout if the transaction coordinator could not be discovered or did not respond within the timeout.
Default Values by Kafka Version
| Kafka Version | Default Value |
|---|---|
| 0.9.0 | 60000 |
| 0.10.0 | 60000 |
| 0.10.1 | 60000 |
| 0.10.2 | 60000 |
| 0.11.0 | 60000 |
| 1.0 | 60000 |
| 1.1 | 60000 |
| 2.0 | 60000 |
| 2.1 | 60000 |
| 2.2 | 60000 |
| 2.3 | 60000 |
| 2.4 | 60000 |
| 2.5 | 60000 |
| 2.6 | 60000 (1 minute) |
| 2.7 | 60000 (1 minute) |
| 2.8 | 60000 (1 minute) |
| 3.0 | 60000 (1 minute) |
| 3.1 | 60000 (1 minute) |
| 3.2 | 60000 (1 minute) |
| 3.3 | 60000 (1 minute) |
| 3.4 | 60000 (1 minute) |
| 3.5 | 60000 (1 minute) |
| 3.6 | 60000 (1 minute) |
| 3.7 | 60000 (1 minute) |
| 3.8 | 60000 (1 minute) |
| 3.9 | 60000 (1 minute) |
| 4.0 | 60000 (1 minute) |
| 4.1 | 60000 (1 minute) |
| 4.2 | 60000 (1 minute) |
Tuning Recommendation
| Profile | Recommended | Why |
|---|---|---|
| producer / latency | 1000 | Reducing the send() block timeout to 1s prevents the calling thread from stalling for up to 60s when buffer.memory is exhausted; instead it fails fast with a BufferExhaustedException that the application can handle (drop, circuit-break, or shed load). |
| producer / durability | 60000 | The 60s block timeout allows send() to wait for buffer.memory to free up during sustained broker outages, keeping backpressure transparent to the application and preventing data loss from rejected sends during transient failures. |
Related Configs
buffer.memory · delivery.timeout.ms · batch.size