Skip to main content
InterviewHubPRO
Section Overview
Q50

Question 50 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

100%
Apache Kafka Streaming (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

High-Throughput Producer Tuning: `linger.ms`, `batch.size`, compression algorithms (zstd vs lz4 vs snappy), and buffer memory exhaustion.

senior LevelCode ExampleSystem Design

In Simple Words: Maximizing Kafka producer throughput (achieving 100MB+/sec per node):

properties
# Allow producer to wait up to 20ms to aggregate larger batches
linger.ms=20

# Increase batch size buffer to 64KB (default 16KB)
batch.size=65536

# Optimal compression algorithm:
# - lz4: Lowest CPU overhead, blazing fast decompression
# - zstd: Best compression ratio (reduces network bandwidth by up to 70%)
compression.type=zstd

# Maximum memory buffer for unsent messages before producer blocks
buffer.memory=67108864 # 64MB

# Max time producer.send() blocks when buffer.memory is full before throwing error
max.block.ms=15000