batch.size — Kafka Producer Configuration
The producer will attempt to batch records together into fewer requests whenever multiple records are being sent to the same partition. This helps performance on both the client and the server
Description
The producer will attempt to batch records together into fewer requests whenever multiple records are being sent to the same partition. This helps performance on both the client and the server. This configuration controls the default batch size in bytes.No attempt will be made to batch records larger than this size.Requests sent to brokers will contain multiple batches, one for each partition with data available to be sent.A small batch size will make batching less common and may reduce throughput (a batch size of zero will disable batching entirely). A very large batch size may use memory a bit more wastefully as we will always allocate a buffer of the specified batch size in anticipation of additional records.Note: This setting gives the upper bound of the batch size to be sent. If we have fewer than this many bytes accumulated for this partition, we will 'linger' for the linger.ms time waiting for more records to show up. This linger.ms setting defaults to 5, which means the producer will wait for 5ms or until the record batch is of batch.size (whichever happens first) before sending the record batch. Note that broker backpressure can result in a higher effective linger time than this setting. The default changed from 0 to 5 in Apache Kafka 4.0 as the efficiency gains from larger batches typically result in similar or lower producer latency despite the increased linger.Type:intDefault:16384Valid Values:[0,...]Importance:medium
Default Values by Kafka Version
| Component | Kafka version line | Documented default |
|---|---|---|
| Producer | 0.7 | 200 |
| Producer | 0.8.1 | 16384 |
| Producer | 0.8.2 | 16384 |
| Producer | 0.9.0 | 16384 |
| Producer | 0.10.0 | 16384 |
| Producer | 0.10.1 | 16384 |
| Producer | 0.10.2 | 16384 |
| Producer | 0.11.0 | 16384 |
| Producer | 1.0 | 16384 |
| Producer | 1.1 | 16384 |
| Producer | 2.0 | 16384 |
| Producer | 2.1 | 16384 |
| Producer | 2.2 | 16384 |
| Producer | 2.3 | 16384 |
| Producer | 2.4 | 16384 |
| Producer | 2.5 | 16384 |
| Producer | 2.6 | 16384 |
| Producer | 2.7 | 16384 |
| Producer | 2.8 | 16384 |
| Producer | 3.0 | 16384 |
| Producer | 3.1 | 16384 |
| Producer | 3.2 | 16384 |
| Producer | 3.3 | 16384 |
| Producer | 3.4 | 16384 |
| Producer | 3.5 | 16384 |
| Producer | 3.6 | 16384 |
| Producer | 3.7 | 16384 |
| Producer | 3.8 | 16384 |
| Producer | 3.9 | 16384 |
| Producer | 4.0 | 16384 |
| Producer | 4.1 | 16384 |
| Producer | 4.2 | 16384 |
| Producer | 4.3 | 16384 |
| Producer | 4.4 | 16384 |
Tuning Recommendation
Workload-dependent proposals, not benchmarked defaults. Review the versioned Config Advisor before applying.
| Profile | Proposal | Rationale and tradeoff |
|---|---|---|
| producer / throughput | 131072 | Sets the allocation target for a batch for one partition; fuller batches can amortize request overhead. Tradeoff: Larger batches can consume more buffer memory without filling at low traffic. Reference · 2026-10-27 |
| producer / latency | 16384 | Sets the allocation target for a batch for one partition; fuller batches can amortize request overhead. Tradeoff: Larger batches can consume more buffer memory without filling at low traffic. Reference · 2026-10-27 |
Related Configs
linger.ms · buffer.memory · max.request.size · compression.type · send.buffer.bytes · max.block.ms