Skip to main content

Posts

Showing posts from July, 2025

🔄 Kafka Producer Internals: send() Explained with Delivery Semantics and Transactions

Kafka Producer Internal Working Apache Kafka is known for its high-throughput, fault-tolerant message streaming system. At the heart of Kafka's data pipeline is the Producer —responsible for publishing data to Kafka topics. This blog dives deep into the internal workings of the Kafka Producer, especially what happens under the hood when send() is called. We'll also break down different delivery guarantees and transactional semantics with diagrams. 🧠 Table of Contents Kafka Producer Architecture Overview What Happens When send() is Called Delivery Semantics Kafka Transactions & Idempotence Error Handling and Retries Diagram: Kafka Producer Internals Conclusion 🏗️ Kafka Producer Architecture Overview Kafka Producer is composed of the following core components: Serializer : Converts key/value to bytes. Partitioner : Determines which partition a record should go to. Accumulator : Buffers the records in memory befor...

Project Reactor vs Java Virtual Threads: Which One to Choose for High-Concurrency Applications?

If you're building a high-concurrency Java backend —say, something that handles millions of requests per second —you’ve likely faced the dilemma: Should I use Project Reactor (Reactive Streams) or Java Virtual Threads (Project Loom)? After working with both, here’s a deep dive comparison that can help you decide. 🔧 What Are They? Project Reactor (Spring WebFlux) Asynchronous, event-driven, non-blocking model. Built on Mono and Flux , part of the reactive ecosystem. Ideal for streaming data and backpressure handling. Java Virtual Threads (JDK 21+) Lightweight threads, launched like regular threads ( Thread.ofVirtual() ). Enable writing traditional blocking code that scales like async. Great for simplifying code without compromising concurrency. ⚔️ Key Differences Feature Project Reactor Java Virtual Threads Programming Style Callback-based (Reactive) Imperative (Synchronous) Blocking I/O Not allowed (must use non-blocking APIs) Allowed (eff...