<?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 Rakesh Vende on Medium]]></title>
        <description><![CDATA[Stories by Rakesh Vende on Medium]]></description>
        <link>https://medium.com/@rakeshvende?source=rss-ab42d6405d76------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*lq0teCbPWX9PC2fG.jpg</url>
            <title>Stories by Rakesh Vende on Medium</title>
            <link>https://medium.com/@rakeshvende?source=rss-ab42d6405d76------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 07:00:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rakeshvende/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[The Cache Lookup That Wasn’t: A Redis Story]]></title>
            <link>https://medium.com/@rakeshvende/the-cache-lookup-that-wasnt-a-redis-story-ed61bb7d540c?source=rss-ab42d6405d76------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed61bb7d540c</guid>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[redis-cluster]]></category>
            <category><![CDATA[kafka-streaming]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Rakesh Vende]]></dc:creator>
            <pubDate>Thu, 22 Oct 2026 16:58:29 GMT</pubDate>
            <atom:updated>2026-10-22T16:58:29.960Z</atom:updated>
            <content:encoded><![CDATA[<p><em>An engineering story for anyone newer to distributed systems — with some real Redis and Redisson lessons baked in. There’s no magic fix at the end, and that turns out to be the whole point.</em></p><h3>A small, reasonable problem</h3><p>Picture a service that processes a never-ending stream of events — alerts, signals, monitoring pings — flowing in continuously. The service runs as many <strong>Kubernetes pods</strong>, each with several worker threads pulling events off a queue, processing them, and finally writing them into <strong>Elasticsearch</strong>, which is the long-term, searchable source of truth.</p><p>Now add one sensible rule: <strong>don’t create duplicates.</strong> If the “same” event shows up again — same host, same kind of failure — we shouldn’t open a second record. We should find the first one and update it.</p><p>The obvious approach: when a new event arrives, ask Elasticsearch <em>“have I seen your twin recently?”</em> If yes, merge; if no, it’s new.</p><p>This works beautifully — until you notice the gap.</p><h3>The gap: events that are “in-transit”</h3><p>In a streaming pipeline there’s an unavoidable delay between <em>“I processed this event”</em> and <em>“this event is searchable in Elasticsearch.”</em> Indexing isn’t instant. For a fraction of a second — sometimes longer — the event is <strong>real and already handled, but invisible</strong> to anyone who queries the store.</p><p>Call such an event <strong>in-transit</strong>: it’s left the station but hasn’t arrived.</p><p>Here’s the trap. If a duplicate arrives during that window and we only ask Elasticsearch, Elasticsearch honestly says <em>“never seen it”</em> — the twin isn’t indexed yet. So we treat a duplicate as brand-new. Across a fast stream, that’s a pile of duplicates and broken correlation.</p><p>So we need something Elasticsearch can’t give us in time: a <strong>fast, short-lived, shared memory of in-transit events</strong>. A cache. And the natural choice is <strong>Redis</strong>, because every property we need is forced by the problem:</p><ul><li>It must be <strong>shared across all pods</strong>, because the duplicate might be handled by a <em>different</em> pod than the original.</li><li>Entries only need to live <strong>briefly</strong> — just until the event lands in Elasticsearch — so each entry gets a short <strong>TTL</strong> (say, 30 seconds).</li><li>We group cached events <strong>by category</strong>, and cap how many we keep with a <strong>max-size</strong>.</li></ul><p>To get per-entry TTL and max-size out of the box, we reach for <strong>Redisson’s </strong>RMapCache — a Java client&#39;s map abstraction over Redis that <em>promises</em> exactly those features. Reasonable need, reasonable tools. This is where the story <em>should</em> end. It doesn&#39;t.</p><h3>The graph turns red</h3><p>One day, a <strong>Redis node is pinned near 100% CPU</strong>, and everything sharing it slows down. Important fact for newcomers: <strong>Redis executes commands on a single thread.</strong> One expensive command doesn’t just take long — it <em>blocks everyone else</em> for its entire duration. So “high CPU on Redis” is a five-alarm fire.</p><p><strong>Challenge #1 — it wasn’t the traffic.</strong> The instinct is “too many requests.” But SLOWLOG and MONITOR told a stranger story: the expensive operations weren&#39;t plain GET/SETs. They were <strong>Lua scripts</strong> — EVAL — scanning a hash and poking at several sorted sets. That was our first clue that the cost wasn&#39;t <em>what we were asking</em>, but <em>how our cache library asked it.</em></p><h3>Layer 1: a “get” is not a get</h3><p>Here’s the part that teaches you something about Redisson. Plain Redis can’t expire an individual <em>field</em> inside a hash — it can only expire whole keys. So to deliver its “each entry has its own TTL” promise, RMapCache <strong>emulates</strong> the feature using several helper structures per logical map:</p><ul><li>the <strong>hash</strong> holding the data,</li><li>a <strong>timeout set</strong> (a sorted set) holding each entry’s expiry time,</li><li>an <strong>idle set</strong> for last-access expiry (maxIdle),</li><li>a <strong>last-access set</strong> for max-size / LRU bookkeeping,</li><li>a small <strong>options</strong> hash.</li></ul><p>And it stitches them together with Lua. This is Redisson’s own code for reading a single value — look at what a humble get actually runs:</p><pre>local value = redis.call(&#39;hget&#39;, KEYS[1], ARGV[2]);<br>if value == false then return nil; end;<br>local t, val = struct.unpack(&#39;dLc0&#39;, value);<br>local expireDate = 92233720368547758;<br>local expireDateScore = redis.call(&#39;zscore&#39;, KEYS[2], ARGV[2]);   -- timeout set<br>if expireDateScore ~= false then expireDate = tonumber(expireDateScore) end;<br>if t ~= 0 then<br>  local expireIdle = redis.call(&#39;zscore&#39;, KEYS[3], ARGV[2]);       -- idle set<br>  if expireIdle ~= false then<br>    if tonumber(expireIdle) &gt; tonumber(ARGV[1]) then<br>      redis.call(&#39;zadd&#39;, KEYS[3], t + tonumber(ARGV[1]), ARGV[2]); -- WRITE: refresh idle<br>    end;<br>    expireDate = math.min(expireDate, tonumber(expireIdle))<br>  end;<br>end;<br>if expireDate &lt;= tonumber(ARGV[1]) then return nil; end;<br>local maxSize = tonumber(redis.call(&#39;hget&#39;, KEYS[5], &#39;max-size&#39;));<br>if maxSize ~= nil and maxSize ~= 0 then<br>  local mode = redis.call(&#39;hget&#39;, KEYS[5], &#39;mode&#39;);<br>  if mode == false or mode == &#39;LRU&#39; then<br>    redis.call(&#39;zadd&#39;, KEYS[4], tonumber(ARGV[1]), ARGV[2]);        -- WRITE: LRU touch<br>  else<br>    redis.call(&#39;zincrby&#39;, KEYS[4], 1, ARGV[2]);                     -- WRITE: LFU touch<br>  end;<br>end;<br>return val;</pre><p>Read that slowly. A single “read” touches <strong>five keys</strong>, does an hget, a zscore into the timeout set, <em>maybe</em> a zscore and a zadd into the idle set, and a zadd/zincrby into the last-access set. In other words: <strong>what looks like a read is actually a small, write-capable program.</strong> Hold onto that — it comes back to bite us hard.</p><h3>Layer 2: every event reads everything</h3><p>Why were these scripts running so much? Because of how the duplicate check worked. Remember, we only fall back to the cache when Elasticsearch comes up empty (the in-transit case). In that fallback, for <strong>each incoming event</strong>, the code pulled back the <strong>entire set of cached events in that category</strong> and compared them one by one.</p><p>If the cache holds N entries for a category, each event does work proportional to N. And events never stop:</p><pre>work  ≈  (events per second)  ×  N</pre><h3>Layer 3: “so just look it up by key!” — if only</h3><p>Any sharp reader thinks: <em>why scan all N? Compute a key from the duplicate’s identity and do one </em>O(1)<em> lookup.</em></p><p>We wished. <strong>The dedup criteria aren’t simple equality.</strong> A matching rule can say “same host <strong>and</strong> same service,” sure — but it can also use <strong>regex matches</strong>, <strong>contains</strong>, <strong>not-equals</strong>, and combinations with AND/OR. You can only collapse a match into a single lookup key when it’s pure equality on known fields. The moment a rule involves a regex or a “contains,” <strong>there is no deterministic key to look up</strong> — you <em>must</em> fetch the candidate set and evaluate the predicate in application code.</p><p>That’s the real reason it’s an O(N) scan and not an O(1) get. The <em>query model</em> (arbitrary predicates) simply doesn&#39;t fit a <em>key-value lookup</em>. A genuine teaching moment: your data structure can only be as fast as your access pattern allows.</p><h3>Layer 4: and each entry is checked one at a time</h3><p>It compounds. Because expiry lives in that <strong>separate timeout set</strong>, deciding whether each candidate is still alive means a zscore <strong>per entry</strong> (you saw it in the script). Scanning N entries triggers roughly N more little lookups. The cost doesn&#39;t just grow with N — it doubles down on it.</p><h3>Layer 5: it’s not a quiet background job</h3><p>We assumed this cleanup ran occasionally, in the background. It didn’t. The scan happened <strong>on the hot path — once per event — on every worker thread</strong> in every pod. So the true multiplier was:</p><pre>N  ×  (threads per pod)  ×  (pods)  ×  (events per second)</pre><p>The concurrency we added for throughput was now <em>amplifying</em> the load — many threads, on many pods, all hammering one shared Redis at once.</p><h3>Layer 6: and it all lands on the master</h3><p>The final twist, and the best Redis lesson of the lot. Our <strong>Redis Cluster</strong> was the standard shape: <strong>one master and several replicas</strong>, with the client (Redisson) explicitly configured to <strong>read from replicas</strong> (ReadMode.SLAVE) to spread load. Smart.</p><p>Except the replicas sat idle while the master burned.</p><p>Why? Because — remember Layer 1 — these “reads” are EVAL<strong> Lua scripts that can write</strong>. A Redis Cluster must route any command that <em>might</em> modify data to the <strong>master</strong>. So every one of these lookups went to the master; the replicas we provisioned to absorb reads <strong>never saw a single one.</strong> The read-scaling we thought we had was silently cancelled by <em>how</em> the read was expressed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WK3diOW2ciPlM0hMH8X0QA.jpeg" /></figure><h3>Then the walls close in</h3><p>By now the cause is clear. The real surprise is how every obvious escape is already blocked:</p><ul><li><em>“Keep a copy inside each pod.”</em> → But the cache <strong>must be shared</strong> across pods — the duplicate may arrive elsewhere. A local-only copy changes the meaning.</li><li><em>“Let Redis expire fields natively instead of emulating it.”</em> → Native per-field TTL arrived in a <strong>newer Redis version</strong> than the one in production. Not available to us.</li><li><em>“Drop </em>RMapCache<em> for a plain map.&quot;</em> → A plain Redis map has <strong>no TTL and no max-size</strong> — and we need <em>both</em>. We&#39;d trade a CPU problem for an out-of-memory one.</li><li><em>“Index by the dedup key.”</em> → As we saw, <strong>regex/contains criteria have no single key.</strong> No general shortcut exists.</li></ul><p>Every lever is pinned by a constraint you didn’t know mattered until you reached for it.</p><h3>The honest ending</h3><p>Here’s what they don’t teach early enough: <strong>there is no clean solution here.</strong> No single switch makes it right. There’s only a set of trade-offs, and the engineering work is choosing the one that best fits <em>your</em> reality — your scale, your tolerance for staleness, your Redis version, your team.</p><p>Will you accept slightly <strong>stale</strong> reads from replicas to offload the master? <strong>Cap</strong> how much you keep and risk missing a match? Move the scan <strong>off the hot path</strong> and carry new complexity elsewhere? Change <strong>how fresh</strong> “in-transit” needs to be? Each choice buys something and costs something. None is simply <em>correct</em>.</p><p>And that’s the real lesson for anyone starting out. The hardest problems in real systems are rarely one exotic, impossible thing. They’re a handful of perfectly reasonable decisions — a shared cache, a short TTL, a convenient library feature, a standard cluster layout, a flexible matching rule — that quietly constrain one another until the space of good answers narrows to a needle’s eye.</p><p>Learning to <em>see that web</em> — and to pick your trade-off with open eyes instead of chasing a fix that doesn’t exist — is a huge part of what it means to grow as an engineer.</p><p><em>(Part 1 — the problem. And seeing it clearly is half of solving it.)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed61bb7d540c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Kafka Streams: State Management, Topics, and Threading]]></title>
            <link>https://medium.com/@rakeshvende/understanding-kafka-streams-state-management-topics-and-threading-0035fb38114c?source=rss-ab42d6405d76------2</link>
            <guid isPermaLink="false">https://medium.com/p/0035fb38114c</guid>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[kafka-streams]]></category>
            <category><![CDATA[kafka]]></category>
            <dc:creator><![CDATA[Rakesh Vende]]></dc:creator>
            <pubDate>Fri, 14 Mar 2025 12:58:08 GMT</pubDate>
            <atom:updated>2025-03-19T03:43:33.928Z</atom:updated>
            <content:encoded><![CDATA[<p>Kafka Streams is a powerful library for building real-time stream processing applications on top of Apache Kafka. While it abstracts much of the complexity of distributed systems, understanding its internal mechanisms — like state stores, changelog topics, repartition topics, and threading — is essential for designing robust and efficient applications. In this blog, I’ll walk you through some common questions I’ve encountered while working with Kafka Streams, presenting them as real-world use cases. Let’s dive in!</p><p><strong>Introduction</strong></p><p>When I first started working with Kafka Streams, I was amazed by how it simplified stream processing with its high-level DSL. But as I dug deeper — whether troubleshooting a stuck thread or scaling an application — I realized that knowing what’s happening under the hood is key.</p><p><strong>Section 1: State Stores in Kafka Streams</strong></p><p><strong>Use Case:</strong> You’re building an application to count user events in real time. You need to maintain this state across records and want to know how Kafka Streams makes it happen.</p><p><strong>Explanation:</strong><br>Kafka Streams uses <strong>state stores</strong> to keep track of stateful data, like counts or aggregates. These are key-value stores where the key might be something like a user ID, and the value is the state (e.g., event count). There are two flavors:</p><ul><li><strong>In-memory stores</strong>: Super fast but limited by RAM.</li><li><strong>Persistent stores</strong>: Backed by RocksDB, they’re durable and can handle larger datasets.</li></ul><p>State stores are tied to operations like aggregate or count. To ensure durability, each store is paired with a <strong>changelog topic</strong> in Kafka, which logs every state update. If your app crashes or rebalances, it can rebuild the state from this topic. Here your offset strategry is very important, in stateful use cases; you may want to keep offset stragery as <strong>earliest</strong> or <strong>latest</strong> based on your use case.</p><p><strong>Section 2: Consumer Group Behavior with Offset Strategies</strong></p><p><strong>Use Case:</strong> Imagine you’re setting up a Kafka Streams application to process <em>entity heartbeat activity logs</em>. You need to decide whether to use the earliest or latest offset reset strategy, but you’re unsure how they behave after offsets are committed.</p><p><strong>Explanation:</strong><br>In Kafka, the offset reset strategy defines <strong>where a consumer starts reading from a partition when there’s no valid committed offset</strong>. Here’s how it works:</p><ul><li><strong>earliest</strong>: If no offset is committed — or if the committed offset is invalid (say, deleted due to retention) — the consumer begins at the oldest message in the partition. Once an offset is committed, it picks up from the next message after that offset. If that offset is no longer available, it falls back to the earliest available record.</li><li><strong>latest</strong>: Without a committed offset, or if it’s invalid, the consumer starts at the end of the partition, only processing new messages as they arrive. After an offset is committed, it continues from the next message. If the committed offset is gone, it jumps to the latest message, potentially skipping some data.</li></ul><p><em>Entity Hertbeat Activity Logs</em> use case — Imagine you’re tracking “heartbeat” activity logs for different entities — think of these as signals that tell you whether something is active or not. You’re interested in two things: entities that are sending heartbeats and those that aren’t. Let’s say your app crashes for a while, and during that downtime, some entities stop sending heartbeat data. You’d want to figure out which ones went silent while the app was offline. Using the “earliest” strategy can help here — it lets you look back at which entities were sending heartbeats before the crash but stopped during the downtime. The catch? This approach means digging through a lot of past data, which could slow things down and cause delays for the stream processing it.</p><p>Once offsets are committed, both strategies behave similarly — continuing from the last committed point — unless retention or errors invalidate that offset. <strong>This understanding helped me choose earliest for reprocessing historical data and latest for real-time monitoring.</strong></p><p><strong>Section 3: State Stores and Changelog Topics</strong></p><p><strong>Use Case:</strong> You’ve enabled state stores and noticed changelog topics popping up in your Kafka cluster. You’re curious about how they work together during processing and recovery.</p><p><strong>Explanation:</strong><br>Here’s the step-by-step flow I pieced together:</p><ol><li><strong>Startup</strong>: When your Kafka Streams app starts, it initializes state stores based on your topology.</li><li><strong>Processing</strong>: As records flow in, the state store updates (e.g., incrementing a counter), and those changes are written to the changelog topic.</li><li><strong>Recovery</strong>: If a task fails or moves to another instance, Kafka Streams restores the state by replaying the changelog topic.</li></ol><p>Each state store gets its own changelog topic, acting like a safety net. This process clicked for me when I saw my app recover from a restart without losing any aggregated data.</p><p><strong>Section 4: Partitioning of State Stores</strong></p><p><strong>Use Case:</strong> Your app is scaling across multiple instances, and you’re wondering whether each partition gets its own state store.</p><p><strong>Explanation:</strong><br>In Kafka Streams, state isn’t tied directly to partitions but to <strong>tasks</strong>. Each task processes one or more partitions and has its own instance of the state store. So, if a task handles two partitions, it maintains state for both in a single store instance. This keeps state local to the task, making scaling straightforward. I found this design brilliant — it ensures parallelism without duplicating state unnecessarily.</p><p><strong>Section 5: Significance of Repartition Topics</strong></p><p><strong>Use Case:</strong> You notice repartition topics in your cluster and wonder why they’re there.</p><p><strong>Explanation:</strong><br>Repartition topics come into play when Kafka Streams needs to redistribute data based on a new key — like before a groupBy or join operation. They ensure all records with the same key end up in the same partition for stateful processing. I encountered this when I needed to group events by a different key than their original one — it’s Kafka Streams’ way of reshuffling the deck.</p><p><strong>Section 6: Creation of Changelog and Repartition Topics</strong></p><p><strong>Use Case:</strong> You’re designing a stream topology and want to know when changelog and repartition topics get created.</p><p><strong>Explanation:</strong></p><ul><li><strong>Changelog topics</strong>: Created automatically for every state store to log updates.</li><li><strong>Repartition topics</strong>: Triggered when you change a record’s key (e.g., via selectKey or groupBy) and follow it with a stateful operation needing key-based partitioning.</li></ul><p><strong>Section 7: Threads and State Management in Kafka Streams</strong></p><p><strong>Use Case:</strong> Imagine you’re knee-deep in debugging a Kafka Streams application. You’re trying to figure out which threads are updating the state store and producing data to the changelog topic. You also want to know the sequence of events — does the state store get updated before or after the changelog topic is written to? And is the consumer thread handling everything in the processing pipeline? Let’s break it down step by step.</p><p><strong>Which Threads Produce Data into the Changelog Topic?</strong></p><p>In Kafka Streams, the star of the show is the <strong>StreamThread</strong>. This thread is the workhorse that drives most of the action:</p><ul><li><strong>What It Does</strong>: The StreamThread consumes records from your input topics, processes them according to your application’s logic (think filters, maps, or aggregations), and produces output records to downstream topics.</li><li><strong>State Management</strong>: When your processing involves state — like tracking a running count or maintaining a table — the StreamThread updates the state store (whether it’s in-memory or persistent, like RocksDB).</li><li><strong>Changelog Updates</strong>: Right after updating the state store, the StreamThread sends a record to the changelog topic. This changelog acts as a log of state changes, making it possible to recover the state if something goes wrong, like a crash or a partition rebalance.</li></ul><p>There’s another thread called the <strong>StateUpdater</strong>, but it doesn’t produce to the changelog topic. Its job is to restore the state store by consuming from the changelog topic during recovery or startup — not to write to it.</p><p><strong>Bottom Line</strong>: The StreamThread is the one responsible for producing data into the changelog topic after it updates the state store.</p><p><strong>Does Kafka Streams Update the State Store Before Producing to the Changelog Topic?</strong></p><p>Yes, and this order matters! Here’s how it works:</p><ul><li><strong>Step 1: State Store Update</strong>: When a stateful operation happens (e.g., incrementing a counter or updating a key-value pair), the StreamThread first updates the state store.</li><li><strong>Step 2: Changelog Write</strong>: Immediately after the state store is updated, the StreamThread produces a record to the changelog topic to log that change.</li></ul><p>Why this sequence? It’s all about consistency and reliability. Updating the state store first ensures that the in-memory state is always accurate before the change is logged. The changelog topic then serves as a durable backup, so Kafka Streams can rebuild the state store if needed — like after a failure. This design balances performance (fast in-memory updates) with fault tolerance (persistent logging).</p><p><strong>Is the Consumer Thread Doing the Entire Stream Processing?</strong></p><p>In Kafka Streams, the StreamThread is more than just a consumer — it’s an all-in-one powerhouse:</p><ul><li><strong>Consuming</strong>: It pulls records from your input topics.</li><li><strong>Processing</strong>: It runs your defined logic, like transformations or aggregations.</li><li><strong>State Handling</strong>: It updates state stores and writes to changelog topics as needed.</li><li><strong>Producing</strong>: It sends the processed records to output topics.</li></ul><p>So, yes, the StreamThread handles the entire stream processing pipeline. Unlike a basic Kafka consumer that only reads messages, the StreamThread in Kafka Streams is a multi-tasker, managing the full lifecycle of each record from input to output.</p><p><strong>Pro Tip</strong>: If you’re troubleshooting slow processing or stuck threads, knowing that the StreamThread does it all can help you pinpoint bottlenecks — whether it’s in consumption, processing, or state management.</p><p><strong>Conclusion</strong></p><p>Kafka Streams does a fantastic job of hiding the complexity of distributed stream processing, but peeking under the hood — like understanding how the StreamThread juggles state updates and changelog writes — can make you a better developer. In this section, we’ve seen how the StreamThread powers the processing pipeline, updates state stores before logging changes, and ensures your application stays both fast and resilient. These insights have helped me debug and optimize my own Kafka Streams apps, and I hope this blog, born from my own questions and explorations, helps you understand Kafka Streams too!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0035fb38114c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Agentic AI: History, Concepts, Workflow and Use Cases]]></title>
            <link>https://medium.com/@rakeshvende/exploring-agentic-ai-history-concepts-workflow-and-openai-o1-model-3aad1fef2095?source=rss-ab42d6405d76------2</link>
            <guid isPermaLink="false">https://medium.com/p/3aad1fef2095</guid>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <dc:creator><![CDATA[Rakesh Vende]]></dc:creator>
            <pubDate>Wed, 01 Jan 2025 14:17:57 GMT</pubDate>
            <atom:updated>2025-01-02T06:49:35.855Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p>Imagine a world where your home adjusts the temperature autonomously, your vehicle drives you safely to your destination without your input, or your health is monitored continuously by an AI that can diagnose issues even before you feel them. This isn’t the stuff of science fiction; it’s the realm of <strong>Agentic AI</strong>.</p><p><strong>Agentic AI</strong> refers to artificial intelligence systems designed to act <strong>autonomously </strong>towards achieving specific objectives, much like a human agent would. These systems <strong>perceive </strong>their environment, make <strong>decisions</strong>, and execute <strong>actions </strong>to fulfil their goals, often with little to no human intervention. Today, we’ll delve into the history, core concepts, architectural framework, use cases and how OpenAI o1 model is significant step for Agentic AI future.</p><p><strong>What is Agentic AI, how it differs from traditional AI?</strong></p><p>Pre-generative AI focused on predictive and reinforcement learning models, which excelled at pattern recognition. Predictive models used algorithms to forecast future events based on historical data, while reinforcement learning models learned optimal actions through reward-based trial and error, impacting areas like gaming and logistics. These approaches set the stage for more advanced AI by showing how machines could learn from experience.</p><p>Post-generative AI marks an era where AI systems can create new content, such as text, images, or music, based on learned patterns from vast datasets. Technologies like large language models (e.g., GPT) and image generators (e.g., DALL-E) exemplify this shift, enabling not just the recognition but also the generation of novel, human-like outputs. This advancement has transformed creative industries, personalized content delivery, significantly expanding AI’s role from merely <strong>interpreting to actively creating</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*PQUhCne_7lhizAE7REOhsQ.jpeg" /></figure><p><strong>Chain of Thought Reasoning</strong> — What differs Agentic AI is chain of thought reasoning capabilities.</p><p><strong>Agentic AI</strong></p><p>If you dwell into details of Agentic AI concept, high level, you will find below components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*iUUnZgSeWWB02yDM-eljGg.jpeg" /></figure><p><strong>Perception</strong>: These systems gather data through various sensors or digital inputs, understanding their context. This could serve as an interface where natural language processing is utilized to analyse and comprehend the user’s intended actions or queries.</p><p><strong>Planning and Reasoning</strong>: This aspect of agent makes it <strong>autonomous</strong>. Agentic AI makes decisions based on its perception of the environment without needing constant human oversight. Using advanced algorithms, often including machine learning techniques like deep learning, agentic AI can plan actions to achieve desired outcomes.</p><p><strong>Action Execution</strong>: These agents perform tasks in the real or virtual world, adapting to new situations as they arise. Here agents are being able to call another agents, search the web, call the APIs through integrations and so on.</p><p><strong>Feedback Loop: </strong>A<strong> </strong>feedback loop involves testing the output against an ideal, pre-trained model output for accuracy. If discrepancies exist, the output is fed back to the agent for refinement, ensuring reliability and precision in operations.</p><p>Agentic AI being autonomous is the key aspect, it is able to dynamically adopt to changing conditions and this is possible because of planning and reasoning capabilities of AI models. OpenAI has recently launched the o1 model which has made significant growth in its reasoning capabilities.</p><p><strong>OpenAI o1 Model: </strong>The OpenAI o1 model, part of a new series focused on advanced reasoning capabilities, brings several notable features and improvements over previous models.</p><p><strong>Complex Reasoning: </strong>o1 is designed to handle complex, multi-step reasoning tasks. It uses a “chain of thought” approach, breaking down problems into smaller steps, which allows it to solve sophisticated problems in fields like mathematics, coding, and science.</p><p><strong>Performance Metrics (Mathematics) </strong>: In a qualifying exam for the International Mathematics Olympiad (IMO), o1 scored 83%, a significant improvement over the 13% achieved by GPT-4o.</p><p><strong>Use Cases</strong></p><p>Agentic AI is all about Autonomous Actions. Till now, we were able to detect the patterns, do predictive analysis, LLM enabled us to create chatbots/co-pilot helping machine answers to queries. With Agentic AI, its time to machines performing actions autonomously.</p><p>There are endless possibilities on use cases where agentic AI can do wonders. For example in healthcare arena, we can think of below agents performing unique actions.</p><p><strong>Personalized Medication Adjustment:</strong></p><p><strong>Action</strong>: Adjusting dosages or suggesting alternative medications based on real-time feedback from wearable devices.<br><strong>Example</strong>: For a diabetic patient, an AI agent analyses continuous glucose monitor (CGM) data and recommends insulin adjustments.</p><p><strong>Medical Imaging Analysis:</strong></p><p><strong>Action</strong>: Detecting early signs of diseases like cancer or cardiovascular conditions from medical scans.<br><strong>Example</strong>: An AI agent identifies subtle lung nodules in CT scans, reducing the time needed for radiologists to flag cases.</p><p><strong>Dynamic Resource Allocation:</strong></p><p><strong>Action</strong>: Optimizing hospital resources in real-time, such as ICU bed availability or staff allocation.<br><strong>Example</strong>: AI agents reallocate nursing staff based on patient load in different wards to reduce response times.</p><p><strong>Conclusion</strong><br>Agentic AI stands at the frontier of artificial intelligence, promising a future where machines can act more like partners than mere tools. However, this leap forward brings with it a suite of challenges that we must address thoughtfully. Balancing technological innovation with ethical considerations will be key to harnessing the full potential of agentic AI.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3aad1fef2095" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Transmitting Large Kafka Payloads: Best Practices and Strategies]]></title>
            <link>https://towardsdev.com/transmitting-large-kafka-payloads-best-practices-and-strategies-01b1ce7f9835?source=rss-ab42d6405d76------2</link>
            <guid isPermaLink="false">https://medium.com/p/01b1ce7f9835</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[software-design-principle]]></category>
            <dc:creator><![CDATA[Rakesh Vende]]></dc:creator>
            <pubDate>Tue, 17 Sep 2024 14:23:30 GMT</pubDate>
            <atom:updated>2024-09-19T18:28:56.013Z</atom:updated>
            <content:encoded><![CDATA[<p>Apache Kafka is renowned for its distributed, high-throughput messaging system, and is widely adopted in modern data platforms. However, transmitting large payloads over Kafka can be tricky, especially when working with messages larger than the default 1 MB limit. Large messages can cause bottlenecks, reduce performance, and even crash brokers if not handled properly.</p><p>This blog will cover essential techniques and best practices for sending large messages efficiently in Kafka, including increasing message size limits, using compression, optimizing batching, chunking and external stores.</p><p><strong>Understanding Kafka Message Size Limitations</strong></p><p>By default, Kafka imposes a message size limit of 1 MB (set by the max.message.bytes property). This constraint helps prevent performance issues like network latency, memory pressure, and uneven load balancing in the Kafka cluster. However, there are cases when transmitting large files—like logs, or bulk data—is unavoidable.</p><p>If you need to send large messages, Kafka allows you to increase the maximum message size, but doing so blindly can lead to several performance drawbacks.</p><h4>Increasing the Maximum Message Size</h4><p>To allow Kafka to handle larger messages, you can adjust the max.message.bytes configuration at both the broker and topic levels:</p><pre># Broker-level setting<br>max.message.bytes=10485760  # Example: 10 MB<br><br># Topic-level setting<br>bin/kafka-topics.sh --alter --topic &lt;topic_name&gt; --config max.message.bytes=10485760</pre><p>It’s important to note that increasing the message size affects memory and disk usage, and you must balance between the maximum allowed message size and available broker resources.</p><p>However, merely increasing the message size might not be sufficient. Large messages can strain network resources, cause high latency and create inefficiencies. To optimize the transmission of large payloads, additional strategies like compression and batching come into play.</p><p><strong>Using Compression to Optimize Large Message Transmission</strong></p><p>One of the most effective ways to reduce the size of large messages in Kafka is to use message compression. Kafka provides built-in support for several compression codecs, including:</p><ul><li><strong>GZIP</strong>: High compression ratio, but slower compression and decompression speed.</li><li><strong>Snappy</strong>: Lower compression ratio but faster.</li><li><strong>LZ4</strong>: Fastest compression, ideal for large messages.</li><li><strong>ZSTD</strong>: A relatively new codec offering a high compression ratio with faster speeds.</li></ul><p>Here’s how to enable LZ4 compression for better performance:</p><pre># Enable LZ4 compression in the producer configuration<br>compression.type=lz4</pre><p>You can set compression config on producer level, topic level and broker level. Compression config set on topic level will be applied to optimize storage on Kafka broker. Compression config set on producer level will be used for producer to broker communication. If compression config on producer matched with topic level then message will be written to disk as it is, no further compression/decompression will happen at broker side.</p><p>The table below provides guidance on commonly used compression type combinations and highlights situations where less common combinations may be worth exploring.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VWfvjNCWbzeq2deUsQP-vA.png" /><figcaption><a href="https://www.confluent.io/blog/apache-kafka-message-compression/"><em>https://www.confluent.io/blog/apache-kafka-message-compression/</em></a></figcaption></figure><p><strong>Batching Large Messages for Efficient Delivery</strong></p><p>There are few aspect that you need to aware of while using compression strategy. The most important one is Kafka Producer Batching. Smart batching allows Kafka to increase throughput while maintaining very low latency. Batching is mainly controlled by two producer settings — linger.ms and batch.size</p><p>Producers group messages in a batch before sending. This is done to save network trips. If the producer is sending compressed messages, all the messages in a single producer batch are compressed together and sent as the “value” of a “wrapper message”. Compression is more effective when bigger the batch of messages being sent to Kafka! You may want to set the batch size enough on which you would want to apply the compression as per your use cases. However, if your lingure.ms is set to 0, then the message will be sent right away which may be small in size and you end up spending unnecessary compression cost. You need to aptly set combination of batch size and lingure.ms setting.</p><p>After accomplishing all these tasks, you will still have to guess what max size of Kafka record you may get in worst case scenario, in few cases, it may be non-deterministic behaviour. You will also have to think of overhead associated with compression and decompression especially when not all the records getting produced are qualifying as large records.</p><h4>Splitting Messages into Chunks</h4><p>Sometimes, a single large message is simply too big to send, even with compression and batching. In such cases, splitting the large message into smaller chunks is an alternative strategy. You can break the payload into multiple smaller messages and reconstruct them at the consumer side.</p><p>This strategy requires a custom implementation where the producer splits large files into smaller parts, tags each part with a sequence ID, and the consumer reassembles the parts upon receiving all of them.</p><p>Best thing with this approach is we can virtually accommodate any size of payload while the downside here is we need to temporarily hold these chunks in-memory until all correlated chunks are received, this will have risk of potential data loss holding chunks in memory; handling this risk will add on to the complexity.</p><h4>Usage of External Store</h4><p>This will be helpful if payload size is really big. The use case here shifts from kind of sync data transmission to async data upload/download using external data store.</p><p>Large data is stored outside Kafka (e.g. Cloud Storage/RDBMS/Redis), and only metadata is sent through Kafka. This reduces Kafka’s load but introduces the challenge of managing external storage like cleaning the external store time-to-time.</p><h4>Conclusion</h4><p>Handling large messages in Kafka requires careful planning and optimization. By increasing the message size limits, using compression, and fine-tuning batching, you can transmit large Kafka payloads efficiently without sacrificing performance. However, it’s crucial to balance these configurations based on your use case to ensure smooth operations in production.</p><p>With these strategies in place, Kafka can handle larger workloads while maintaining its high throughput and low-latency guarantees.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01b1ce7f9835" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/transmitting-large-kafka-payloads-best-practices-and-strategies-01b1ce7f9835">Transmitting Large Kafka Payloads: Best Practices and Strategies</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>