<?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 Prataparao SaiVamsi on Medium]]></title>
        <description><![CDATA[Stories by Prataparao SaiVamsi on Medium]]></description>
        <link>https://medium.com/@prataparao.saivamsi?source=rss-99aaf3a0a9d6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Prataparao SaiVamsi on Medium</title>
            <link>https://medium.com/@prataparao.saivamsi?source=rss-99aaf3a0a9d6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 20:59:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prataparao.saivamsi/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[Internal Working of ConcurrentHashMap in Java: A Complete Guide]]></title>
            <link>https://medium.com/@prataparao.saivamsi/internal-working-of-concurrenthashmap-in-java-a-complete-guide-22216203e40f?source=rss-99aaf3a0a9d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/22216203e40f</guid>
            <category><![CDATA[concurrenthashmap]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Prataparao SaiVamsi]]></dc:creator>
            <pubDate>Tue, 13 Oct 2026 02:31:02 GMT</pubDate>
            <atom:updated>2026-10-13T02:31:02.224Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever wondered what happens when multiple threads try to read and update the same Map simultaneously?</p><p>Consider the following example:</p><pre>Map&lt;String, Integer&gt; map = new HashMap&lt;&gt;();<br>map.put(&quot;Java&quot;, 1);</pre><p>This works perfectly fine in a single-threaded application. But what happens when multiple threads access the same map and modify it concurrently?</p><p>Without proper synchronization, concurrent modifications can lead to race conditions, lost updates, and inconsistent application behavior.</p><p>Java provides a powerful solution for this problem: ConcurrentHashMap.</p><p>Unlike a regular HashMap, ConcurrentHashMap is designed to support concurrent access while maintaining thread safety and good performance.</p><p>But how does it work internally? Does it lock the entire map? Does it use synchronized methods? How can multiple threads operate on the same data structure efficiently?</p><p>Let’s explore the internal working of ConcurrentHashMap step by step.</p><h3>1. What Is ConcurrentHashMap?</h3><p>ConcurrentHashMap is a thread-safe implementation of the ConcurrentMap interface in the Java Collections Framework.</p><p>It allows multiple threads to access and modify a map concurrently without requiring callers to synchronize every operation manually.</p><p>Example:</p><pre>import java.util.concurrent.ConcurrentHashMap;<br>import java.util.concurrent.ConcurrentMap;<br><br>public class Main {<br>    public static void main(String[] args) {<br>        ConcurrentMap&lt;String, Integer&gt; map =<br>                new ConcurrentHashMap&lt;&gt;();<br>        map.put(&quot;Java&quot;, 1);<br>        map.put(&quot;Spring&quot;, 2);<br>        System.out.println(map.get(&quot;Java&quot;));<br>    }<br>}</pre><p>Output:</p><pre>1</pre><p>Some important characteristics include:</p><ul><li>It is designed for concurrent access.</li><li>Multiple threads can read and update the map concurrently.</li><li>It does not allow null keys or values.</li><li>It provides thread-safe individual operations.</li><li>It offers atomic operations such as putIfAbsent(), compute(), and replace().</li><li>It does not guarantee iteration in insertion order.</li></ul><p>One important distinction: thread-safe individual operations do not automatically make a sequence of multiple operations atomic.</p><p>For example, checking whether a key exists and then inserting it in separate calls can still introduce a race condition. Use an atomic map operation when the logic requires one.</p><h3>2. Why Do We Need ConcurrentHashMap?</h3><p>Let’s understand the problem using a shared counter.</p><p>Imagine two threads updating a shared value.</p><pre>Map&lt;String, Integer&gt; map = new HashMap&lt;&gt;();<br><br>map.put(&quot;count&quot;, 0);</pre><p>Both threads execute:</p><pre>int count = map.get(&quot;count&quot;);<br>map.put(&quot;count&quot;, count + 1);</pre><p>Suppose both threads read the value 0 before either writes the result.</p><p>The execution could look like this:</p><pre>Thread 1 reads count = 0<br>Thread 2 reads count = 0<br><br>Thread 1 writes count = 1<br>Thread 2 writes count = 1</pre><p>The final value is 1, even though two increments were attempted.</p><p>This is a lost-update problem.</p><p>A regular HashMap does not provide the synchronization needed to make this compound operation safe.</p><p>With ConcurrentHashMap, you can use an atomic update:</p><pre>ConcurrentHashMap&lt;String, Integer&gt; map =<br>        new ConcurrentHashMap&lt;&gt;();<br><br>map.put(&quot;count&quot;, 0);<br>map.merge(&quot;count&quot;, 1, Integer::sum);</pre><p>The merge() operation atomically updates the mapping for the key.</p><p>If two threads each call merge(&quot;count&quot;, 1, Integer::sum), both increments are applied, assuming no other operations interfere with the intended counter logic.</p><p>This illustrates an important principle: choosing a concurrent collection is only part of writing correct concurrent code. You must also choose appropriate atomic operations.</p><h3>3. Internal Data Structure of ConcurrentHashMap</h3><p>Like HashMap, modern ConcurrentHashMap implementations use a table of buckets.</p><p>Each bucket can contain a node with a key, value, hash, and reference to another node.</p><p>A simplified node looks like this:</p><pre>static class Node&lt;K, V&gt; {<br>    final int hash;<br>    final K key;<br>    volatile V val;<br>    volatile Node&lt;K, V&gt; next;<br>}</pre><p>This is a conceptual representation of the node structure in modern OpenJDK implementations, not a complete copy of the source code.</p><p>The important fields are:</p><ul><li>hash: Helps determine the bucket.</li><li>key: Stores the key.</li><li>val: Stores the associated value.</li><li>next: Links nodes when multiple entries occupy the same bucket.</li></ul><p>Conceptually:</p><pre>ConcurrentHashMap<br>        |<br>        v<br>   Bucket Array<br>        |<br>        +---- Bucket 0: null<br>        |<br>        +---- Bucket 1: Node A -&gt; Node B<br>        |<br>        +---- Bucket 2: Node C<br>        |<br>        +---- Bucket 3: null</pre><p>When two keys map to the same bucket, collision handling becomes necessary.</p><p>However, the most important difference from HashMap is how concurrent operations are coordinated.</p><h3>4. How Does ConcurrentHashMap Achieve Thread Safety?</h3><p>The internal implementation has evolved across Java versions.</p><p>In Java 7, ConcurrentHashMap used a segmented design. The map was divided into segments, and each segment managed part of the data with its own locking mechanism.</p><p>Starting with Java 8, the implementation moved away from the segment-based design.</p><p>Modern OpenJDK implementations primarily use:</p><ul><li>CAS operations for certain updates.</li><li>Synchronization on individual bucket heads for many competing updates.</li><li>Volatile fields and other memory-ordering mechanisms.</li><li>Cooperative resizing when the table grows.</li></ul><p>CAS stands for Compare-And-Swap. It is an atomic operation that updates a memory location only if its current value matches an expected value.</p><h3>What is CAS?</h3><p>Suppose a thread wants to change a bucket from null to a new node.</p><p>Conceptually, it performs an operation like this:</p><pre>Expected value: null<br>New value:      Node A<br><br>If current value is still null:<br>    Replace null with Node A<br>Otherwise:<br>    Retry or follow another update path</pre><p>The operation succeeds only if the bucket still contains the expected value.</p><p>This allows certain updates to occur without acquiring a traditional lock.</p><p>CAS alone does not make the entire map lock-free. Different operations use different coordination strategies, and some updates use synchronization.</p><h3>Why not lock the entire map?</h3><p>Imagine a map containing thousands of entries.</p><p>If every write operation locked the entire map, one thread updating a key could prevent another thread from updating a completely unrelated key.</p><p>Fine-grained coordination allows unrelated operations to proceed concurrently when they do not contend for the same internal resources.</p><p>That is one of the key design ideas behind modern ConcurrentHashMap.</p><h3>5. What Happens Internally During put()?</h3><p>Let’s examine this operation:</p><pre>map.put(&quot;Java&quot;, 100);</pre><p>The insertion process can be simplified into the following steps.</p><h3>Step 1: Validate the key and value</h3><p>ConcurrentHashMap does not allow null keys or values.</p><p>Therefore, inserting a null key or value results in a NullPointerException.</p><pre>map.put(null, 100); // Throws NullPointerException<br>map.put(&quot;Java&quot;, null); // Throws NullPointerException</pre><p>Rejecting null values also helps make a null result from get() unambiguous: the map has no mapping for that key at the time of the lookup.</p><h3>Step 2: Calculate the hash</h3><p>The map calculates a hash from the key’s hashCode() and applies an internal spreading function.</p><h3>Step 3: Calculate the bucket index</h3><p>The hash and current table capacity determine the bucket index.</p><p>Conceptually:</p><pre>index = (table.length - 1) &amp; hash;</pre><h3>Step 4: Check the bucket</h3><p>If the bucket is empty, the implementation can attempt to install a new node using CAS.</p><p>If another thread wins the race and inserts a node first, the current thread must retry or follow the appropriate update path.</p><h3>Step 5: Handle an existing bucket</h3><p>If the bucket is already occupied, the implementation coordinates updates to that bucket.</p><p>For an ordinary linked-list bucket, this commonly involves synchronizing on the first node and checking that the bucket has not changed before proceeding.</p><p>The implementation then searches for an equal key.</p><ul><li>If the key exists, its value can be updated.</li><li>If the key is new, a new node can be added.</li><li>If the bucket is represented by a tree, tree-specific logic is used.</li></ul><h3>Step 6: Handle resizing if needed</h3><p>If the table reaches its resizing threshold, threads can participate in the resizing process.</p><p>This cooperative design allows the map to grow while coordinating concurrent updates.</p><p>The actual source code includes additional checks and special cases, but these steps explain the main idea.</p><h3>6. How Does get() Work Internally?</h3><p>One of the strengths of ConcurrentHashMap is its efficient retrieval path.</p><p>Consider:</p><pre>Integer value = map.get(&quot;Java&quot;);</pre><p>The lookup generally works as follows:</p><ol><li>Calculate the key’s hash.</li><li>Determine the appropriate bucket.</li><li>Read the bucket’s first node.</li><li>Check whether the node matches the requested key.</li><li>If necessary, traverse the linked nodes or search a tree bin.</li><li>Return the associated value, or null if no mapping is found.</li></ol><p>Ordinary retrievals generally do not require acquiring a bucket lock.</p><p>The implementation uses appropriate memory-access mechanisms so that concurrent updates and reads follow Java’s memory model.</p><p>This is why ConcurrentHashMap can support many readers efficiently while other threads update the map.</p><p>However, an individual retrieval is not a promise that several successive reads will observe one unchanged global snapshot. The map can change between operations.</p><h3>7. How Does ConcurrentHashMap Handle Collisions?</h3><p>A hash collision occurs when different keys map to the same bucket.</p><p>For example:</p><pre>Bucket 3<br>   |<br>   v<br>Node A -&gt; Node B -&gt; Node C</pre><p>Modern OpenJDK implementations can use linked nodes or tree bins to manage collisions.</p><p>When a bucket becomes heavily populated and the table is sufficiently large, the implementation can convert the bucket into a tree structure.</p><p>This helps reduce the cost of searching a heavily populated bucket.</p><p>The precise conversion rules and internal constants are implementation details, so they should be checked against the source code of the Java version you are using.</p><p>The important point is that collision handling and thread coordination must work together: concurrent updates cannot simply modify a shared linked list or tree without suitable synchronization.</p><h3>8. How Does Resizing Work in ConcurrentHashMap?</h3><p>As entries are added, the internal table may need to grow.</p><p>For example:</p><pre>Before resizing:<br>Capacity = 16<br><br>After resizing:<br>Capacity = 32</pre><p>Unlike a simplistic design in which one thread must perform all the work while others wait, modern OpenJDK ConcurrentHashMap can use cooperative resizing.</p><p>A simplified process looks like this:</p><ol><li>A thread detects that resizing is needed.</li><li>A larger table is allocated.</li><li>Threads may help transfer entries from the old table to the new table.</li><li>Special forwarding nodes can indicate that a bucket is being transferred.</li><li>Operations encountering transferred buckets can follow the appropriate path to continue working with the new table.</li></ol><p>This coordination is one of the more complex aspects of the implementation.</p><p>The benefit is that resizing can be shared among participating threads rather than being treated as one indivisible task performed entirely by a single thread.</p><p>That does not mean resizing is free: it still consumes CPU time and memory bandwidth.</p><p>If the approximate number of entries is known in advance, choosing a suitable initial capacity can help reduce repeated growth.</p><h3>9. What Are Atomic Operations in ConcurrentHashMap?</h3><p>Thread-safe individual methods are useful, but atomic compound operations are even more important.</p><p>Consider the following code:</p><pre>if (!map.containsKey(&quot;Java&quot;)) {<br>    map.put(&quot;Java&quot;, 100);<br>}</pre><p>This is not atomic.</p><p>Two threads could both observe that the key is absent before either inserts it.</p><p>A better approach is:</p><pre>map.putIfAbsent(&quot;Java&quot;, 100);</pre><p>This performs the check-and-insert operation atomically.</p><p>Other useful operations include:</p><h3>replace()</h3><pre>map.replace(&quot;Java&quot;, 200);</pre><p>Replaces the value only if the key is already present.</p><h3>computeIfAbsent()</h3><pre>map.computeIfAbsent(&quot;Java&quot;, key -&gt; 100);</pre><p>Computes a value for a key if it is absent and installs the result according to the method’s atomic semantics.</p><h3>merge()</h3><pre>map.merge(&quot;count&quot;, 1, Integer::sum);</pre><p>Adds a mapping if the key is absent or combines the existing value with the supplied value.</p><p>These methods are particularly useful when implementing caches, counters, frequency maps, and shared registries.</p><p>Keep computation functions short and avoid recursive or complex updates to the same map from within these callbacks.</p><h3>10. ConcurrentHashMap vs HashMap</h3><p>Let’s compare the two implementations.</p><p>FeatureHashMapConcurrentHashMapThread-safe operationsNoYesAllows null keyYes, oneNoAllows null valuesYesNoConcurrent readsNot a concurrency guaranteeDesigned to support themConcurrent updatesRequires external coordination when sharedBuilt-in coordinationAtomic compound methodsLimited to ordinary map semanticsProvides methods such as putIfAbsent() and compute()IteratorsFail-fast on a best-effort basisWeakly consistentTypical use caseSingle-threaded or externally synchronized accessShared maps accessed concurrently</p><p>The most important lesson is that these classes serve different purposes.</p><p>Use HashMap when concurrent access is not required or when suitable external synchronization is already provided.</p><p>Use ConcurrentHashMap when multiple threads need to access and update a shared map concurrently.</p><h3>11. Are ConcurrentHashMap Iterators Thread-Safe?</h3><p>ConcurrentHashMap iterators are weakly consistent.</p><p>This means they can operate while the map is being modified by other threads without throwing ConcurrentModificationException merely because of those concurrent changes.</p><p>However, they are not snapshot iterators.</p><p>An iterator may reflect some updates that occur after iteration begins, but it is not guaranteed to reflect every concurrent modification.</p><p>Example:</p><pre>ConcurrentHashMap&lt;String, Integer&gt; map =<br>        new ConcurrentHashMap&lt;&gt;();<br>map.put(&quot;Java&quot;, 1);<br>map.put(&quot;Spring&quot;, 2);<br>for (String key : map.keySet()) {<br>    System.out.println(key);<br>}</pre><p>Other threads can modify the map while this loop runs.</p><p>The iteration remains safe, but you should not assume that the loop observes one perfectly consistent snapshot of all entries.</p><p>If an application requires a stable snapshot, it needs a separate strategy appropriate to its consistency requirements.</p><h3>12. Is ConcurrentHashMap Completely Lock-Free?</h3><p>No.</p><p>This is a common misconception.</p><p>Modern implementations use CAS for certain operations and avoid locking for many retrievals, but some updates use synchronization.</p><p>For example, competing insertions into an occupied bucket may need to coordinate through a lock associated with that bucket’s first node.</p><p>Therefore, it is more accurate to say that ConcurrentHashMap uses a combination of lock-free techniques and fine-grained synchronization rather than describing the entire implementation as lock-free.</p><p>This distinction matters because performance depends on workload characteristics.</p><p>If many threads repeatedly update the same key or contend for the same bucket, contention can still occur.</p><p>Good key distribution and appropriate data modeling remain important.</p><h3>13. When Should You Use ConcurrentHashMap?</h3><p>Here are several practical use cases.</p><h3>1. Application-level caches</h3><p>Store frequently accessed data that multiple threads need to retrieve.</p><pre>ConcurrentHashMap&lt;String, User&gt; cache =<br>        new ConcurrentHashMap&lt;&gt;();</pre><p>For more advanced cache requirements, such as expiration, eviction, and refresh, a dedicated caching library may be a better choice.</p><h3>2. Counting events</h3><pre>ConcurrentHashMap&lt;String, Integer&gt; counts =<br>        new ConcurrentHashMap&lt;&gt;();<br>counts.merge(&quot;LOGIN&quot;, 1, Integer::sum);<br>counts.merge(&quot;PURCHASE&quot;, 1, Integer::sum);</pre><p>This provides atomic per-key increments, though very high-frequency counters may benefit from specialized alternatives.</p><h3>3. Shared configuration or registries</h3><p>Store mappings such as service names to service instances, or identifiers to shared resources.</p><h3>4. Frequency counting</h3><pre>String[] words = {&quot;java&quot;, &quot;spring&quot;, &quot;java&quot;};<br><br>ConcurrentHashMap&lt;String, Integer&gt; frequency =<br>        new ConcurrentHashMap&lt;&gt;();<br>for (String word : words) {<br>    frequency.merge(word, 1, Integer::sum);<br>}</pre><p>This example is sequential, but the same atomic update method can be used when several threads process words concurrently.</p><h3>14. Important ConcurrentHashMap Interview Questions</h3><p><strong>Q1. Why is ConcurrentHashMap preferred over HashMap in multithreaded applications?</strong></p><p>It provides thread-safe map operations and supports concurrent access without requiring callers to synchronize the entire map for every operation.</p><p><strong>Q2. Does ConcurrentHashMap allow null keys or values?</strong></p><p>No. Both are prohibited.</p><p><strong>Q3. Is ConcurrentHashMap completely lock-free?</strong></p><p>No. It uses CAS for some updates, synchronization for certain competing updates, and other coordination mechanisms.</p><p><strong>Q4. What changed in Java 8?</strong></p><p>The OpenJDK implementation moved away from the earlier segmented design toward bucket-level coordination, CAS-based updates, tree bins, and cooperative resizing.</p><p><strong>Q5. Are reads blocked by writes?</strong></p><p>Ordinary reads generally do not acquire bucket locks, but they may observe changes as operations proceed. This does not mean every possible operation is free from contention.</p><p><strong>Q6. What is the difference between </strong><strong>putIfAbsent() and </strong><strong>put()?</strong></p><p>put() inserts or replaces a mapping. putIfAbsent() inserts only if the key is currently absent.</p><p><strong>Q7. What does weakly consistent iteration mean?</strong></p><p>An iterator can continue while concurrent modifications occur, but it does not represent a guaranteed snapshot of the map.</p><p><strong>Q8. Can ConcurrentHashMap store duplicate keys?</strong></p><p>No. It maintains at most one mapping for each key according to its equality rules.</p><p><strong>Q9. Is ConcurrentHashMap suitable for every concurrent problem?</strong></p><p>No. It is useful for shared key-value mappings, but compound workflows, global invariants, ordering requirements, and snapshot consistency may require additional coordination.</p><h3>Conclusion</h3><p>ConcurrentHashMap is one of the most important collections for Java developers working with multithreaded applications.</p><p>Its efficiency comes from combining several techniques:</p><ul><li>Hash-based bucket indexing.</li><li>CAS operations for certain updates.</li><li>Fine-grained synchronization for competing modifications.</li><li>Efficient retrievals that generally avoid bucket locks.</li><li>Tree bins for heavily populated buckets.</li><li>Cooperative resizing.</li><li>Atomic operations such as putIfAbsent(), compute(), and merge().</li></ul><p>Understanding these mechanisms helps you select the right collection, write safer concurrent code, and reason about performance under contention.</p><p>Remember: thread safety is not just about preventing exceptions. It is about ensuring that concurrent operations behave according to the guarantees your application actually needs.</p><p>The next time you build a shared cache, counter, or registry in Java, consider whether ConcurrentHashMap is the right tool for the job.</p><p><strong>If you enjoyed this deep dive into Java internals, follow along for more articles on JVM internals, multithreading, collections, and backend engineering.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22216203e40f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Internal Working of HashMap: A Complete Guide]]></title>
            <link>https://medium.com/@prataparao.saivamsi/internal-working-of-hashmap-a-complete-guide-534b2c17ead7?source=rss-99aaf3a0a9d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/534b2c17ead7</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[hashmap-internal-working]]></category>
            <dc:creator><![CDATA[Prataparao SaiVamsi]]></dc:creator>
            <pubDate>Mon, 12 Oct 2026 15:22:09 GMT</pubDate>
            <atom:updated>2026-10-12T15:22:09.834Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever wondered what happens internally when you write the following line of Java code?</p><pre>Map&lt;String, Integer&gt; map = new HashMap&lt;&gt;();<br>map.put(&quot;Apple&quot;, 100);<br>map.put(&quot;Banana&quot;, 200);<br>System.out.println(map.get(&quot;Apple&quot;));</pre><p>The output is simple:</p><pre>100</pre><p>But behind this simple operation, Java performs several steps involving hashing, array indexing, collision handling, and sometimes even converting linked lists into balanced trees.</p><p>Understanding these internal mechanisms helps you write better Java code, troubleshoot performance issues, and confidently answer Java interview questions.</p><p>In this article, we’ll explore the internal working of Java’s HashMap step by step.</p><h3>1. What Is HashMap?</h3><p>HashMap is a class in the Java Collections Framework that stores data in key-value pairs.</p><pre>HashMap&lt;String, Integer&gt; map = new HashMap&lt;&gt;();<br>map.put(&quot;Java&quot;, 1);<br>map.put(&quot;Python&quot;, 2);<br>map.put(&quot;JavaScript&quot;, 3);</pre><p>Here, each key maps to a corresponding value.</p><p>Some important characteristics of HashMap are:</p><ul><li>It stores data as key-value pairs.</li><li>It allows one null key and multiple null values.</li><li>It does not guarantee iteration order.</li><li>It is not thread-safe by default.</li><li>It provides expected constant-time performance for basic operations such as get() and put(), assuming a good distribution of hash values.</li></ul><p>Now, let’s look at how it works internally.</p><h3>2. Internal Data Structure of HashMap</h3><p>Internally, Java’s HashMap uses an array of buckets. Each bucket can contain a node holding a key, value, hash, and reference to the next node.</p><p>Conceptually, a node looks like this:</p><pre>static class Node&lt;K, V&gt; {<br>    final int hash;<br>    final K key;<br>    V value;<br>    Node&lt;K, V&gt; next;<br>}</pre><p>This is a simplified representation of the node structure used by modern Java implementations.</p><p>The important fields are:</p><ul><li>hash: Stores the hash value calculated for the key.</li><li>key: Stores the actual key.</li><li>value: Stores the associated value.</li><li>next: Points to another node when multiple entries occupy the same bucket.</li></ul><p>A simplified representation of the bucket array looks like this:</p><pre>HashMap<br>   |<br>   v<br>Bucket Array<br>+-------+------------------+<br>| Index | Contents         |<br>+-------+------------------+<br>|   0   | null             |<br>|   1   | Node A -&gt; Node B |<br>|   2   | null             |<br>|   3   | Node C           |<br>|   4   | null             |<br>+-------+------------------+</pre><p>When multiple keys map to the same bucket, their entries must be managed within that bucket.</p><p>This brings us to one of the most important concepts in HashMap: hashing.</p><h3>3. How Does Hashing Work?</h3><p>When you insert a key into a HashMap, Java calculates a hash value for that key.</p><p>For example:</p><pre>map.put(&quot;Apple&quot;, 100);</pre><p>Java calls the key’s hashCode() method to obtain its hash code.</p><p>Conceptually:</p><pre>int hashCode = key.hashCode();</pre><p>However, modern OpenJDK implementations of HashMap transform the hash code before using it to calculate the bucket index.</p><p>The implementation uses a function equivalent to:</p><pre>static final int hash(Object key) {<br>    int h;<br>    return (key == null)<br>            ? 0<br>            : (h = key.hashCode()) ^ (h &gt;&gt;&gt; 16);<br>}</pre><p>The expression h ^ (h &gt;&gt;&gt; 16) mixes the upper 16 bits of the hash code into the lower 16 bits.</p><p>Why is this necessary?</p><p>Because the bucket index is calculated using a limited number of bits. Mixing bits helps information from the upper portion of a hash code influence the resulting index.</p><p>This can improve bucket distribution for certain hash-code patterns.</p><h3>How is the bucket index calculated?</h3><p>For a table whose capacity is a power of two, Java calculates the index using:</p><pre>int index = (capacity - 1) &amp; hash;</pre><p>For example, if the capacity is 16:</p><pre>capacity       = 16<br>capacity - 1   = 15<br>binary         = 00001111</pre><p>The hash value is combined with this mask using the bitwise AND operator.</p><pre>Bucket Index = (Capacity - 1) &amp; Hash</pre><p>This operation efficiently determines which bucket should hold the entry.</p><p><strong>Important:</strong> The hash code is not itself the bucket index. The bucket index is derived from the hash and the current table capacity.</p><h3>4. What Happens Internally During put()?</h3><p>Let’s understand the insertion process using a simple example.</p><pre>HashMap&lt;String, Integer&gt; map = new HashMap&lt;&gt;();<br>map.put(&quot;Apple&quot;, 100);</pre><p>The process can be broken down into several steps.</p><h3>Step 1: Calculate the hash</h3><p>Java calculates the hash of the key using hashCode() and the internal hash-spreading function.</p><h3>Step 2: Initialize the bucket array if necessary</h3><p>A newly created HashMap does not immediately allocate its bucket array.</p><pre>HashMap&lt;String, Integer&gt; map = new HashMap&lt;&gt;();</pre><p>In common OpenJDK implementations, the internal table is allocated when the first insertion requires it.</p><h3>Step 3: Calculate the bucket index</h3><p>Java calculates the bucket index using the hash and the current table capacity.</p><pre>index = (capacity - 1) &amp; hash;</pre><h3>Step 4: Check whether the bucket is empty</h3><p>If the bucket is empty, Java inserts a new node into that position.</p><pre>Before insertion:<br><br>Bucket Array<br>+-------+<br>|   0   | null |<br>|   1   | null |<br>|   2   | null |<br>|   3   | null |<br>+-------+<br><br>After insertion:<br><br>Bucket Array<br>+-------+<br>|   0   | null |<br>|   1   | Apple|<br>|   2   | null |<br>|   3   | null |<br>+-------+</pre><p>The bucket index shown here is illustrative.</p><h3>Step 5: Handle an existing entry or collision</h3><p>If the bucket already contains a node, Java checks whether the new key matches an existing key.</p><p>It first compares hashes and then checks key identity or equality.</p><p>If the key already exists, the corresponding value is updated.</p><pre>map.put(&quot;Apple&quot;, 150);</pre><p>Now the value associated with &quot;Apple&quot; is 150, not 100.</p><p>If the key is different but maps to the same bucket, Java handles the collision.</p><p>We’ll explore collision handling next.</p><h3>Step 6: Check whether resizing is required</h3><p>After adding a new mapping, Java checks whether the map has exceeded its applicable threshold.</p><p>If necessary, it resizes the bucket array.</p><p>We’ll discuss this in detail later.</p><h3>5. What Is a Hash Collision?</h3><p>A hash collision occurs when different keys map to the same bucket.</p><p>For example:</p><pre>Bucket Array<br>+-------+-----------------------+<br>| Index | Contents              |<br>+-------+-----------------------+<br>|   0   | null                  |<br>|   1   | Apple -&gt; Mango -&gt; ... |<br>|   2   | null                  |<br>|   3   | Banana                |<br>+-------+-----------------------+</pre><p>Here, &quot;Apple&quot; and &quot;Mango&quot; represent different keys that happen to occupy the same bucket.</p><p>A collision does not necessarily mean that the two keys have identical hash codes. Different hash codes can also map to the same bucket index.</p><p>Java’s HashMap handles collisions primarily through linked nodes and, under certain conditions, balanced trees.</p><h3>Collision handling using a linked list</h3><p>Initially, entries in the same bucket can be connected as a linked list.</p><pre>Bucket[1]<br>   |<br>   v<br>+-------+-------+------+<br>| Apple |  100  | next | ---&gt; <br>+-------+-------+------+<br>                              |<br>                              v<br>                     +-------+-------+------+<br>                     | Mango |  200  | null |<br>                     +-------+-------+------+</pre><p>When searching for a key, Java traverses the nodes in the bucket and compares candidate keys.</p><p>As the number of entries in a bucket increases, a linked list can make lookup slower because more nodes may need to be examined.</p><p>To improve performance in heavily populated buckets, modern Java implementations can convert a linked list into a balanced tree.</p><h3>6. What Is Treeification in HashMap?</h3><p>Starting with Java 8, HashMap can convert a heavily populated bucket from a linked list into a red-black tree.</p><p>This process is called <strong>treeification</strong>.</p><p>A simplified illustration:</p><p>Before treeification:</p><pre>Bucket<br>  |<br>  v<br>A -&gt; B -&gt; C -&gt; D -&gt; E -&gt; F -&gt; G -&gt; H</pre><p>After treeification:</p><pre>          D<br>        /   \<br>       B     F<br>      / \   / \<br>     A   C E   H<br>              /<br>             G</pre><p>The tree shown is illustrative; the actual tree structure depends on the keys and insertion history.</p><h3>When does treeification happen?</h3><p>In the standard OpenJDK implementation:</p><ul><li>TREEIFY_THRESHOLD is 8.</li><li>UNTREEIFY_THRESHOLD is 6.</li><li>MIN_TREEIFY_CAPACITY is 64.</li></ul><p>These constants have specific roles.</p><ul><li>When a bucket becomes sufficiently populated, treeification may be attempted.</li><li>If the table capacity is below 64, HashMap generally resizes instead of immediately converting the bucket into a tree.</li><li>During certain resizing operations, tree bins may convert back into ordinary linked bins.</li></ul><p>The threshold of 8 is not a guarantee that every bucket containing eight entries immediately becomes a tree. The insertion path, current table capacity, and implementation details matter.</p><h3>Why use a red-black tree?</h3><p>A red-black tree is a self-balancing binary search tree.</p><p>Searching a well-behaved tree bin can take approximately O(log⁡n)O(\log n) time, compared with O(n)O(n) for traversing a linked list containing nn entries.</p><p>However, tree-bin behavior also depends on hash distribution, key equality, and the ability to compare keys when ordering is needed.</p><p><strong>Key takeaway:</strong> Treeification helps limit the impact of heavily populated buckets, but it does not guarantee that every HashMap lookup takes logarithmic time.</p><h3>7. How Does get() Work Internally?</h3><p>Now let’s examine the lookup operation.</p><pre>Integer value = map.get(&quot;Apple&quot;);</pre><p>Internally, the process works approximately as follows.</p><ol><li>Java calculates the hash of the requested key.</li><li>It calculates the corresponding bucket index.</li><li>It examines the first node in that bucket.</li><li>If the first node does not match, it searches the remaining linked nodes or tree nodes.</li><li>If it finds an equal key, it returns the associated value.</li><li>If no matching key exists, it returns null.</li></ol><p>The matching process uses the hash as a quick filter, followed by identity or equality checks.</p><p>A simplified lookup algorithm looks like this:</p><pre>V get(Object key) {<br>    int hash = hash(key);<br>    int index = (table.length - 1) &amp; hash;<br>    Node&lt;K, V&gt; node = table[index];<br>    while (node != null) {<br>        if (node.hash == hash &amp;&amp;<br>            (node.key == key ||<br>             (key != null &amp;&amp; key.equals(node.key)))) {<br>            return node.value;<br>        }<br>        node = node.next;<br>    }<br>    return null;<br>}</pre><p>This is conceptual pseudocode, not the complete implementation. Actual HashMap code also handles tree bins and other details.</p><h3>Why are hashCode() and equals() both important?</h3><p>Consider a custom class:</p><pre>class Employee {<br>    private final int id;<br>    Employee(int id) {<br>        this.id = id;<br>    }<br>    @Override<br>    public int hashCode() {<br>        return Integer.hashCode(id);<br>    }<br>    @Override<br>    public boolean equals(Object obj) {<br>        if (this == obj) {<br>            return true;<br>        }<br>        if (!(obj instanceof Employee)) {<br>            return false;<br>        }<br>        Employee other = (Employee) obj;<br>        return this.id == other.id;<br>    }<br>}</pre><p>Now consider:</p><pre>Map&lt;Employee, String&gt; employees = new HashMap&lt;&gt;();<br>employees.put(new Employee(101), &quot;Alice&quot;);<br>System.out.println(<br>    employees.get(new Employee(101))<br>);</pre><p>Output:</p><pre>Alice</pre><p>Although the two Employee objects are different object instances, they represent the same logical key because their equals() methods return true and their hash codes are consistent.</p><p>If you override equals(), you should also override hashCode() so that equal objects have equal hash codes.</p><p>Otherwise, logically equal keys may end up in different buckets, causing unexpected lookup behavior.</p><h3>8. What Happens When You Insert Duplicate Keys?</h3><p>A HashMap cannot contain multiple distinct mappings for keys that are equal according to its key-matching rules.</p><p>Consider:</p><pre>Map&lt;String, Integer&gt; map = new HashMap&lt;&gt;();<br>map.put(&quot;Java&quot;, 10);<br>map.put(&quot;Java&quot;, 20);<br>System.out.println(map);</pre><p>Output:</p><pre>{Java=20}</pre><p>The second insertion updates the existing mapping.</p><p>Internally, Java calculates the hash, finds the relevant bucket, and checks whether an existing node represents the same key.</p><p>If it does, Java updates the node’s value instead of adding another mapping.</p><p>This is why the following statement is important:</p><p><strong>Different keys can collide, but an equal key updates its existing mapping.</strong></p><h3>9. What Is the Default Capacity of HashMap?</h3><p>The commonly used default initial capacity in Java’s HashMap is 16, with a default load factor of 0.75.</p><pre>Map&lt;String, Integer&gt; map = new HashMap&lt;&gt;();</pre><p>These defaults are important, but there is a subtle distinction: the table is typically allocated lazily rather than at the moment the constructor runs.</p><h3>What is capacity?</h3><p>Capacity refers to the length of the internal bucket array.</p><p>For example:</p><pre>Capacity = 16<br><br>Bucket indices:<br>0, 1, 2, 3, 4, 5, 6, 7,<br>8, 9, 10, 11, 12, 13, 14, 15</pre><h3>What is load factor?</h3><p>The load factor controls how full the map is allowed to become before a resize is triggered.</p><p>The default load factor is:</p><pre>0.75f</pre><p>For a table capacity of 16, the usual resize threshold is:</p><p>16×0.75=1216 \times 0.75 = 12</p><p>This means the threshold is 12 mappings for a table of capacity 16.</p><p>When the number of mappings exceeds the applicable threshold, the map generally resizes.</p><p>A resize does not occur simply because a bucket becomes full. It is based on the map’s overall size and threshold, with additional implementation-specific behavior for heavily populated buckets.</p><h3>10. How Does Resizing Work Internally?</h3><p>Resizing is another important part of HashMap.</p><p>Suppose the table has capacity 16 and its threshold is 12.</p><p>As new mappings are added, the map’s size eventually exceeds the threshold.</p><p>Java then expands the table, commonly doubling its capacity from 16 to 32.</p><pre>Before resizing:<br><br>Capacity = 16<br>Threshold = 12<br><br>After resizing:<br><br>Capacity = 32<br>Threshold = 24</pre><p>The exact threshold can differ in edge cases, but doubling the capacity is the standard behavior when growing a normally sized table.</p><h3>Why does HashMap resize?</h3><p>As the number of entries increases, a larger bucket array can help distribute entries across more buckets.</p><p>This can reduce collisions and maintain efficient lookup performance.</p><h3>Does resizing simply copy the old array?</h3><p>No. Entries must be redistributed according to the new capacity.</p><p>Because HashMap capacities are normally powers of two, OpenJDK can efficiently determine whether a node remains in its existing bucket index or moves to an index offset by the old capacity.</p><p>For example, when capacity doubles from 16 to 32, an entry previously at index 5 may remain at index 5 or move to index 21.</p><p>Conceptually:</p><pre>Old Capacity = 16<br><br>Bucket[5]<br>   |<br>   v<br>Node A -&gt; Node B<br><br>After resizing to capacity 32:<br><br>Bucket[5]  -&gt; Node A<br>Bucket[21] -&gt; Node B</pre><p>This is an illustrative example, not a guarantee that every bucket splits into two non-empty buckets.</p><p>The redistribution depends on the hashes of the nodes in each old bucket.</p><h3>Is resizing expensive?</h3><p>Resizing requires processing existing entries, so it can be relatively expensive compared with an ordinary insertion.</p><p>However, because the table grows geometrically, the amortized cost of insertion remains efficient under normal conditions.</p><p>If you know approximately how many entries your map will contain, providing an appropriate initial capacity can reduce repeated resizing.</p><p>For example:</p><pre>Map&lt;Integer, String&gt; map = new HashMap&lt;&gt;(1000);</pre><p>Be aware that the constructor argument represents an initial capacity request, not a guaranteed maximum number of entries. The internal table size and threshold are adjusted according to the implementation’s sizing rules.</p><h3>11. How Does remove() Work Internally?</h3><p>Consider the following code:</p><pre>map.remove(&quot;Apple&quot;);</pre><p>The removal process is approximately:</p><ol><li>Calculate the hash of the key.</li><li>Find the appropriate bucket.</li><li>Search for the matching node.</li><li>Remove the node from the bucket’s linked list or tree.</li><li>Update the map’s size.</li></ol><p>For a linked list, removing a node involves adjusting references so that the surrounding nodes remain connected.</p><p>Before removal:</p><pre>Apple -&gt; Mango -&gt; Banana</pre><p>After removing Mango:</p><pre>Apple -&gt; Banana</pre><p>If the key does not exist, the map remains unchanged.</p><p>Removing an entry does not normally shrink the entire bucket array automatically. HashMap primarily grows its table as needed; it does not routinely reduce capacity after removals.</p><h3>12. Can HashMap Have a Null Key?</h3><p>Yes. Java’s HashMap allows one null key and multiple null values.</p><p>For example:</p><pre>Map&lt;String, Integer&gt; map = new HashMap&lt;&gt;();<br>map.put(null, 100);<br>map.put(&quot;Java&quot;, null);<br>map.put(&quot;Python&quot;, null);</pre><p>This is valid.</p><p>In the standard OpenJDK implementation, a null key is assigned a hash value of zero.</p><p>Since a map can have only one mapping for the null key, inserting another null key updates the value of that existing mapping.</p><p>Keep in mind that other map implementations, such as ConcurrentHashMap, have different rules for null keys and values.</p><h3>13. What Is the Time Complexity of HashMap?</h3><p>The time complexity of HashMap operations depends on the distribution of keys and the structure of individual buckets.</p><p>OperationExpected timeWorst-case considerationsput()O(1)O(1) amortizedCan take longer due to collisions or resizingget()O(1)O(1)Can degrade with heavy collisionsremove()O(1)O(1) expectedDepends on bucket structureIterationO(C+N)O(C + N)Depends on capacity and number of mappings</p><p>Here:</p><ul><li>NN is the number of mappings.</li><li>CC is the bucket-array capacity.</li></ul><p>The expected constant-time performance assumes a reasonable distribution of hash values and other normal operating conditions.</p><p>Tree bins can improve collision-heavy lookup behavior, but they do not make all possible cases universally O(log⁡n)O(\log n).</p><h3>14. Is HashMap Thread-Safe?</h3><p>No. HashMap is not thread-safe by default.</p><p>If multiple threads access the same map and at least one thread structurally modifies it without proper synchronization, the application may experience race conditions and unpredictable behavior.</p><p>For example:</p><pre>Map&lt;String, Integer&gt; map = new HashMap&lt;&gt;();</pre><p>This map should not be assumed safe for concurrent modification.</p><p>If your application requires concurrent access, consider alternatives such as:</p><pre>Map&lt;String, Integer&gt; map = new ConcurrentHashMap&lt;&gt;();</pre><p>ConcurrentHashMap is designed for concurrent access and has different implementation details and restrictions, including disallowing null keys and values.</p><p>For simpler scenarios where all access can be synchronized externally, synchronized wrappers may also be appropriate.</p><p>Choose the implementation based on your concurrency requirements rather than assuming that any map is automatically thread-safe.</p><h3>15. Important HashMap Interview Questions</h3><p>Here are some common questions to test your understanding.</p><p><strong>Q1. What happens internally when you call </strong><strong>put()?</strong></p><p>Java calculates the key’s hash, determines the bucket index, checks for an existing key, inserts or updates a mapping, and checks whether resizing is required.</p><p><strong>Q2. What is a hash collision?</strong></p><p>A collision occurs when different keys map to the same bucket.</p><p><strong>Q3. Why does HashMap use both </strong><strong>hashCode() and </strong><strong>equals()?</strong></p><p>The hash helps locate the bucket, while equality checks determine whether a candidate node represents the requested key.</p><p><strong>Q4. Why is the default load factor 0.75?</strong></p><p>It provides a practical balance between memory usage and collision frequency. A lower load factor generally uses more memory, while a higher one may increase collisions.</p><p><strong>Q5. What happens when two different keys have the same hash code?</strong></p><p>They can occupy the same bucket. Java distinguishes them through key matching and handles collisions using linked nodes or tree bins.</p><p><strong>Q6. When does a linked list become a red-black tree?</strong></p><p>In standard OpenJDK implementations, treeification is attempted around the threshold of eight nodes, subject to the table-capacity rule and insertion path.</p><p><strong>Q7. What happens when the HashMap exceeds its threshold?</strong></p><p>The table generally resizes, commonly doubling its capacity, and existing entries are redistributed.</p><p><strong>Q8. Why should we override </strong><strong>hashCode() when overriding </strong><strong>equals()?</strong></p><p>Equal objects must have equal hash codes. Violating this contract can cause logically equal keys to behave unexpectedly in hash-based collections.</p><p><strong>Q9. Does HashMap maintain insertion order?</strong></p><p>No. If insertion order is required, consider LinkedHashMap.</p><p><strong>Q10. Is HashMap thread-safe?</strong></p><p>No. For concurrent access, consider ConcurrentHashMap or suitable synchronization.</p><h3>Conclusion</h3><p>Java’s HashMap is much more than a simple key-value data structure.</p><p>Its performance comes from combining hashing, efficient bucket indexing, collision handling, resizing, and treeification.</p><p>To summarize:</p><ul><li>Hashing helps determine where an entry belongs.</li><li>The bucket array provides efficient access to entries.</li><li>hashCode() and equals() work together to identify keys.</li><li>Linked lists handle collisions in ordinary buckets.</li><li>Red-black trees can improve performance in heavily populated buckets.</li><li>Resizing helps maintain efficient distribution as the map grows.</li><li>Thread safety must be handled separately when multiple threads share a map.</li></ul><p>Once you understand these internal mechanisms, operations such as put(), get(), and remove() become much easier to reason about.</p><p>The next time you write a single line of code using HashMap, you&#39;ll know much more about what happens behind the scenes.</p><p><strong>If you found this guide useful, share it with another Java developer and follow along for more deep dives into Java internals.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=534b2c17ead7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Kafka: The Definitive Guide]]></title>
            <link>https://medium.com/@prataparao.saivamsi/apache-kafka-the-definitive-guide-e88f7d5cdd65?source=rss-99aaf3a0a9d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e88f7d5cdd65</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[apache-kafka]]></category>
            <dc:creator><![CDATA[Prataparao SaiVamsi]]></dc:creator>
            <pubDate>Wed, 08 Oct 2025 18:23:23 GMT</pubDate>
            <atom:updated>2025-10-08T18:23:23.485Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*7N6mEBgatx33RFFL.png" /></figure><p>In today’s world of <strong>data-driven applications</strong>, real-time data processing is not a luxury — it’s a necessity. Whether it’s tracking user activity on a website, processing financial transactions, or monitoring IoT devices, businesses need systems that can handle <strong>high-throughput, low-latency data streams</strong>.</p><p>Enter <strong>Apache Kafka</strong> — an open-source distributed event streaming platform used by thousands of companies, from startups to global enterprises.</p><p>This guide is your <strong>complete roadmap to Kafka</strong>, whether you’re just starting or you’re managing large-scale production clusters.</p><h3>Table of Contents</h3><ol><li>What is Apache Kafka?</li><li>Kafka Core Concepts</li><li>Kafka Architecture Deep Dive</li><li>Kafka Setup &amp; Installation</li><li>Producing and Consuming Messages</li><li>Kafka Use Cases</li><li>Advanced Kafka Features</li><li>Kafka Performance Tuning</li><li>Monitoring and Operations</li><li>Security in Kafka</li><li>Best Practices</li><li>Kafka Alternatives and Integrations</li><li>Final Thoughts</li></ol><h3>What is Apache Kafka?</h3><p>Apache Kafka is an <strong>open-source distributed event streaming platform</strong> originally developed by LinkedIn and now part of the Apache Software Foundation. It’s designed to handle <strong>real-time data feeds</strong> with extremely high throughput, fault tolerance, and scalability.</p><p>Kafka allows you to:</p><ul><li>Publish and subscribe to streams of records.</li><li>Store streams of records in a fault-tolerant way.</li><li>Process streams of records in real time.</li></ul><p><strong>Kafka vs Traditional Messaging Systems</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*TcAIkg7ykprwKO3bAgL96A.png" /></figure><h3>Kafka Core Concepts</h3><h3>Topics</h3><p>A topic is a named stream of records. Producers write data to topics, and consumers read from them.</p><h3>Partitions</h3><p>Topics are split into partitions to enable parallelism and scalability.</p><h3>Records (Messages)</h3><p>The atomic unit of data in Kafka. Each record consists of a key, a value, and optional metadata.</p><h3>Producer</h3><p>An application that writes data to Kafka.</p><h3>Consumer</h3><p>An application that reads data from Kafka.</p><h3>Consumer Groups</h3><p>A way of scaling consumers; each consumer in a group gets a subset of partitions.</p><h3>Offset</h3><p>A unique ID assigned to each message within a partition.</p><h3>Kafka Architecture Deep Dive</h3><p>Kafka is <strong>distributed</strong>, <strong>fault-tolerant</strong>, and <strong>horizontally scalable</strong>. Here’s how:</p><h3>Brokers</h3><p>Kafka runs as a cluster of one or more <strong>brokers</strong> (servers). Each broker manages a set of partitions.</p><h3>Zookeeper (or KRaft)</h3><p>Zookeeper was traditionally used for coordination, leader election, and configuration. Kafka is transitioning to <strong>KRaft mode</strong> (Kafka Raft Metadata mode) to eliminate Zookeeper.</p><h3>Producers</h3><p>They send records to a topic. They can choose a partition by key or let Kafka distribute automatically.</p><h3>Consumers</h3><p>They subscribe to topics and process records. Consumers track the offset for each partition they read.</p><h3>Replication</h3><p>Each partition can have multiple <strong>replicas</strong> for fault tolerance. One replica is the <strong>leader</strong>; others are <strong>followers</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/0*sGx2w6zhAImmqM7Y.png" /></figure><h3>Kafka Setup &amp; Installation</h3><h3>Local Setup (Single Node)</h3><p>You can set up Kafka quickly using Docker or native binaries.</p><h4>Using Docker</h4><pre>version: &#39;3&#39;<br>services:<br>  zookeeper:<br>    image: confluentinc/cp-zookeeper<br>    environment:<br>      ZOOKEEPER_CLIENT_PORT: 2181<br>  kafka:<br>    image: confluentinc/cp-kafka<br>    environment:<br>      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181<br>      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092<br>      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1</pre><h3>Install from Binaries</h3><p>Download from Kafka Downloads, unzip, and run:</p><pre>bin/zookeeper-server-start.sh config/zookeeper.properties<br>bin/kafka-server-start.sh config/server.properties</pre><h3>Producing and Consuming Messages</h3><h3>Producer Example (Java)</h3><pre>Properties props = new Properties();<br>props.put(&quot;bootstrap.servers&quot;, &quot;localhost:9092&quot;);<br>props.put(&quot;key.serializer&quot;, &quot;org.apache.kafka.common.serialization.StringSerializer&quot;);<br>props.put(&quot;value.serializer&quot;, &quot;org.apache.kafka.common.serialization.StringSerializer&quot;);<br><br>KafkaProducer&lt;String, String&gt; producer = new KafkaProducer&lt;&gt;(props);<br>producer.send(new ProducerRecord&lt;&gt;(&quot;my-topic&quot;, &quot;key1&quot;, &quot;Hello, Kafka!&quot;));</pre><h3>Consumer Example (Java)</h3><pre>Properties props = new Properties();<br>props.put(&quot;bootstrap.servers&quot;, &quot;localhost:9092&quot;);<br>props.put(&quot;group.id&quot;, &quot;test-group&quot;);<br>props.put(&quot;key.deserializer&quot;, &quot;org.apache.kafka.common.serialization.StringDeserializer&quot;);<br>props.put(&quot;value.deserializer&quot;, &quot;org.apache.kafka.common.serialization.StringDeserializer&quot;);<br><br>KafkaConsumer&lt;String, String&gt; consumer = new KafkaConsumer&lt;&gt;(props);<br>consumer.subscribe(Collections.singletonList(&quot;my-topic&quot;));<br><br>while (true) {<br>    ConsumerRecords&lt;String, String&gt; records = consumer.poll(Duration.ofMillis(100));<br>    for (ConsumerRecord&lt;String, String&gt; record : records) {<br>        System.out.printf(&quot;Offset = %d, Key = %s, Value = %s%n&quot;,<br>                          record.offset(), record.key(), record.value());<br>    }<br>}</pre><h3>Kafka Use Cases</h3><p>Kafka shines in a variety of use cases:</p><ul><li><strong>Log Aggregation</strong></li><li><strong>Real-Time Analytics</strong></li><li><strong>Event Sourcing</strong></li><li><strong>Stream Processing</strong></li><li><strong>IoT Data Ingestion</strong></li><li><strong>Website Activity Tracking</strong></li><li><strong>Microservices Communication</strong></li></ul><h3>Advanced Kafka Features</h3><h3>Kafka Streams</h3><p>A client library for processing and analyzing data stored in Kafka. Enables complex event processing (joins, windowing, etc.).</p><h3>Kafka Connect</h3><p>A tool for scalably and reliably streaming data between Kafka and external systems (databases, file systems, etc.).</p><h3>Schema Registry</h3><p>Manages Avro/JSON schemas to ensure data compatibility and serialization.</p><h3>Log Compaction</h3><p>Keeps only the latest record for each key, useful for changelog-style data.</p><h3>Kafka Performance Tuning</h3><p>Some tips:</p><ul><li><strong>Batching:</strong> Increase batch.size and linger.ms for producers.</li><li><strong>Compression:</strong> Use Snappy or LZ4.</li><li><strong>Replication:</strong> Tune replication.factor for fault tolerance vs performance.</li><li><strong>Consumer Parallelism:</strong> Scale consumers via multiple instances or threads.</li></ul><h3>Monitoring and Operations</h3><p>Use tools like:</p><ul><li><strong>Confluent Control Center</strong></li><li><strong>Prometheus + Grafana</strong></li><li><strong>Burrow</strong> — for consumer lag monitoring</li><li><strong>Kafka Manager / Cruise Control</strong> — cluster management</li></ul><p>Key metrics to monitor:</p><ul><li>Broker CPU and disk usage</li><li>Message throughput (in/out)</li><li>Consumer lag</li><li>Partition distribution</li><li>Under-replicated partitions</li></ul><h3>Security in Kafka</h3><p>Kafka supports:</p><ul><li><strong>SSL Encryption</strong> for data in transit</li><li><strong>SASL Authentication</strong></li><li><strong>ACLs (Access Control Lists)</strong> for authorization</li><li><strong>Kerberos Integration</strong> for enterprise environments</li></ul><p>Example: Enabling SSL</p><pre>ssl.keystore.location=/var/private/ssl/kafka.server.keystore.jks<br>ssl.keystore.password=password<br>ssl.key.password=password</pre><h3>Best Practices</h3><ul><li><strong>Use multiple partitions</strong> to increase parallelism.</li><li><strong>Avoid large messages</strong> — Kafka is optimized for many small messages.</li><li><strong>Use schema registry</strong> to evolve message structure safely.</li><li><strong>Monitor consumer lag</strong> constantly.</li><li><strong>Avoid tight coupling</strong> between producers and consumers.</li><li><strong>Retain data wisely</strong> — storage costs can add up.</li></ul><h3>Kafka Alternatives and Integrations</h3><h3>Alternatives</h3><ul><li><strong>RabbitMQ</strong> — Better for low-latency, non-persistent messages</li><li><strong>Apache Pulsar</strong> — Strong multi-tenancy and geo-replication</li><li><strong>AWS Kinesis</strong> — Fully managed alternative on AWS</li></ul><h3>Integrations</h3><ul><li><strong>Kafka + Spark Streaming</strong></li><li><strong>Kafka + Flink</strong></li><li><strong>Kafka + Elasticsearch</strong></li><li><strong>Kafka + Cassandra</strong></li></ul><h3>Final Thoughts</h3><p>Apache Kafka has become the <strong>backbone of modern data infrastructure</strong>. From logging and metrics to event-driven architectures and stream processing, Kafka powers some of the <strong>most demanding applications</strong> in the world.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e88f7d5cdd65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create an API Key in Azure and Use It with OpenAI: A Step-by-Step Guide for Beginners]]></title>
            <link>https://medium.com/@prataparao.saivamsi/how-to-create-an-api-key-in-azure-and-use-it-with-openai-a-step-by-step-guide-for-beginners-1fb056290ba3?source=rss-99aaf3a0a9d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fb056290ba3</guid>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Prataparao SaiVamsi]]></dc:creator>
            <pubDate>Tue, 07 Oct 2025 13:44:48 GMT</pubDate>
            <atom:updated>2025-10-07T13:44:48.119Z</atom:updated>
            <content:encoded><![CDATA[<p>Integrating OpenAI with Azure might sound intimidating, especially if you’re new to cloud platforms or APIs. Don’t worry! This guide will walk you through every step, from setting up your Azure account to writing code that uses your API key to interact with OpenAI. By the end, you’ll understand not just how to do it, but also why each step matters.</p><h3>1. What is an API Key and Why Do You Need One?</h3><p>An API key is like a password for your application. It tells Azure that your app is allowed to use a particular service (in this case, OpenAI). You’ll use this key in your code to prove your identity and get access to the OpenAI models.</p><h3>2. Setting Up Your Azure Account</h3><p>If you don’t have an Azure account yet:</p><ul><li>Go to <a href="https://azure.com/free">https://azure.com/free</a> and sign up.</li><li>You’ll need an email address and a phone number. Azure offers free credits for new users.</li></ul><h3>3. Creating an Azure OpenAI Resource</h3><p>This is where you’ll “host” your OpenAI models in Azure.</p><h3>Step-by-Step Instructions</h3><ol><li>Log in to the Azure Portal</li><li>Visit <a href="https://portal.azure.com/">https://portal.azure.com</a> and sign in.</li><li>Search for Azure OpenAI</li><li>At the top, in the search bar, type “Azure OpenAI”.</li><li>Click on Azure OpenAI in the results.</li><li>Create a New Resource</li><li>Click the + Create button.</li><li>Fill in the required information:</li><li>Subscription: Choose your Azure subscription.</li><li>Resource Group: You can create a new one (e.g., openai-demo-rg).</li><li>Region: Pick a region close to you (e.g., East US, West Europe).</li><li>Name: Give your resource a unique name (e.g., my-openai-resource).</li><li>Click Review + create, then Create.</li><li>Wait for Deployment</li><li>Azure will take a minute or two to set up your resource.</li><li>Click Go to resource when it’s ready.</li></ol><h3>4. Deploying a Model (GPT-3.5, GPT-4, etc.)</h3><p>Before you can use OpenAI, you need to “deploy” a model.</p><ol><li>In your Azure OpenAI resource, look for Model Deployments or Deployments in the left menu.</li><li>Click + Create or + Add.</li><li>Select the model you want (like gpt-35-turbo or gpt-4).</li><li>Give your deployment a name (e.g., gpt35-demo).</li><li>Click Create.</li></ol><p>Why this matters:<br>Deploying a model makes it available for your API calls. You’ll use the deployment name in your code.</p><h3>5. Getting Your API Key and Endpoint</h3><p>Now you’re ready to get the information you’ll use to connect from your code.</p><ol><li>In your Azure OpenAI resource, find Keys and Endpoint in the left menu.</li><li>You’ll see two keys (KEY 1 and KEY 2) and an Endpoint URL.</li><li>Copy one of the keys (KEY 1 is fine for now).</li><li>Copy the Endpoint URL (it looks like <a href="https://your-resource-name.openai.azure.com/).">https://your-resource-name.openai.azure.com/).</a></li></ol><p>Tip:<br>Keep your API key secret! Don’t share it or post it publicly.</p><h3>6. Writing Code to Use Your API Key with OpenAI</h3><p>Let’s write a simple Python script that sends a prompt to your deployed model and prints the response.</p><h3>Prerequisites</h3><ul><li>Install Python (from <a href="https://www.python.org/">python.org</a>) if you don’t have it.</li><li>Install the requests library by running:</li></ul><pre>pip install requests</pre><h3>Sample Python Code</h3><pre>import requests<br># Replace these with your actual values<br>endpoint = &quot;https://YOUR_RESOURCE_NAME.openai.azure.com/&quot;<br>api_key = &quot;YOUR_API_KEY&quot;<br>deployment_name = &quot;YOUR_DEPLOYMENT_NAME&quot;<br>headers = {<br>    &quot;api-key&quot;: api_key,<br>    &quot;Content-Type&quot;: &quot;application/json&quot;<br>}<br>data = {<br>    &quot;prompt&quot;: &quot;Write a short story about a robot learning to paint.&quot;,<br>    &quot;max_tokens&quot;: 100<br>}<br># Construct the full URL for the API call<br>url = f&quot;{endpoint}openai/deployments/{deployment_name}/completions?api-version=2024-02-15-preview&quot;<br>response = requests.post(url, headers=headers, json=data)<br># Print the response from the API<br>print(response.json())</pre><h3>What Each Part Means</h3><ul><li>endpoint: The base URL for your Azure OpenAI resource.</li><li>api_key: The secret key you copied earlier.</li><li>deployment_name: The name you gave your model deployment (e.g., gpt35-demo).</li><li>headers: Tells Azure who you are (your API key) and what data format you’re sending.</li><li>data: The prompt you want to send to the model and how many tokens (words) you want in the response.</li><li>url: The complete address for your API call, including the deployment name and API version.</li></ul><h3>7. Running Your Code</h3><ol><li>Save the script as openai_test.py.</li><li>Open your terminal or command prompt.</li><li>Run:</li></ol><pre>python openai_test.py</pre><p>You should see a JSON response with the model’s answer!</p><h3>8. Best Practices and Troubleshooting</h3><ul><li>Keep your API key safe. Never share it or commit it to public code repositories.</li><li>If you get errors: Double-check your endpoint, API key, and deployment name.</li><li>Rotate your keys periodically for security.</li><li>For production: Store your API key in environment variables or use Azure Key Vault.</li></ul><h3>Summary</h3><ul><li>Create an Azure account and OpenAI resource.</li><li>Deploy a model and get your API key and endpoint.</li><li>Write code to call the API using your key.</li><li>Keep your keys secure and experiment!</li></ul><p>With these steps, you’re ready to start building amazing AI-powered applications with Azure and OpenAI — even as a beginner. Happy coding! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fb056290ba3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Java 23: New Features and Why Java 8 and 11 Remain Popular]]></title>
            <link>https://medium.com/@prataparao.saivamsi/exploring-java-23-new-features-and-why-java-8-and-11-remain-popular-38dc1285118c?source=rss-99aaf3a0a9d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/38dc1285118c</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java-23]]></category>
            <category><![CDATA[java8]]></category>
            <category><![CDATA[java11]]></category>
            <dc:creator><![CDATA[Prataparao SaiVamsi]]></dc:creator>
            <pubDate>Thu, 26 Sep 2024 07:01:44 GMT</pubDate>
            <atom:updated>2024-09-26T07:01:44.862Z</atom:updated>
            <content:encoded><![CDATA[<p>Java continues to evolve, with the latest release being Java SE 23, which debuted on September 17, 2024. This version introduces several exciting features that enhance the language’s capabilities and developer experience. In this blog, we will explore the key updates in Java 23 and discuss why many developers still prefer using Java 8 and Java 11.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/0*jGpmZD6X8e2CuAeA" /></figure><h3>Key Features of Java 23</h3><p>Java 23 brings a host of new features and enhancements that cater to both new and experienced developers. Here are some notable additions:</p><ol><li>Primitive Types in Pattern Matching:</li></ol><ul><li>Java 23 allows primitive types to be used in pattern matching, simplifying switch expressions. This enhancement enables cleaner code when handling different data types in conditional statements.</li></ul><pre>var weight = 68;<br>switch (weight) {<br>    case byte b when b &lt;= 70 -&gt; System.out.println(&quot;byte: less than or equal to 70&quot;);<br>    case int i when i &lt;= 700 -&gt; System.out.println(&quot;int: less than or equal to 700&quot;);<br>    case long l when l &gt;= 7_000 &amp;&amp; l &lt;= 70_000 -&gt; System.out.println(&quot;long range: 7,000 - 70,000&quot;);<br>    case double d -&gt; System.out.println(&quot;double&quot;);<br>}</pre><p>2. Markdown Documentation Comments:</p><ul><li>Java 23 introduces support for Markdown in documentation comments (Javadoc), making it easier to write and read documentation compared to traditional HTML tags.</li></ul><pre>/**<br> * # This is a Markdown Comment<br> * - Easy to write<br> * - Easy to read<br> */</pre><p>3. Implicitly Declared Classes and Instance Main Methods:</p><ul><li>This feature simplifies the creation of single-class programs for beginners by allowing them to omit boilerplate code, such as static modifiers and parameters in the main method.</li></ul><pre>void main() {<br>    System.out.println(&quot;Hello, World!&quot;);<br>}</pre><p>4. Class-File API (Second Preview):</p><ul><li>The Class-File API allows for parsing, generating, and transforming Java class files, providing a standardized way for developers to interact with class files.</li></ul><p>5. Vector API (Eighth Incubator):</p><ul><li>The Vector API continues its incubator phase, enabling developers to express vector computations that compile into optimal vector instructions for improved performance.</li></ul><p>6. Stream Gatherers (Second Preview):</p><ul><li>This feature enhances the ability to transform data streams more effectively, improving how developers can work with collections of data.</li></ul><p>These features collectively aim to improve developer productivity, enhance performance, and simplify code readability.</p><h3>Why Do Many Developers Prefer Java 8 and Java 11?</h3><p>Despite the advancements in newer versions like Java 23, many developers continue to use Java 8 and Java 11 for several reasons:</p><ol><li>Long-Term Support (LTS):</li></ol><ul><li>Both Java 8 and Java 11 are Long-Term Support releases, meaning they receive updates and security patches for an extended period. This stability is crucial for enterprise applications that require consistent support.</li></ul><p>2. Established Ecosystem:</p><ul><li>Many libraries and frameworks have been built around these versions. Migrating legacy systems can be costly and time-consuming, leading organizations to stick with what they know works.</li></ul><p>3. Familiarity:</p><ul><li>Developers who have been working with Java for years are often comfortable with the features and syntax of these versions. Learning new features in later versions may not be a priority if existing applications are stable.</li></ul><p>4. Performance:</p><ul><li>While newer versions introduce performance improvements, many applications running on Java 8 or Java 11 perform adequately for their needs. Upgrading may not yield significant benefits compared to the effort involved.</li></ul><p>5. Compatibility:</p><ul><li>Some older systems or third-party tools may not yet support features introduced in newer versions, leading teams to remain on older versions until full compatibility is achieved.</li></ul><h3>Conclusion</h3><p>Java SE 23 offers exciting new features that enhance the language’s capabilities and improve developer experience. However, the widespread use of Java 8 and Java 11 highlights the importance of stability, support, and familiarity in software development environments. As organizations evaluate their technology stacks, balancing the adoption of new features with the need for reliability will continue to shape their decisions regarding which version of Java to use. For developers looking to leverage the latest advancements while maintaining a stable foundation, exploring the new features of Java SE 23 could be beneficial as they plan future projects or migrations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38dc1285118c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding OAuth: A Comprehensive Guide]]></title>
            <link>https://medium.com/@prataparao.saivamsi/understanding-oauth-a-comprehensive-guide-cd218879dc0a?source=rss-99aaf3a0a9d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd218879dc0a</guid>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[oauth]]></category>
            <dc:creator><![CDATA[Prataparao SaiVamsi]]></dc:creator>
            <pubDate>Thu, 26 Sep 2024 02:01:59 GMT</pubDate>
            <atom:updated>2024-09-26T02:17:32.522Z</atom:updated>
            <content:encoded><![CDATA[<p>OAuth (Open Authorization) is a widely adopted authorization framework that allows third-party applications to gain limited access to a user’s resources on another service without exposing their credentials. This blog post will delve into the intricacies of OAuth, its importance, and how to implement it effectively.</p><h3>What is OAuth?</h3><p>OAuth is primarily designed to enhance security by enabling users to grant access to their data without sharing their passwords. Instead of using login credentials, OAuth utilizes access tokens that specify the permissions granted to the third-party application. This separation of roles between the user (resource owner) and the application (client) minimizes security risks associated with password sharing.</p><h3>Why Use OAuth?</h3><ol><li>Security: Users do not need to share their passwords with third-party applications.</li><li>Granular Access Control: Users can specify what data the application can access.</li><li>Revocation: Users can easily revoke access without changing their passwords.</li><li>Standardization: Many major platforms (e.g., Google, Facebook, Twitter) use OAuth, making it a familiar and trusted method for authentication.</li></ol><h3>The OAuth 2.0 Flow</h3><p>The OAuth 2.0 protocol consists of several steps that facilitate secure authorization:</p><ol><li>Authorization Request: The client requests authorization from the user by redirecting them to the authorization server (e.g., Google).</li><li>User Consent: The user logs in and consents to grant access to the client.</li><li>Authorization Grant: Upon consent, the authorization server redirects back to the client with an authorization code.</li><li>Access Token Request: The client exchanges the authorization code for an access token by making a request to the authorization server.</li><li>Access Token Response: The authorization server responds with an access token, which the client can use to access protected resources.</li><li>Resource Access: The client uses the access token to make authorized API requests on behalf of the user.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/0*AqVdzo-T_ZNixloz.jpeg" /></figure><h3>Implementing OAuth 2.0</h3><p>To implement OAuth 2.0 in your applications, follow these steps:</p><ol><li><strong>Register Your Application</strong>:</li></ol><ul><li>Create an application in the developer console of your chosen service provider (e.g., Google Cloud Platform).</li><li>Obtain your client_id and client_secret.</li></ul><p>2.<strong> Set Up Redirect URIs:</strong></p><ul><li>Specify where users should be redirected after they authorize your application.</li></ul><p>3.<strong> Initiate Authorization Flow:</strong></p><ul><li>Redirect users to the authorization endpoint with required parameters including client_id, redirect_uri, and scope.</li></ul><p>4.<strong> Handle Authorization Code:</strong></p><ul><li>Capture the authorization code from the redirect URI after user consent.</li></ul><p>5.<strong> Exchange Code for Access Token:</strong></p><ul><li>Make a POST request to the token endpoint with your client_id, client_secret, and received code.</li></ul><p>6.<strong> Use Access Token for API Calls:</strong></p><ul><li>Include the access token in HTTP headers when making requests to protected resources.</li></ul><h3>Example Code Snippet</h3><p>Here’s a basic example of how you might implement OAuth 2.0 in Python using requests:</p><pre>import requests<br><br># Step 1: Redirect user for authorization<br>authorization_url = &quot;https://accounts.google.com/o/oauth2/auth&quot;<br>params = {<br>    &#39;client_id&#39;: &#39;YOUR_CLIENT_ID&#39;,<br>    &#39;redirect_uri&#39;: &#39;YOUR_REDIRECT_URI&#39;,<br>    &#39;response_type&#39;: &#39;code&#39;,<br>    &#39;scope&#39;: &#39;https://www.googleapis.com/auth/userinfo.profile&#39;<br>}<br>response = requests.get(authorization_url, params=params)<br>print(&quot;Go to this URL for authorization:&quot;, response.url)<br><br># Step 2: Exchange code for token<br>code = input(&quot;Enter the authorization code:&quot;)<br>token_url = &quot;https://oauth2.googleapis.com/token&quot;<br>data = {<br>    &#39;code&#39;: code,<br>    &#39;client_id&#39;: &#39;YOUR_CLIENT_ID&#39;,<br>    &#39;client_secret&#39;: &#39;YOUR_CLIENT_SECRET&#39;,<br>    &#39;redirect_uri&#39;: &#39;YOUR_REDIRECT_URI&#39;,<br>    &#39;grant_type&#39;: &#39;authorization_code&#39;<br>}<br>token_response = requests.post(token_url, data=data)<br>access_token = token_response.json().get(&#39;access_token&#39;)<br><br># Step 3: Use access token<br>api_url = &quot;https://www.googleapis.com/userinfo/v2/me&quot;<br>headers = {&#39;Authorization&#39;: f&#39;Bearer {access_token}&#39;}<br>user_info = requests.get(api_url, headers=headers)<br>print(user_info.json())</pre><h3>Conclusion</h3><p>OAuth is a powerful tool for securing user data while allowing third-party applications limited access without compromising credentials. By understanding its workflow and implementing it correctly, developers can enhance security and improve user experience across applications. Whether you are building a social media app or integrating with cloud services, mastering OAuth will be essential for modern web development. For further reading on OAuth implementation details and best practices, consider exploring resources like Google’s documentation or community blogs focusing on specific programming languages and frameworks</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd218879dc0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>