Batching (การจัดกลุ่มข้อความ) และ compression (การบีบอัดข้อมูล) เป็นเทคนิคสำคัญสำหรับ throughput ของ Kafka ที่สูง — ลด overhead ต่อข้อความและต้นทุน network/storage การเข้าใจสิ่งเหล่านี้ช่วยให้ได้ performance ที่สูงของ Kafka
Batching — จัดกลุ่มข้อความ
BATCHING → the producer groups multiple messages into a single BATCH before sending:
→ fewer, larger requests instead of many tiny ones → much higher THROUGHPUT (less
per-request overhead, fewer network round-trips)
→ controlled by: batch.size (batch size limit) + linger.ms (wait time to accumulate a batch)
→ trade-off: slightly higher LATENCY (waiting to batch) for much higher throughput
→ batching is essential for high-throughput producing
