Kafka Producer Throughput Configuration
Evaluate batching, compression and buffering for sustained production; retain delivery guarantees.
producer
| Config / reference | Default → proposal | Rationale and conditions |
|---|---|---|
| Batching and compression | ||
| batch.size Java client 4.4 Evaluate | 16 KiB → 128 KiB | 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. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: Low per-partition traffic or a tight memory budget. Measure: batch-size-avg, records-per-request-avg, buffer-available-bytes The producer buffer is shared across partitions. Exhaustion can block send() until max.block.ms; handle synchronous exceptions as well as asynchronous send failures. Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| linger.ms Java client 4.4 Evaluate | 5 ms → 20 ms | Sets the intentional batching wait. Full batches can be sent earlier; zero removes this wait but does not prevent batching. Tradeoff: A larger value can delay partially filled batches. Queueing and broker backpressure can add other delays. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: A latency budget smaller than the proposed batching wait. Measure: record-queue-time-avg, batch-size-avg, end-to-end p95/p99 latency In Java, delivery.timeout.ms must be >= linger.ms + request.timeout.ms. librdkafka timeout names and validation rules are different. max.block.ms bounds synchronous waiting for metadata/buffer allocation; linger.ms concerns batching after enqueueing. There is no general requirement that max.block.ms exceed linger.ms. Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| compression.type Java client 4.4 Evaluate | none → lz4 | Selects the batch compression codec. Evaluate the candidate with the actual payload and record rate. Tradeoff: Compression trades CPU for network and storage bytes. No codec or compression ratio is best for every workload. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: Already-compressed payloads or a CPU-bound producer without a measured benefit. Measure: compression-rate-avg, CPU, bytes sent and p95/p99 latency A codec-specific compression level only applies to the selected codec. Benchmark CPU, bytes and latency; no fixed gain is implied. Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| compression.lz4.level Java client 4.4 Evaluate | 9 → 1 | Selects the LZ4 compression effort when LZ4 is enabled. Java accepts levels 1 through 17; 9 is the default, not the maximum. Tradeoff: Changing the level trades compression effort against compressed size. Java and librdkafka levels have different ranges and are not performance-equivalent. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: A codec other than LZ4 or a workload without a compression benchmark. Measure: compression-rate-avg, CPU, output bytes and latency at each level A codec-specific compression level only applies to the selected codec. Benchmark CPU, bytes and latency; no fixed gain is implied. Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| buffer.memory Java client 4.4 Evaluate | 32 MiB → 128 MiB | Budgets producer record buffering during bursts or temporary downstream slowdown. Tradeoff: It is not a hard cap on total producer process memory, and increasing it cannot fix sustained downstream saturation. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: A process memory limit that cannot accommodate the proposed budget and other allocations. Measure: buffer-available-bytes, bufferpool-wait-time, process memory and send failures The producer buffer is shared across partitions. Exhaustion can block send() until max.block.ms; handle synchronous exceptions as well as asynchronous send failures. Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| Network and buffers | ||
| max.request.size Java client 4.4 Evaluate | 1048576 → 5242880 | Limits a Java producer request and effectively the maximum uncompressed record batch. Increase only when record sizes require it. Tradeoff: Broker/topic limits apply to record batches after compression; they are not identical to the whole request limit. Check socket.request.max.bytes separately. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: An unverified broker/topic batch limit or an assumption that larger requests alone improve throughput. Measure: request-size-max, record-size-max, rejected records and broker limits The Java request limit and uncompressed batch limit differ from the broker/topic compressed record-batch limit. Also check the broker whole-request limit socket.request.max.bytes. Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| send.buffer.bytes Java client 4.4 Evaluate | 128 KiB → 1 MiB | Requests a TCP send buffer size; the operating system determines the effective allocation. Tradeoff: Larger socket buffers may use more kernel memory. A larger configured value does not guarantee lower blocking or higher throughput. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: A socket buffer change without evidence of network backpressure or OS limit review. Measure: effective SO_SNDBUF, network throughput, socket memory and RTT Java socket buffers use -1 for the OS default. librdkafka uses 0. Effective allocation and autotuning depend on the OS. Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| receive.buffer.bytes Java client 4.4 Evaluate | 32 KiB → 256 KiB | Requests a TCP receive buffer size for client connections. Tradeoff: Kernel defaults, autotuning and limits affect the result. More buffer capacity may be unused on low-volume response paths. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: A memory-constrained client without a measured receive bottleneck. Measure: effective SO_RCVBUF, socket memory, bytes received and request latency Java socket buffers use -1 for the OS default. librdkafka uses 0. Effective allocation and autotuning depend on the OS. Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| Delivery and transactions | ||
| acks Java client 4.4 Keep | all (unchanged) | With acks=all, successful writes require the relevant in-sync replica acknowledgements and the configured minimum ISR. Tradeoff: Durability depends on replication, ISR and failure conditions. acks=1 can lose acknowledged writes after leader failure and conflicts with explicitly enabled idempotence. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: Using acks=all as a substitute for reviewing topic replication and min.insync.replicas. Measure: UnderMinIsrPartitionCount, produce errors, replication state and acknowledgement latency Java idempotence requires acks=all, retries>0 and max.in.flight.requests.per.connection<=5. Explicit conflicting settings are rejected. acks=all must be reviewed with actual topic replication, ISR and failure scenarios. A single-replica ISR can satisfy a minimum ISR of one. Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| enable.idempotence Java client 4.4 Keep | true (unchanged) | Deduplicates retried producer batches within the producer protocol and preserves ordering with compatible settings. It is not end-to-end exactly-once processing. Tradeoff: Requires acks=all, retries greater than zero and at most five in-flight requests in Java. Application retries across producer sessions can still duplicate business events. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: Conflicting acknowledgement, retry or in-flight settings; unsupported client versions. Measure: duplicate business events, producer errors and sequence-related failures Java idempotence requires acks=all, retries>0 and max.in.flight.requests.per.connection<=5. Explicit conflicting settings are rejected. Without idempotence, retries with multiple in-flight requests can reorder records. Idempotence does not deduplicate arbitrary application resends. Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| max.in.flight.requests.per.connection Java client 4.4 Keep | 5 (unchanged) | Controls request pipelining per broker connection. Java idempotent production supports at most five in-flight requests. Tradeoff: Without idempotence, retries with more than one in-flight request can reorder records. Serializing requests reduces concurrency. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: Raising beyond the client idempotence limit or disabling ordering protections without application review. Measure: request latency, in-flight requests, throughput and record ordering Java idempotence requires acks=all, retries>0 and max.in.flight.requests.per.connection<=5. Explicit conflicting settings are rejected. Without idempotence, retries with multiple in-flight requests can reorder records. Idempotence does not deduplicate arbitrary application resends. Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| retries Java client 4.4 Keep | 2147483647 (unchanged) | Allows retryable produce failures to be retried; delivery.timeout.ms also bounds delivery in clients that support it. Tradeoff: Retries do not handle every error. Applications must inspect send futures or callbacks and handle failed or ambiguous outcomes. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: Treating a high retry count as a guarantee that records cannot fail or be duplicated by application retries. Measure: record-retry-rate, record-error-rate and delivery failures Java idempotence requires acks=all, retries>0 and max.in.flight.requests.per.connection<=5. Explicit conflicting settings are rejected. Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| delivery.timeout.ms Java client 4.4 Evaluate | 2 min → 5 min | Bounds the delivery attempt window after send() returns, including batching, acknowledgement waits and retryable failures. Tradeoff: A longer window delays final failure reporting and can hold buffered records longer. It must be at least request.timeout.ms + linger.ms in Java. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: A failure-response budget shorter than this window, or treating it as a guarantee of successful delivery. Measure: delivery failures, record-queue-time and recovery during broker outages In Java, delivery.timeout.ms must be >= linger.ms + request.timeout.ms. librdkafka timeout names and validation rules are different. Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| retry.backoff.ms Java client 4.4 Keep | 100 ms (unchanged) | Sets the initial wait between retry attempts; combine it with retry.backoff.max.ms where supported. Tradeoff: Longer waits reduce retry pressure but can delay recovery. Jitter, processing and timeout budgets affect the actual retry schedule. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: A retry delay chosen without measuring failure recovery and broker load. Measure: record-retry-rate, request rate and recovery latency Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| retry.backoff.max.ms Java client 4.4 Evaluate | 1 s → 5 s | Caps the exponential retry backoff where supported by the selected client version. Tradeoff: Increasing the cap can delay recovery after a short outage. It does not imply a fixed number of attempts within the delivery window. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: Recovery objectives that cannot tolerate the proposed backoff. Measure: retry rate, failure recovery time and delivery timeout rate Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| Other controls | ||
| request.timeout.ms Java client 4.4 Keep | 30 s (unchanged) | Bounds waiting for a Java client request response. For producers, review it together with the delivery window. Tradeoff: A shorter request timeout can trigger retries during slow responses; it is not an application processing deadline. librdkafka request.timeout.ms has different, broker-enforced acknowledgement semantics. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: Translating this setting directly to librdkafka or setting it below observed response tails. Measure: request-latency-max, timeout rate and retry rate In Java, delivery.timeout.ms must be >= linger.ms + request.timeout.ms. librdkafka timeout names and validation rules are different. Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| partitioner.adaptive.partitioning.enable Java client 4.4 Keep | true (unchanged) | Allows the built-in producer partitioner to favor partitions on faster brokers for eligible unkeyed records. Tradeoff: Adaptive distribution can be uneven. It does not override explicit partition selection or every custom partitioner. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: A workload requiring uniform partition distribution without verifying partitioner behavior. Measure: per-partition throughput, batch size and broker request latency Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| partitioner.ignore.keys Java client 4.4 Keep | false (unchanged) | Keeping false preserves key-based partition selection with the built-in partitioner. Tradeoff: Setting true makes the built-in partitioner ignore keys when selecting partitions and can invalidate application key locality assumptions. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: Changing key partitioning for consumers or compacted topics that depend on stable key placement. Measure: per-key partition consistency and partition skew Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| metadata.max.age.ms Java client 4.4 Keep | 5 min (unchanged) | Bounds the interval between periodic metadata refreshes even when no leadership change was detected. Tradeoff: Errors can trigger earlier refreshes. Lowering this interval is not a direct fix for leader failover latency and increases metadata traffic. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: Using periodic refresh as the sole explanation for failover recovery. Measure: metadata request rate, metadata age and discovery time for new partitions Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |
| connections.max.idle.ms Java client 4.4 Keep | 9 min (unchanged) | Controls how long idle client connections may remain open. Tradeoff: Longer-lived connections retain resources; shorter intervals can add connection and authentication work. Network intermediaries may impose their own timeouts. Workload, validation and sourcesWorkload: Sustained production with enough traffic per partition to fill batches. Avoid when: An idle timeout inconsistent with load balancers or connection resource limits. Measure: connection creation/close rate, authentication latency and file descriptors Versioned reference · 2026-10-27 · unbenchmarked tuning proposal |