<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sanu Kumar Chaudhary on Medium]]></title>
        <description><![CDATA[Stories by Sanu Kumar Chaudhary on Medium]]></description>
        <link>https://medium.com/@sanukchaudhary?source=rss-2be31e93bdad------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*cE2v7OQgHFaO7kdp</url>
            <title>Stories by Sanu Kumar Chaudhary on Medium</title>
            <link>https://medium.com/@sanukchaudhary?source=rss-2be31e93bdad------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 17:03:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sanukchaudhary/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Apache Kafka Basics: How It Works]]></title>
            <link>https://medium.com/@sanukchaudhary/apache-kafka-basics-how-it-works-90c9ff73f3c6?source=rss-2be31e93bdad------2</link>
            <guid isPermaLink="false">https://medium.com/p/90c9ff73f3c6</guid>
            <category><![CDATA[kafka-consumer-group]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[kafka-producer]]></category>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[kafka-consumer]]></category>
            <dc:creator><![CDATA[Sanu Kumar Chaudhary]]></dc:creator>
            <pubDate>Tue, 20 Oct 2026 17:58:04 GMT</pubDate>
            <atom:updated>2026-10-20T17:58:04.534Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8FGVLMzQIv0wYWrwc3un7A.png" /><figcaption>Apache Kafka Basics: How It Works</figcaption></figure><p>Consider an e-commerce application. Whenever a customer places an order, the application generates an event. The inventory service needs that event to update stock, the notification service needs it to notify the customer, and the analytics service needs it to track sales.</p><p>One way to build this system is to make the order service communicate directly with every application that needs the data. But as the number of applications grows, managing these connections becomes increasingly complicated.</p><p>Kafka offers another approach. Applications publish events to Kafka, and other applications consume those events independently.</p><p>To understand how this works, let’s follow an event through Kafka and explore the components involved.</p><h3>1. Producers, consumers, and events</h3><p>Let’s start with three basic concepts.</p><p>A <strong>producer</strong> is an application that publishes events to Kafka. A <strong>consumer</strong> is an application that reads and processes those events.</p><p>An <strong>event</strong> represents something that happened. For example, when a customer places an order, the application might publish an <strong>OrderCreated</strong> event containing data such as the order ID, customer ID, and order details.</p><p>The producer doesn’t need to know which applications will eventually consume that event. It simply publishes the event to Kafka.</p><p>This separation allows producers and consumers to operate independently. The inventory service can process orders, while the analytics service reads the same stream for reporting.</p><p>But this leads to an important question: if producers can publish millions of events, how does Kafka organize them?</p><h3>2. Topics and records: Organizing events</h3><p>Kafka organizes events into categories called <strong>topics</strong>.</p><p>For example, an e-commerce application might have topics named <em>orders</em>, <em>payments</em>, and <em>shipments</em>. Each topic represents a particular stream of related events.</p><p>An individual event stored in Kafka is called a <strong>record</strong>. A record can contain a key, a value, a timestamp, and optional headers.</p><p>When an order is placed, the producer might publish a record to the <em>orders</em> topic with the order ID as its key and the order details as its value.</p><p>The topic gives the event a place in the system, but it doesn’t tell us exactly how the event is stored.</p><p>To understand that, we need to look at partitions.</p><h3>3. Partitions: How Kafka organizes and scales data</h3><p>A topic can contain millions or billions of records. Storing and processing all those records through a single log would limit how much work could be distributed across machines.</p><p>Kafka addresses this by dividing a topic into <strong>partitions</strong>.</p><p>Each partition is an ordered log to which records are appended. A topic with three partitions might look like this:</p><pre>Topic: orders<br>Partition 0: [Record A] → [Record D] → [Record G]<br>Partition 1: [Record B] → [Record E] → [Record H]<br>Partition 2: [Record C] → [Record F] → [Record I]</pre><p>These are three separate sequences of records. Kafka preserves the order of records within each partition, but it does not guarantee a single global order across all partitions.</p><p>Why is this useful?</p><p>Partitions allow Kafka to distribute data across multiple servers and let different consumers process different portions of a topic concurrently. Instead of relying on one machine to handle everything, Kafka can spread storage and processing across a cluster.</p><p>Partitions also affect ordering. If events for the same order must be processed in sequence, the producer can use the order ID as the record key. With the usual key-based partitioning strategy, records with the same key are routed to the same partition, provided the partitioning configuration remains compatible.</p><p>Partitions therefore help Kafka balance two important requirements: scalability and ordered processing.</p><p>But where are these partitions actually stored?</p><h3>4. Brokers and clusters: Where the data lives</h3><p>A <strong>broker</strong> is a Kafka server that stores and serves partitions. A <strong>cluster</strong> is a group of Kafka brokers working together.</p><p>When a topic is created, its partitions are assigned to brokers. A cluster might distribute the partitions of the <em>orders</em> topic across several servers.</p><p>Distributing partitions across brokers allows Kafka to spread storage and request-handling work across multiple servers, increasing the cluster’s potential capacity.</p><p>Kafka can also replicate partitions across brokers. A partition’s leader handles normal reads and writes, while its replicas provide redundancy according to the cluster’s replication configuration. Replication helps Kafka remain available and protect data when a broker fails.</p><p>So far, we have seen how producers publish records, how topics organize them, how partitions divide the data, and how brokers store it.</p><p>The next question is just as important: how does an application read those records without interfering with other applications?</p><h3>5. Consumers and offsets: Reading records</h3><p>Kafka consumers read records by requesting data from brokers. This is commonly described as a pull model: consumers fetch batches of records when they are ready to process them.</p><p>Unlike a system that necessarily removes a message after delivery, Kafka retains records according to its retention policy. Reading a record does not ordinarily delete it.</p><p>This makes it possible for a consumer to read the same retained records again when needed.</p><p>But how does Kafka know where a consumer should continue reading?</p><p>The answer is an <strong>offset</strong>.</p><p>An offset identifies a record’s position within a particular partition. As a consumer reads records, it tracks its progress through the log. Consumers can periodically commit offsets so that they can resume from a saved position after restarting.</p><p>For example, suppose a consumer has processed the first 500 records in a partition, and it went down for some reason.</p><p>After restarting, the consumer can resume from its committed offset rather than starting from the beginning.</p><p>A consumer can also reset its position to an earlier offset to reprocess retained data. This is useful when rebuilding a downstream system or recovering from a processing bug.</p><p>Reading previously retained records again is commonly called <strong>replaying events</strong>.</p><p>Notice that the offset belongs to a partition, not to the topic as a whole. Offset 100 in one partition is unrelated to offset 100 in another.</p><p>This ability to track progress independently is one of the ideas that makes Kafka useful for event streaming.</p><p>However, a single consumer may eventually struggle to keep up with a growing stream. Kafka offers another mechanism to help: <strong>consumer groups</strong>.</p><h3>6. Consumer groups: Scaling consumption</h3><p>A <strong>consumer group</strong> is a set of consumers that coordinate to consume records from a topic.</p><p>Within a traditional consumer group, Kafka assigns each partition to at most one group member at a time. A consumer can own multiple partitions, but two consumers in the same group do not simultaneously own the same partition under this assignment model.</p><p>Imagine the <em>orders</em> topic has three partitions and a consumer group has two consumers.</p><p>One consumer might handle partitions 0 and 1, while the other handles partition 2. The group can therefore process different partitions in parallel.</p><p>If the group has more consumers than partitions, some consumers will remain unassigned and idle for that topic. This is why the number of partitions places an upper bound on the number of simultaneously active consumers in a traditional consumer group for that topic.</p><p>Consumer groups also provide a way for independent applications to read the same events.</p><p>Suppose the inventory service uses one consumer group and the analytics service uses another. Both groups can read the <em>orders </em>topic independently, and each maintains its own progress.</p><p>The inventory service can process an order without advancing the analytics service’s offset. Similarly, the analytics service can replay retained events without requiring the inventory service to repeat its work.</p><p>Each consumer groups track their progress independently by maintaining their own offset, so processing an event in one group does not advance the other group’s committed offset.</p><p>This gives Kafka a useful combination: consumers within a group can share the processing workload, while different groups can independently consume the same event stream.</p><h3>7. Bringing everything together</h3><p>Let’s follow an <em>OrderCreated</em> event through the system.</p><p>First, the order service acts as a producer and publishes a record to the <em>orders</em> topic.</p><p>Kafka routes the record to one of the topic’s partitions. A broker hosting that partition appends the record to its log and serves it to consumers that fetch data from that partition.</p><p>The inventory and analytics services consume the record through their respective consumer groups. Each group tracks its own progress using offsets.</p><p>As the volume of orders increases, the topic’s partitions can be distributed across brokers, and additional consumers can help process the workload, provided enough partitions and resources are available.</p><p>The important point is that these components aren’t isolated features. They work together to form one system.</p><p>Producers publish events. Topics organize them. Partitions provide ordered logs that can be distributed. Brokers store and serve those logs. Consumers read the records, offsets track their progress, and consumer groups coordinate parallel processing.</p><h3>Conclusion</h3><p>Kafka is more than a mechanism for sending messages between applications. It provides a distributed way to store and consume event streams.</p><p>Its design allows producers and consumers to remain relatively independent, lets multiple applications read the same retained data, and supports scaling through partitions and consumer groups.</p><p>Once you understand how these pieces fit together, Kafka becomes easier to reason about. Instead of memorizing a list of terms, you can follow the journey of an event and understand why each component exists.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90c9ff73f3c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>