<?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 Ht on Medium]]></title>
        <description><![CDATA[Stories by Ht on Medium]]></description>
        <link>https://medium.com/@ht976648?source=rss-3d167af838cb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*R56ORA4jswMjEko0</url>
            <title>Stories by Ht on Medium</title>
            <link>https://medium.com/@ht976648?source=rss-3d167af838cb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 17:22:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ht976648/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[How a Production Voice AI Pipeline Actually Works]]></title>
            <link>https://medium.com/@ht976648/how-a-production-voice-ai-pipeline-actually-works-f527c9e9460a?source=rss-3d167af838cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/f527c9e9460a</guid>
            <category><![CDATA[voice-ai]]></category>
            <category><![CDATA[pipecat]]></category>
            <category><![CDATA[livekit]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[conversational-ai]]></category>
            <dc:creator><![CDATA[Ht]]></dc:creator>
            <pubDate>Fri, 30 Oct 2026 18:29:27 GMT</pubDate>
            <atom:updated>2026-10-30T18:29:27.283Z</atom:updated>
            <content:encoded><![CDATA[<p><em>From VAD to turn detection to intent routing: the full architecture, how to make it scale, why it can replace “Press 1, Press 2” IVR systems, and how e-commerce platforms like Swiggy, Zomato and Blinkit can improve their tech with it.</em></p><p>Most people think a voice agent is just “speech to text, then LLM, then text to speech.” In a demo, that works. In production, that naive version feels broken: it interrupts you mid-sentence, waits too long to reply, and cannot handle a real customer request.</p><p>The difference between a demo and a product lives in the details of the pipeline. I have built voice agents for calling systems and for video (WebRTC), and this post walks through everything I learned, layer by layer: the voice pipeline itself, intent routing, multilingual support, the infrastructure around it (WebSockets, TLS, WebRTC, rate limiting, Redis, deployment), and the business case for replacing IVR.</p><h3>The pipeline at a glance</h3><pre>User speaks → VAD → STT (streaming) → Turn detection → Intent router<br>→ Specialist agent → LLM response → TTS (streaming) → User hears the reply</pre><pre>Mic audio<br>   |<br>   v<br>[VAD: Silero, local on CPU]      -- is a human speaking right now?<br>   |<br>   v<br>[STT: streaming over WebSocket]  -- partial transcripts in real time<br>   |<br>   v<br>[Turn detection]                 -- has the user finished their thought?<br>   |   LiveKit: semantic (text-based)<br>   |   Pipecat: Smart Turn (audio-based)<br>   v<br>[Intent router: confidence score vs threshold]<br>   |<br>   v<br>[Specialist agents: track / cancel / refund / ...]<br>   |<br>   v<br>[LLM tokens -&gt; streaming TTS over WebSocket]<br>   |<br>   v<br>Audio back to user</pre><h3>Layer 1: VAD (Voice Activity Detection)</h3><p>VAD answers one simple question for every tiny slice of audio (around 30 ms): is a human voice present, or is this silence and noise?</p><ul><li><strong>Silero VAD</strong> is the common choice. It is a small model that runs locally on CPU with very low latency.</li><li>It runs frame by frame on the live stream, not on a finished recording.</li><li>It does three jobs: it detects when the user starts speaking, it detects silence (which wakes up the turn detector), and it powers interruption handling (if the user talks over the agent, the agent stops).</li><li>Its limit: it only separates voice from noise. It does not know <em>who</em> is speaking. For that you need speaker diarization (for example pyannote, or the diarization option in services like Deepgram).</li></ul><h3>Layer 2: Speech to text, under the hood</h3><p>A transformer-based STT model works in an encoder-decoder pattern:</p><ol><li>The raw sound wave is cut into small chunks and converted into a (mel) spectrogram: time on the horizontal axis, frequency on the vertical axis, and color intensity showing energy.</li><li>The <strong>encoder</strong> turns that spectrogram into numeric representations.</li><li>The <strong>decoder</strong> reads those numbers and produces text tokens, which become the transcript.</li></ol><h3>Why streaming matters</h3><p>A voice agent cannot wait for you to finish a full paragraph before it starts transcribing.</p><ul><li>Deepgram (and others like AssemblyAI, Google, Azure) offer streaming over WebSocket: you push audio continuously and get partial transcripts back.</li><li>Open-source Whisper is built for chunks of audio (about 30 seconds), so it is not streaming out of the box. For live use you chunk it yourself or use wrappers like faster-whisper or whisper-streaming.</li></ul><p>WebSockets are the natural fit here because one connection stays open, so there is no new request overhead per audio chunk.</p><h3>Layer 3: Turn detection, the hard part</h3><p>Silence alone is a terrible signal. People pause mid-sentence to think. If the agent replies at every pause, it feels rude; if it waits too long, it feels slow. Turn detection decides: is this a mid-sentence pause, or the end of the turn?</p><h3>LiveKit: semantic turn detection (text-based)</h3><ul><li>A small transformer model runs locally on CPU.</li><li>When VAD detects silence, the model reads the transcript from the STT plus conversation context and estimates the probability that the sentence is complete.</li><li>“I want you to…” is clearly unfinished, so the agent waits. “Track my order” is complete, so it moves on.</li><li>Strength: it understands language and intent. Dependency: it relies on the STT transcript being fast and accurate.</li></ul><h3>Pipecat: Smart Turn (audio-based)</h3><ul><li>It works directly on the audio, not the transcript.</li><li>It analyzes the last few seconds of speech: pitch rising or falling, pacing, trailing off, filler sounds like “umm”. In other words, prosody, not just loudness.</li><li>Strength: it does not wait for STT, and prosody is similar across many languages. It is open source and runs locally.</li></ul><h3>Why they pair well with VAD</h3><p>VAD is the cheap, always-on trigger: it detects speech and silence. The turn detector is the smarter judge that only activates when silence appears. VAD notices the pause; the turn detector decides whether the pause is real.</p><p>Both frameworks have their own strengths. In my experience, LiveKit’s semantic approach has been the stronger fit for building conversational support agents, while Pipecat’s audio-based approach is attractive when you want the lowest latency and language-independent behavior.</p><h3>Layer 4: Intent routing and multi-agent design</h3><p>Here is the upgrade that makes this production-ready: <strong>do not send the user’s text straight to one big LLM.</strong></p><p>Instead:</p><ol><li>A lightweight decision model reads the full utterance and understands its <em>semantic meaning</em>.</li><li>It outputs an intent and a confidence score.</li><li>The score is compared against a threshold:</li></ol><ul><li><strong>High confidence:</strong> route directly to the right specialist agent (track order, cancel order, refund).</li><li><strong>Low confidence:</strong> ask a clarifying question, or escalate to a human.</li></ul><ol><li>The specialist agent performs the actual task using its own tools and APIs.</li></ol><p><strong>Benefits:</strong> faster responses, lower cost, fewer hallucinations, easier testing (each agent does one job), and a safe fallback when the system is unsure.</p><h3>Semantic routing vs. LLM-based routing</h3><p>The common alternative is to hand the prompt to an LLM and let it decide which tool to call or which agent to route to. Frameworks like the Vercel AI SDK and the OpenAI SDK make that easy, and it works. But every routing decision costs an LLM call, which adds latency and money, and at call-center volume that adds up fast.</p><p>Semantic routing is cheaper: embed the utterance, compare it against example utterances for each intent, compute a similarity score, and apply the threshold. Only if the score is low do you fall back to an LLM. Ready-made platforms like Vapi exist, but I preferred to build my own so I could control the routing logic, the thresholds, and the cost.</p><h3>Multilingual support</h3><p>In India, one customer speaks Hindi, the next Marathi, then Malayalam or Gujarati. This is where semantic routing shines: <strong>the meaning of “I want to cancel my order” is the same in every language.</strong> With a multilingual STT model and a multilingual embedding model, the same intent router works across languages without maintaining a separate rule set for each one. Language becomes a detail of the first and last layers (STT and TTS), while the middle of the pipeline stays unchanged.</p><h3>Layer 5: Response and streaming TTS</h3><p>The LLM generates tokens, and we do not wait for the full answer.</p><ul><li>Tokens are grouped into sentences or phrases and sent to the TTS over WebSocket (services like ElevenLabs and Cartesia support this).</li><li>Audio chunks come back and play immediately, while the LLM is still writing the rest.</li><li>Result: LLM generation, TTS synthesis, and playback overlap, so time to first audio drops sharply. <strong>The metric that matters is the gap between the user finishing and the agent’s first sound.</strong></li></ul><h3>Connecting it to real phone calls: Twilio, ngrok and WebSockets</h3><p>For my calling system, the entry point is Twilio. Twilio streams the call audio to my server over a WebSocket (Media Streams), as base64-encoded audio chunks. My server forwards that audio to Deepgram over a second WebSocket, and the transcript flows into the rest of the pipeline.</p><p>During development there is one practical problem: Twilio needs a public address, and a laptop does not have one. <strong>ngrok</strong> solves this by exposing your local server on a public URL, so Twilio can reach the code running on your machine.</p><h3>What a WebSocket actually is</h3><p>A WebSocket is a persistent, full-duplex, bi-directional connection: both sides can send data at any time over one open connection.</p><ol><li>It starts as a normal HTTP request. The client asks to upgrade the connection.</li><li>The server replies with <strong>101 Switching Protocols</strong>, and from then on the connection speaks WebSocket.</li><li>ws:// is unencrypted. wss:// runs over TLS, and is what you should use in production.</li></ol><h3>How TLS makes it safe</h3><p>When you open a site over HTTPS, a few things happen:</p><ol><li>The client and server first set up a TCP connection (the SYN, SYN-ACK, ACK handshake).</li><li>Then the TLS handshake begins. The server sends its <strong>certificate</strong>, which carries its public key and is digitally signed by a trusted Certificate Authority.</li><li>The client verifies that signature against the CAs it already trusts. This proves the server is who it claims to be.</li><li>The two sides then agree on a shared secret using a key exchange algorithm such as <strong>Diffie-Hellman</strong> (or its elliptic-curve variant, ECDHE; elliptic curve cryptography is the same family of math used by blockchains).</li><li>From then on, all traffic is encrypted with fast symmetric keys derived from that secret.</li></ol><h3>WebSockets vs. WebRTC</h3><p>I have also built agents over WebRTC (for video), and the difference is worth understanding.</p><p>With WebSockets, if peer A wants to send data to peer B, it goes through a central server over TCP. TCP guarantees delivery and ordering, which is great for important data and bad for live media, because a lost packet makes everything behind it wait.</p><p><strong>WebRTC</strong> connects the two peers directly, and it uses UDP for the media. For live audio and video, a lost frame is better skipped than retransmitted late. The flow looks like this:</p><ol><li><strong>Signaling:</strong> the peers still need to exchange setup information (codecs, network details, addresses) reliably. This happens over a WebSocket, because that information cannot be lost.</li><li><strong>Offer and answer:</strong> peer A creates an offer, peer B accepts it and sends back an answer.</li><li><strong>NAT problem:</strong> most devices are behind a NAT and do not know their own public address. <strong>STUN</strong> servers tell a device what its public address looks like, so the peers can try to connect directly.</li><li><strong>TURN fallback:</strong> with symmetric NATs or strict firewalls, a direct connection fails. A <strong>TURN</strong> server then relays the media between the peers. It always works, but it adds a hop, more latency and more cost, so it is the fallback rather than the default.</li></ol><h3>Rate limiting across containers with Redis</h3><p>Voice agents call paid external APIs: ElevenLabs, Deepgram, OpenAI. Without rate limiting, one bug or one abusive caller can burn through your quota or your budget.</p><p>A rate limiter written in Go (or any language) keeps its counters in the memory of one process. That works for a single container. But once you run 10 containers or 20 Kubernetes pods, each has its own memory, so each enforces its own limit and the global limit is meaningless. The fix is a shared store, and <strong>Redis</strong> is built for exactly this: every instance checks Redis before calling the external API.</p><h3>The algorithms</h3><p><strong>Token bucket.</strong> A bucket holds a fixed number of tokens and refills at a fixed rate. Each request takes a token; if the bucket is empty, the request is rejected. It allows short bursts while enforcing an average rate.</p><p><strong>Leaky bucket.</strong> Requests enter a bucket and leave at a fixed rate. It smooths traffic into a constant outflow, so the downstream system never sees more than the fixed rate, no matter how bursty the input.</p><p><strong>Fixed window counter.</strong> Count requests in fixed windows (say, one minute) and reject once the limit is hit. It is simple and good for things like OTP limits, but it has a boundary flaw. With a limit of 10 per minute, a client can send 10 requests at 0:58 and 10 more at 1:03. Each window sees 10, yet 20 requests passed in five seconds.</p><p><strong>Sliding window log.</strong> Store the timestamp of every request and count how many fall in the last 60 seconds. It is exact and has no boundary problem, but it stores a timestamp per request, so memory grows with traffic, O(N).</p><p><strong>Sliding window counter.</strong> The best balance, and the one I use most. It keeps only two counters, the previous window and the current one, and weights the previous one by how much of it still overlaps the sliding window:</p><pre>estimated = previous_count × ((window_size − time_elapsed_in_current_window) / window_size) + current_count</pre><p>If estimated is under the threshold, the request passes; otherwise it is rejected. With a limit of 100 per minute, an estimate of 90 passes and 110 is rejected. It avoids the boundary problem of the fixed window and the memory cost of the log.</p><h3>Why Redis fits</h3><p>Redis is an in-memory data store that executes commands on a single thread. Its event loop processes ready sockets one at a time, and because every operation is in memory, it is extremely fast. Single-threaded execution also means its operations are atomic, which is exactly what a distributed rate limiter needs.</p><p>It also ships useful</p><p>data structures: hashes (key-value maps), and <strong>sorted sets</strong>, which power things like a LeetCode-style leaderboard, where each user is stored with a score and the set stays ordered by rank.</p><p>Can Redis be used as a database? It is primarily an in-memory store, and memory is volatile: if the machine loses power, the data is gone. But Redis offers two persistence mechanisms: <strong>RDB snapshots</strong> (periodic dumps you can copy to S3 or other blob storage) and the <strong>AOF</strong> (append-only file), which logs every write so the state can be replayed. So it can be durable, but it is best used for what it is great at: caching, counters, queues and leaderboards. And because Redis speaks a simple protocol over TCP, you can even talk to it from a custom TCP client using Go’s net package.</p><h3>Concurrency: Python vs. Node.js</h3><p>Two runtime details matter when you build voice agents.</p><p><strong>Python and the GIL.</strong> CPython has a Global Interpreter Lock, a mutex that lets only one thread execute Python bytecode at a time. For CPU-bound work, threads do not run in parallel. For I/O-bound work, which voice agents mostly are (waiting on sockets and APIs), the lock is released while waiting, so threads and asyncio work well. For CPU-heavy parts, use multiple processes or native libraries.</p><p><strong>Node.js: V8 and libuv.</strong> JavaScript runs on a single thread in the V8 engine, but Node uses <strong>libuv</strong>, which provides the event loop and a thread pool for blocking work like file and DNS operations. Promise callbacks go to the microtask queue, which is drained first, while setTimeout and setInterval callbacks go to the task (macrotask) queue. The event loop picks tasks and hands them to V8. This is what makes Node non-blocking: it never sits waiting on I/O.</p><h3>Deployment</h3><p><strong>AWS Lambda</strong> is attractive because you pay only for the time your code actually runs: execute for one second, pay for one second. It is a great fit for the stateless parts of the system, like intent routing, tool calls and webhooks. One caveat: Lambda is not designed for long-lived streaming connections, so for the live audio WebSocket layer you typically want a persistent server, such as a container or an EC2 instance.</p><p><strong>EC2 with PM2.</strong> When running several Node.js services on the same EC2 instance, <strong>PM2</strong> is a process manager that keeps them alive, restarts them on crashes, and lets you monitor them easily (pm2 start, pm2 restart, pm2 logs, pm2 monit). If you run WebRTC on EC2, remember that you will also need STUN/TURN servers so peers behind NATs can connect.</p><h3>The business case: replacing IVR</h3><p>We all know it: “Press 1 for orders, press 2 for refunds, press 9 to speak to an agent.” It is slow, frustrating and rigid. It is also what customers of Blinkit, Zomato, Swiggy and Flipkart hear every day.</p><p>This architecture can replace it end to end:</p><ul><li>A customer says, in natural language and in their own language, “My order from yesterday hasn’t arrived, and I want a refund.”</li><li>VAD and turn detection let the conversation flow without awkward cut-offs.</li><li>The intent router picks the right agent with a confidence check.</li><li>The specialist agent tracks the order, cancels it, or processes the refund.</li><li>Humans are involved only when confidence is low or the case is complex.</li></ul><p>These companies handle millions of support calls a day, most of them repetitive (track, cancel, refund). That is exactly where this pipeline fits.</p><h3>Recommendations for Swiggy, Zomato, Blinkit and other e-commerce platforms</h3><p>Quick-commerce and food-delivery support is a near-perfect fit for this pipeline: the requests are short, repetitive, time-sensitive and tied to a live order. These are the upgrades I would make, in order of impact.</p><ol><li><strong>Replace the IVR menu with intent routing first.</strong> Start with the three highest-volume intents: <em>where is my order</em>, <em>cancel my order</em> and <em>refund / missing item</em>. Each becomes a specialist agent with its own tools (order tracking API, cancellation API, refund API), and everything else escalates to a human.</li><li><strong>Give the agent the order context before the customer speaks.</strong> The caller’s phone number already identifies their latest order. Load order status, rider location and ETA into the agent up front, so “where is my order?” is answered in one sentence instead of a five-question dialogue.</li><li><strong>Support Hindi, Marathi, Malayalam, Gujarati and more from day one.</strong> Use a multilingual STT model and a multilingual embedding model for routing. Customers in tier-2 and tier-3 cities, and delivery partners themselves, speak in their own language, and the intent is identical in every language.</li><li><strong>Tune turn detection for noisy, real-world calls.</strong> Customers call from roads, kitchens and markets. Combine local VAD with a turn detector, and test on real noisy audio, not studio recordings, so the agent neither cuts people off nor waits too long.</li><li><strong>Use confidence thresholds and a safe human handoff.</strong> Below the threshold, ask one clarifying question. After two failed attempts, or for angry customers, payment disputes and safety issues, transfer to a human with the transcript and detected intent attached, so the customer never repeats themselves.</li><li><strong>Make refunds a guarded action.</strong> Let the agent refund automatically only within clear rules (amount caps, order status, abuse checks), and log every decision. This keeps the cost savings without opening a fraud hole.</li><li><strong>Control cost and latency at scale.</strong> Route with embeddings and call an LLM only for low-confidence cases, stream STT and TTS, and use Redis-based shared rate limiting so a traffic spike or a bug cannot exhaust Deepgram, ElevenLabs or OpenAI quotas across hundreds of pods.</li><li><strong>Measure what matters.</strong> Track time to first audio, intent accuracy, containment rate (calls solved without a human), escalation rate and customer satisfaction, and review misrouted calls every week to add new example utterances.</li><li><strong>Extend beyond support.</strong> The same pipeline can power proactive calls (delivery delay updates, address confirmation for cash-on-delivery orders), voice ordering and rider or restaurant partner support, which are all costly to handle manually today.</li></ol><p>The point is not to remove humans. It is to let them handle the hard 20% of calls, while the pipeline handles the repetitive 80% instantly, in any language, at any hour.</p><h3>What I would tell companies building in this space</h3><p>Stop bolting an LLM onto an IVR menu. Build the full pipeline:</p><ul><li>local VAD</li><li>proper turn detection</li><li>streaming STT and TTS</li><li>an intent-routed, multi-agent layer with confidence thresholds and human fallback</li><li>multilingual support from day one</li><li>shared rate limiting (Redis) so one bad caller cannot drain your API budget</li></ul><p>That is what makes voice support feel human and scale economically.</p><p><strong>The future of customer support isn’t a smarter menu. It’s no menu at all.</strong></p><p><em>Voice AI is not one model. It is a pipeline, and every layer decides whether it feels magical or broken.</em></p><p><em>#VoiceAI #AgenticAI #LiveKit #Pipecat #LLM #CustomerSupport #MultiAgentSystems</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f527c9e9460a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[# I Stopped Building One Smart Agent. I Started Building a Team.]]></title>
            <link>https://medium.com/@ht976648/i-stopped-building-one-smart-agent-i-started-building-a-team-4c2cf1e2edd4?source=rss-3d167af838cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c2cf1e2edd4</guid>
            <dc:creator><![CDATA[Ht]]></dc:creator>
            <pubDate>Thu, 30 Jul 2026 22:39:31 GMT</pubDate>
            <atom:updated>2026-07-30T22:39:31.099Z</atom:updated>
            <content:encoded><![CDATA[<p>### What broke when my voice AI tried to do everything alone – and what changed when I split it into 5 agents</p><p>– -</p><p>## The 1am Debugging Session That Started This</p><p>A few months back I was running a voice calling agent – Twilio for the phone stuff, Deepgram turning speech into text, ElevenLabs turning replies back into speech. One big LLM sat in the middle doing everything: figuring out intent, pulling context, writing the reply, hoping it was right.</p><p>It worked great in demos. It fell apart in production.</p><p>Someone would call in with something even slightly layered – a question that needed a document lookup *and* a judgment call *and* a specific tone – and the single model would just… buckle. The answer would come back a little off. And the worst part wasn’t the wrong answer, it was not knowing *why* it was wrong. Was it a bad retrieval? A misread intent? The model just having an off moment? No way to tell. One giant prompt, one black box.</p><p>That’s when I stopped trying to make the model smarter and started trying to make the *system* smarter.</p><p>## Stop Hiring One Genius. Hire a Team.</p><p>Here’s the shift, in plain terms: instead of one model trying to plan, retrieve, write, and quality-check all in a single pass, I split those jobs across specialized agents that hand off to each other. Same idea as any team that actually functions – you don’t ask one person to be the strategist, the builder, and the editor at the same time and expect consistent output.</p><p>The repo – `multi-calling-agent-with-knowledge-base-orchestrator-agent` – is basically that team, coded up:</p><ul><li>**Planner** – the first agent to touch a request. Its only job is figuring out what’s actually being asked and routing it to whoever should handle it.</li><li>- **Coder** – handles the structured, technical, rule-based stuff. Anything that needs precision over vibes.</li><li>- **Vision** – deals with anything visual or document-derived – context pulled from ingested PDFs, mostly.</li><li>- **General** – the conversational one. Normal back-and-forth that doesn’t need a specialist.</li><li>- **Reviewer** – the last checkpoint. Before anything reaches the caller, this agent checks it against what was actually retrieved and catches stuff that doesn’t hold up.</li></ul><p>Each one’s its own class, doing one job. Which sounds like a small thing until you’re debugging at midnight and you can actually go “okay, the Planner routed this wrong” instead of staring at one wall of model output wondering what went sideways.</p><p>## Fixing Hallucinations Wasn’t About the Agents. It Was About What Feeds Them.</p><p>Multi-agent architecture solves *coordination*. It does nothing for *making stuff up* unless you also fix what the agents are working with.</p><p>Two things feed real information in instead of letting the model guess:</p><ul><li>**Zendesk KB integration** – so answers come from the same documentation human support already trusts, not from the model’s imagination.</li><li>- **PDF RAG pipeline** – documents get chunked and embedded, and only the relevant chunk gets pulled in at query time. No stuffing entire PDFs into every prompt and hoping for the best.</li></ul><p>The Reviewer agent leans on this directly – it’s checking generated answers against what was *actually retrieved*, not just against “does this sound like a reasonable sentence.”</p><p>## Memory as a Graph, Not a Growing Transcript</p><p>Most systems handle memory by just… keeping a longer and longer transcript, then summarizing it when it gets too big. That’s not memory, that’s a log with a lossy compression problem.</p><p>This one uses Neo4j instead – a graph. Callers, past issues, resolutions – they’re nodes. The relationships between them are edges. So “has this person mentioned this before” isn’t a search through pages of old transcript, it’s a graph traversal. It’s a fundamentally different way to ask the question.</p><p>This lines up with the bigger agentic-memory work I’ve been doing with the OpenClaw Research Group too – memory that’s structured and queryable, not just a context window that eventually falls off the end and gets forgotten.</p><p>## The Boring Part Nobody Posts About</p><p>Here’s the bit that doesn’t make it into most “look what I built” posts: none of the above works if the code is a mess.</p><p>The original version of this was one script doing everything – handling the call, hitting the LLM, generating a response, all tangled into each other. Before any of the agent stuff could exist, I had to rip that apart and rebuild it properly:</p><p>```</p><p>routes/ → where Twilio webhooks land</p><p>controllers/ → decides what happens with a request</p><p>services/ → the actual agent orchestration logic</p><p>adapters/ → talking to Deepgram, ElevenLabs, Zendesk, Neo4j</p><p>```</p><p>Nobody screenshots a refactor. There’s no dopamine hit for a clean folder structure. But this is the part that made everything else possible – you cannot cleanly bolt a 5-agent pipeline onto spaghetti code. This unglamorous restructuring is what turned a fragile demo into something that could actually hold up and be extended by someone who isn’t me.</p><p>## What Actually Changed</p><p>Putting it all together, here’s what I actually got out of this vs. the single-model version:</p><ul><li>I can tell **which agent** broke something, instead of guessing</li><li>- The Reviewer catches mismatches between retrieved context and generated answers, before the caller hears them</li><li>- Memory persists as relationships, not just a fading transcript</li><li>- Adding a new capability means adding a new agent – not rewriting a bloated prompt</li></ul><p>## Last Thought</p><p>There’s a line from the Gita – Nishkama Karma – do the work, don’t get attached to who claps for it. The refactor here is the perfect example. Nobody’s impressed by folder structure. But it’s the actual foundation everything flashy sits on top of. The multi-agent routing only works because of the boring layering underneath.</p><p>If you’re working on multi-agent orchestration, RAG pipelines, or graph memory – I’d genuinely like to compare notes. Drop a comment or hit me up.</p><p>Want a look at the repo? Comment below and I’ll send it over.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c2cf1e2edd4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[# I Stopped Building One Smart Agent. I Started Building a Team.]]></title>
            <link>https://medium.com/@ht976648/i-stopped-building-one-smart-agent-i-started-building-a-team-8b2249aeaec7?source=rss-3d167af838cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b2249aeaec7</guid>
            <dc:creator><![CDATA[Ht]]></dc:creator>
            <pubDate>Thu, 30 Jul 2026 22:29:26 GMT</pubDate>
            <atom:updated>2026-07-30T22:29:26.999Z</atom:updated>
            <content:encoded><![CDATA[<p>### What broke when my voice AI tried to do everything alone – and what changed when I split it into 5 agents</p><p>– -</p><p>## The 1am Debugging Session That Started This</p><p>A few months back I was running a voice calling agent – Twilio for the phone stuff, Deepgram turning speech into text, ElevenLabs turning replies back into speech. One big LLM sat in the middle doing everything: figuring out intent, pulling context, writing the reply, hoping it was right.</p><p>It worked great in demos. It fell apart in production.</p><p>Someone would call in with something even slightly layered – a question that needed a document lookup *and* a judgment call *and* a specific tone – and the single model would just… buckle. The answer would come back a little off. And the worst part wasn’t the wrong answer, it was not knowing *why* it was wrong. Was it a bad retrieval? A misread intent? The model just having an off moment? No way to tell. One giant prompt, one black box.</p><p>That’s when I stopped trying to make the model smarter and started trying to make the *system* smarter.</p><p>## Stop Hiring One Genius. Hire a Team.</p><p>Here’s the shift, in plain terms: instead of one model trying to plan, retrieve, write, and quality-check all in a single pass, I split those jobs across specialized agents that hand off to each other. Same idea as any team that actually functions – you don’t ask one person to be the strategist, the builder, and the editor at the same time and expect consistent output.</p><p>The repo – `multi-calling-agent-with-knowledge-base-orchestrator-agent` – is basically that team, coded up:</p><ul><li>**Planner** – the first agent to touch a request. Its only job is figuring out what’s actually being asked and routing it to whoever should handle it.</li><li>- **Coder** – handles the structured, technical, rule-based stuff. Anything that needs precision over vibes.</li><li>- **Vision** – deals with anything visual or document-derived – context pulled from ingested PDFs, mostly.</li><li>- **General** – the conversational one. Normal back-and-forth that doesn’t need a specialist.</li><li>- **Reviewer** – the last checkpoint. Before anything reaches the caller, this agent checks it against what was actually retrieved and catches stuff that doesn’t hold up.</li></ul><p>Each one’s its own class, doing one job. Which sounds like a small thing until you’re debugging at midnight and you can actually go “okay, the Planner routed this wrong” instead of staring at one wall of model output wondering what went sideways.</p><p>## Fixing Hallucinations Wasn’t About the Agents. It Was About What Feeds Them.</p><p>Multi-agent architecture solves *coordination*. It does nothing for *making stuff up* unless you also fix what the agents are working with.</p><p>Two things feed real information in instead of letting the model guess:</p><ul><li>**Zendesk KB integration** – so answers come from the same documentation human support already trusts, not from the model’s imagination.</li><li>- **PDF RAG pipeline** – documents get chunked and embedded, and only the relevant chunk gets pulled in at query time. No stuffing entire PDFs into every prompt and hoping for the best.</li></ul><p>The Reviewer agent leans on this directly – it’s checking generated answers against what was *actually retrieved*, not just against “does this sound like a reasonable sentence.”</p><p>## Memory as a Graph, Not a Growing Transcript</p><p>Most systems handle memory by just… keeping a longer and longer transcript, then summarizing it when it gets too big. That’s not memory, that’s a log with a lossy compression problem.</p><p>This one uses Neo4j instead – a graph. Callers, past issues, resolutions – they’re nodes. The relationships between them are edges. So “has this person mentioned this before” isn’t a search through pages of old transcript, it’s a graph traversal. It’s a fundamentally different way to ask the question.</p><p>This lines up with the bigger agentic-memory work I’ve been doing with the OpenClaw Research Group too – memory that’s structured and queryable, not just a context window that eventually falls off the end and gets forgotten.</p><p>## The Boring Part Nobody Posts About</p><p>Here’s the bit that doesn’t make it into most “look what I built” posts: none of the above works if the code is a mess.</p><p>The original version of this was one script doing everything – handling the call, hitting the LLM, generating a response, all tangled into each other. Before any of the agent stuff could exist, I had to rip that apart and rebuild it properly:</p><p>```</p><p>routes/ → where Twilio webhooks land</p><p>controllers/ → decides what happens with a request</p><p>services/ → the actual agent orchestration logic</p><p>adapters/ → talking to Deepgram, ElevenLabs, Zendesk, Neo4j</p><p>```</p><p>Nobody screenshots a refactor. There’s no dopamine hit for a clean folder structure. But this is the part that made everything else possible – you cannot cleanly bolt a 5-agent pipeline onto spaghetti code. This unglamorous restructuring is what turned a fragile demo into something that could actually hold up and be extended by someone who isn’t me.</p><p>## What Actually Changed</p><p>Putting it all together, here’s what I actually got out of this vs. the single-model version:</p><ul><li>I can tell **which agent** broke something, instead of guessing</li><li>- The Reviewer catches mismatches between retrieved context and generated answers, before the caller hears them</li><li>- Memory persists as relationships, not just a fading transcript</li><li>- Adding a new capability means adding a new agent – not rewriting a bloated prompt</li></ul><p>## Last Thought</p><p>There’s a line from the Gita – Nishkama Karma – do the work, don’t get attached to who claps for it. The refactor here is the perfect example. Nobody’s impressed by folder structure. But it’s the actual foundation everything flashy sits on top of. The multi-agent routing only works because of the boring layering underneath.</p><p>Repo’s open if you want to dig into it:</p><p>`github.com/himasnhu77/multi-calling-agent-with-knowledge-base-orchestrator-agent`</p><p>If you’re working on multi-agent orchestration, RAG pipelines, or graph memory – I’d genuinely like to compare notes. Drop a comment or hit me up.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b2249aeaec7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Last Seat Problem: How Booking Systems Prevent Double Booking]]></title>
            <link>https://medium.com/@ht976648/the-last-seat-problem-how-booking-systems-prevent-double-booking-015895d4f9c1?source=rss-3d167af838cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/015895d4f9c1</guid>
            <dc:creator><![CDATA[Ht]]></dc:creator>
            <pubDate>Tue, 21 Jul 2026 20:10:22 GMT</pubDate>
            <atom:updated>2026-07-21T20:10:22.107Z</atom:updated>
            <content:encoded><![CDATA[<p>I would structure it like this:</p><h3>1. Introduction</h3><ul><li>The “last seat” problem.</li><li>Why concurrency is difficult.</li><li>Real examples (movie tickets, airline booking, hotel reservations, flash sales).</li></ul><h3>2. The Race Condition</h3><p>Diagram:</p><pre>Seat A10</pre><pre>          AVAILABLE</pre><pre>              │<br>      ┌───────┴────────┐<br>      │                │<br>   User A           User B<br>      │                │<br>      ▼                ▼<br> Read Available   Read Available<br>      │                │<br>      ▼                ▼<br>Book Seat         Book Seat<br>      │                │<br>      ▼                ▼<br> SUCCESS          SUCCESS ❌</pre><pre>Same seat sold twice</pre><p>Explain why simply checking availability is not enough.</p><h3>3. What Happens Inside the Backend</h3><pre>Client</pre><pre>↓</pre><pre>API Gateway</pre><pre>↓</pre><pre>Booking Service</pre><pre>↓</pre><pre>Database</pre><p>Show where the race condition actually occurs.</p><h3>4. Naive SQL Flow</h3><pre>SELECT status<br>FROM seats<br>WHERE id = 10;</pre><pre>status = AVAILABLE</pre><pre>UPDATE seats<br>SET status=&#39;BOOKED&#39;;</pre><p>Then explain why two transactions executing simultaneously both succeed.</p><h3>5. Pessimistic Locking</h3><p>Sequence diagram</p><pre>User A</pre><pre>↓</pre><pre>SELECT ... FOR UPDATE</pre><pre>↓</pre><pre>🔒 Row Locked</pre><pre>↓</pre><pre>Payment</pre><pre>↓</pre><pre>COMMIT</pre><pre>↓</pre><pre>Unlock</pre><p>Second user</p><pre>User B</pre><pre>↓</pre><pre>SELECT ... FOR UPDATE</pre><pre>↓</pre><pre>WAIT......</pre><pre>WAIT......</pre><pre>WAIT......</pre><pre>↓</pre><pre>Seat Already Booked</pre><p>Explain</p><ul><li>Row Lock</li><li>Blocking</li><li>Deadlocks</li><li>Lock timeout</li></ul><h3>6. Optimistic Locking</h3><p>Database</p><pre>Seat</pre><pre>ID      STATUS      VERSION</pre><pre>10      Available      7</pre><p>Timeline</p><pre>User A</pre><pre>Read Version = 7</pre><pre>↓</pre><pre>Update</pre><pre>WHERE version = 7</pre><pre>↓</pre><pre>Version becomes 8</pre><pre>✔ Success</pre><p>User B</p><pre>Read Version = 7</pre><pre>↓</pre><pre>Update</pre><pre>WHERE version = 7</pre><pre>↓</pre><pre>0 rows updated</pre><pre>❌ Retry</pre><h3>7. Version Column Diagram</h3><pre>Version</pre><pre>5</pre><pre>↓</pre><pre>6</pre><pre>↓</pre><pre>7</pre><pre>↓</pre><pre>8</pre><p>Explain why the version is incremented.</p><h3>8. Database Internals</h3><p>Explain</p><ul><li>MVCC</li><li>Row Lock</li><li>Snapshot</li><li>Transaction</li><li>WAL</li><li>Commit Log</li></ul><h3>9. Redis Seat Hold</h3><p>Diagram</p><pre>User</pre><pre>↓</pre><pre>Booking Service</pre><pre>↓</pre><pre>Redis</pre><pre>Hold Seat</pre><pre>TTL = 5 Minutes</pre><pre>↓</pre><pre>Payment</pre><pre>↓</pre><pre>Database</pre><pre>↓</pre><pre>Booking Confirmed</pre><p>Explain why Redis is used.</p><h3>10. Payment Failure</h3><pre>Redis Hold</pre><pre>↓</pre><pre>Payment Failed</pre><pre>↓</pre><pre>TTL expires</pre><pre>↓</pre><pre>Seat Available Again</pre><h3>11. Complete Production Architecture</h3><pre>Client</pre><pre>                       │</pre><pre>                 Load Balancer</pre><pre>                       │</pre><pre>                Booking Service</pre><pre>            ┌──────────┴──────────┐</pre><pre>        Redis Seat Hold      Kafka Events</pre><pre>               │                  │</pre><pre>               ▼                  ▼</pre><pre>         Booking Database    Notification Service</pre><pre>               │</pre><pre>         Payment Service</pre><pre>               │</pre><pre>         Booking Confirmed</pre><p>Also explain</p><ul><li>Why Kafka?</li><li>Why Redis?</li><li>Why Database?</li><li>Why asynchronous notifications?</li></ul><h3>12. Optimistic vs Pessimistic Comparison</h3><p>FeatureOptimisticPessimisticLockNoYesWaitingNoYesThroughputHighLowerConflict HandlingRetryWaitBest ForSocial AppsTicket BookingDeadlocksRarePossibleScalabilityBetterModerate</p><h3>13. What FAANG / Product Interviews Ask</h3><p>Typical interview questions:</p><ul><li>Design BookMyShow.</li><li>Prevent double booking.</li><li>Design airline reservation.</li><li>Why Redis?</li><li>Why Kafka?</li><li>What if payment fails?</li><li>What if Redis crashes?</li><li>Why not only SQL?</li><li>Why optimistic locking?</li><li>Why pessimistic locking?</li><li>How do deadlocks occur?</li><li>How would you scale to 10 million users?</li></ul><h3>14. Final Takeaway</h3><blockquote><em>Every backend engineer eventually realizes that concurrency is not about making software faster.</em></blockquote><blockquote><em>It’s about ensuring that </em><strong><em>correctness survives under massive scale.</em></strong></blockquote><p>Two users can click <strong>“Book Now”</strong> at exactly the same millisecond.</p><p>The real challenge is making sure only one of them owns the seat.</p><p>That is where transactions, locking strategies, Redis, databases, and distributed systems work together behind the scenes.</p><p>This structure would make the article feel like a premium system design guide rather than a simple explanation. It would naturally include <strong>8–10 diagrams</strong>, production architecture, SQL examples, interview insights, and real-world trade-offs — exactly the kind of content that tends to perform well with backend engineers on Medium and LinkedIn.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=015895d4f9c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Memorizing Subarray Problems. Learn the Prefix Sum Pattern Instead.]]></title>
            <link>https://medium.com/@ht976648/stop-memorizing-subarray-problems-learn-the-prefix-sum-pattern-instead-a3e06f5d9279?source=rss-3d167af838cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3e06f5d9279</guid>
            <dc:creator><![CDATA[Ht]]></dc:creator>
            <pubDate>Tue, 21 Jul 2026 19:59:26 GMT</pubDate>
            <atom:updated>2026-07-21T19:59:26.773Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve solved enough LeetCode problems, you’ve probably noticed something interesting.</p><p>Many questions look completely different on the surface:</p><ul><li>Subarray Sum Equals K</li><li>Count Subarrays with Given Sum</li><li>Maximum Length Contiguous Array</li><li>Product of Array Except Self</li><li>Range Sum Query</li><li>2D Matrix Sum Queries</li></ul><p>Most candidates memorize a separate solution for each problem.</p><p>But interviewers aren’t testing whether you’ve memorized solutions — they’re testing whether you can recognize the <strong>underlying pattern</strong>.</p><p>One of the most powerful patterns for array problems is <strong>Prefix Sum</strong>.</p><p>Once you truly understand it, an entire family of interview questions suddenly becomes much easier.</p><h3>What is Prefix Sum?</h3><p>A prefix sum stores the cumulative sum of elements from the beginning of the array up to a given index.</p><p>For an array</p><pre>[3, 2, 5, 1, 6]</pre><p>The prefix sum becomes</p><pre>[3, 5, 10, 11, 17]</pre><p>where</p><pre>prefix[i] = prefix[i-1] + nums[i]</pre><p>Building this takes <strong>O(n)</strong> time.</p><p>At first glance, it may not seem useful.</p><p>The real power appears when answering multiple range queries.</p><h3>Range Sum Queries Become O(1)</h3><p>Suppose you’re repeatedly asked:</p><blockquote><em>What is the sum between index L and R?</em></blockquote><p>A brute-force solution requires traversing every element.</p><p>Time Complexity:</p><pre>O(n)</pre><p>With prefix sums:</p><pre>Sum(L,R)</pre><pre>= Prefix[R] − Prefix[L−1]</pre><p>Each query now becomes</p><pre>O(1)</pre><p>This idea alone powers many database engines, analytics systems, and competitive programming problems.</p><h3>The Interview Trick: Prefix Sum + HashMap</h3><p>This is probably the most common interview pattern.</p><p>Consider the famous problem:</p><h3>Subarray Sum Equals K</h3><p>Instead of checking every possible subarray,</p><p>we maintain the running prefix sum.</p><p>Suppose</p><pre>Current Prefix = P</pre><p>If there existed a previous prefix</p><pre>P − K</pre><p>then the elements between those two prefixes must sum to K.</p><p>So instead of storing every subarray,</p><p>we simply store previous prefix sums inside a HashMap.</p><p>Each lookup becomes</p><pre>O(1)</pre><p>Overall complexity:</p><pre>O(n)</pre><p>instead of</p><pre>O(n²)</pre><p>This exact observation solves many seemingly different problems.</p><h3>Problems Solved Using Prefix Sum + HashMap</h3><p>Once you recognize this pattern, you’ll notice it everywhere.</p><ul><li>Subarray Sum Equals K</li><li>Count Subarrays with Given Sum</li><li>Longest Subarray with Given Sum</li><li>Continuous Subarray Sum</li><li>Count Binary Subarrays</li><li>Count Nice Subarrays</li></ul><p>Although these questions appear different,</p><p>their core idea remains exactly the same.</p><h3>Maximum Length Contiguous Array (Equal 0s and 1s)</h3><p>This is one of my favorite interview questions.</p><p>You’re given a binary array.</p><p>Find the longest contiguous subarray having equal numbers of 0s and 1s.</p><p>Most people immediately think about sliding windows.</p><p>That doesn’t work.</p><p>Instead,</p><p>convert</p><pre>0 → -1<br>1 → +1</pre><p>Now the question becomes</p><blockquote><em>Find the longest subarray whose sum equals zero.</em></blockquote><p>Suddenly,</p><p>it’s another Prefix Sum + HashMap problem.</p><p>A completely different-looking problem reduces to exactly the same pattern.</p><p>That’s the beauty of understanding concepts instead of memorizing solutions.</p><h3>Product of Array Except Self</h3><p>Interestingly,</p><p>this problem doesn’t even involve sums.</p><p>Instead,</p><p>we use</p><ul><li>Prefix Product</li><li>Suffix Product</li></ul><p>For every index,</p><pre>Answer</pre><pre>=</pre><pre>Left Product × Right Product</pre><p>No division.</p><p>Linear time.</p><p>Constant extra space (optimized).</p><p>This teaches an important lesson:</p><p>The prefix idea isn’t limited to addition.</p><p>It works whenever cumulative information can be reused.</p><h3>Prefix Sum on Matrices (2D Prefix Sum)</h3><p>Interviewers also love extending one-dimensional ideas into two dimensions.</p><p>Suppose you receive thousands of rectangle sum queries.</p><p>Without preprocessing,</p><p>every query requires traversing the rectangle.</p><p>Instead,</p><p>build a 2D Prefix Sum matrix once.</p><p>Each rectangle query can now be answered in constant time using inclusion-exclusion.</p><p>This technique appears in</p><ul><li>Matrix Sum Query</li><li>Image Processing</li><li>Heatmaps</li><li>Dynamic Programming</li><li>Competitive Programming</li></ul><p>Understanding 1D Prefix Sum makes learning 2D Prefix Sum almost effortless.</p><h3>What About Kadane’s Algorithm?</h3><p>Many people think Kadane’s Algorithm is unrelated.</p><p>It’s actually closely connected.</p><p>Maximum Subarray Sum can be interpreted as</p><pre>Current Prefix</pre><pre>−</pre><pre>Minimum Prefix Seen So Far</pre><p>Looking at Kadane through the lens of prefix sums helps you derive the algorithm rather than memorize it.</p><p>Patterns begin connecting with each other.</p><p>That’s when interview preparation becomes much easier.</p><h3>Prefix Sum in Real Systems</h3><p>Prefix sums aren’t just interview tricks.</p><p>They are heavily used in production systems.</p><p>Some examples include:</p><h3>Image Processing</h3><p>Fast calculation of pixel intensities over rectangular regions.</p><h3>Financial Analytics</h3><p>Running balances and cumulative revenue reports.</p><h3>Time-Series Databases</h3><p>Efficient aggregation across time intervals.</p><h3>GIS &amp; Heatmaps</h3><p>Fast geographic region calculations.</p><h3>Game Development</h3><p>Terrain calculations and cumulative game effects.</p><h3>Database Systems</h3><p>Optimizing repeated range aggregation queries.</p><p>Every system answering frequent range queries benefits from preprocessing cumulative information once.</p><h3>Common Prefix Sum Problems You Should Practice</h3><p>If you’re preparing for coding interviews, these problems should definitely be on your list:</p><ul><li>Range Sum Query</li><li>Subarray Sum Equals K</li><li>Count Subarrays With Given Sum</li><li>Continuous Subarray Sum</li><li>Maximum Length Contiguous Array</li><li>Binary Subarrays With Sum</li><li>Product of Array Except Self</li><li>Running Sum of 1D Array</li><li>2D Range Sum Query</li><li>Corporate Flight Bookings (Difference Array)</li><li>Car Pooling</li><li>Prefix XOR Problems</li></ul><p>Rather than memorizing each solution independently,</p><p>try identifying the common pattern behind them.</p><h3>Final Thoughts</h3><p>The biggest mistake candidates make is collecting hundreds of solutions.</p><p>The better approach is collecting patterns.</p><p>Whenever you see problems involving:</p><ul><li>Range Queries</li><li>Subarrays</li><li>Running Totals</li><li>Equal Counts</li><li>Matrix Sums</li><li>Prefix Differences</li></ul><p>pause and ask yourself:</p><blockquote><strong><em>Can Prefix Sum solve this?</em></strong></blockquote><p>Very often,</p><p>the answer is yes.</p><p>Mastering Prefix Sum doesn’t just help you solve one problem.</p><p>It helps you solve an entire category of interview questions with confidence.</p><p><strong>Reference &amp; Inspiration</strong></p><p>This article was inspired by an excellent explanation of Prefix Sum patterns by Raveen Panditha:</p><p><a href="https://medium.com/@raveenpanditha/dsa-patterns-03-prefix-sum-a-complete-guide-0b91fb687a08">https://medium.com/@raveenpanditha/dsa-patterns-03-prefix-sum-a-complete-guide-0b91fb687a08</a></p><p>Understanding patterns — not memorizing solutions — is what ultimately separates strong problem solvers from candidates who rely only on practice counts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3e06f5d9279" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Memorizing Linked List Problems. Learn These 3 Pointer Movements Instead.]]></title>
            <link>https://medium.com/@ht976648/stop-memorizing-linked-list-problems-learn-these-3-pointer-movements-instead-18621e7cb479?source=rss-3d167af838cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/18621e7cb479</guid>
            <dc:creator><![CDATA[Ht]]></dc:creator>
            <pubDate>Sun, 19 Jul 2026 19:24:30 GMT</pubDate>
            <atom:updated>2026-07-19T19:24:30.058Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve solved a few Linked List problems, you’ve probably experienced this.</p><p>You solve <strong>Reverse Linked List</strong> today.</p><p>Tomorrow you see <strong>Reverse Nodes in k Groups</strong>.</p><p>The next day it’s <strong>Reverse Alternate k Nodes</strong>.</p><p>Then comes <strong>Swap Pairs</strong>, <strong>Reverse Between Positions</strong>, <strong>Rotate List</strong>, and suddenly it feels like every problem is completely different.</p><p>The reality?</p><p>They’re not.</p><p>Almost every Linked List problem is built on a handful of pointer movements.</p><p>Once I realized this, Linked Lists stopped being scary.</p><h3>The Biggest Mistake</h3><p>Most people memorize algorithms.</p><pre>Reverse List → Memorize<br>Reverse k Groups → Memorize<br>Swap Pairs → Memorize<br>Rotate List → Memorize</pre><p>After a week…</p><p>Everything is forgotten.</p><p>Instead of memorizing solutions, understand what each pointer is responsible for.</p><h3>The Reverse Linked List Mental Model</h3><p>Forget code.</p><p>Think about responsibilities.</p><p>You only need three pointers.</p><pre>prev<br>curr<br>next</pre><p>Initially,</p><pre>prev = null<br>curr = head</pre><p>Every iteration follows exactly the same sequence.</p><h3>Step 1</h3><p>Save the remaining list.</p><pre>next = curr.next</pre><p>Why?</p><p>Because once we change curr.next, we&#39;ll lose access to the rest of the list.</p><p>Think of next as your safety rope.</p><h3>Step 2</h3><p>Reverse the arrow.</p><pre>curr.next = prev</pre><p>That’s the actual reversal.</p><p>Nothing magical happens.</p><p>You’re simply changing one pointer.</p><h3>Step 3</h3><p>Move the window.</p><pre>prev = curr<br>curr = next</pre><p>Now the reversed portion grows by one node.</p><p>Repeat until curr == null.</p><p>Done.</p><p>That’s literally the entire reverse algorithm.</p><h3>Visualizing It</h3><p>Original list</p><pre>1 → 2 → 3 → 4 → 5</pre><p>Iteration 1</p><pre>prev = 1<br>curr = 2</pre><pre>1 ← 2 → 3 → 4 → 5</pre><p>Iteration 2</p><pre>2 ← 1</pre><pre>curr = 3</pre><p>Iteration 3</p><pre>3 ← 2 ← 1</pre><p>Continue.</p><p>Eventually,</p><pre>5 → 4 → 3 → 2 → 1</pre><p>Nothing more than repeating the same four operations.</p><h3>Every Reverse Problem Uses the Same Pattern</h3><p>This realization changed everything for me.</p><p>Whether it’s</p><ul><li>Reverse Linked List</li><li>Reverse Between</li><li>Reverse k Groups</li><li>Reverse Alternate k Groups</li></ul><p>the reversal logic never changes.</p><p>Only the <strong>boundary</strong> changes.</p><h3>Pattern 1 — Reverse Entire List</h3><p>Reverse until</p><pre>curr == null</pre><p>That’s it.</p><h3>Pattern 2 — Reverse First k Nodes</h3><p>Instead of running until null,</p><p>run only</p><pre>k iterations</pre><p>Everything else remains identical.</p><h3>Pattern 3 — Reverse Between Left and Right</h3><p>Don’t start from the head.</p><p>Move until</p><pre>left</pre><p>Then perform the exact reverse process for</p><pre>right - left + 1</pre><p>Reconnect both ends.</p><p>Again —</p><p>same reverse logic.</p><h3>Pattern 4 — Reverse Nodes in k Groups</h3><p>This problem looks difficult.</p><p>But think carefully.</p><p>You’re simply doing this repeatedly.</p><pre>Reverse first k nodes</pre><pre>Reconnect</pre><pre>Move to next group</pre><pre>Repeat</pre><p>The reverse algorithm never changes.</p><p>Only the outer loop changes.</p><h3>Pattern 5 — Reverse Alternate k Groups</h3><p>Exactly the same.</p><pre>Reverse k</pre><pre>Skip k</pre><pre>Reverse k</pre><pre>Skip k</pre><p>Again…</p><p>No new algorithm.</p><p>Just different boundaries.</p><h3>Why Beginners Get Lost</h3><p>Because they focus on code.</p><p>Instead, focus on ownership.</p><p>Ask yourself:</p><ul><li>Who remembers the previous node?</li><li>Who is the current node?</li><li>Who protects the remaining list?</li><li>Where should I stop reversing?</li></ul><p>Once these questions become natural, the code almost writes itself.</p><h3>The Real Pattern Behind Linked Lists</h3><p>Most Linked List questions reduce to one of these operations:</p><ul><li>Traverse</li><li>Reverse</li><li>Find Middle</li><li>Detect Cycle</li><li>Merge</li><li>Split</li><li>Reconnect</li></ul><p>Everything else is a combination of these building blocks.</p><h3>My Interview Strategy</h3><p>Whenever I see a new Linked List problem, I don’t immediately think about code.</p><p>I first ask:</p><p><strong>Which pointer pattern does this belong to?</strong></p><p>If it’s a reversal problem,</p><p>I instantly think</p><pre>prev<br>curr<br>next</pre><p>If it’s a cycle problem,</p><p>I think</p><pre>Slow<br>Fast</pre><p>If it’s merging,</p><p>I think</p><pre>Dummy node<br>Tail pointer</pre><p>Instead of memorizing 50 algorithms,</p><p>I memorize 5 pointer patterns.</p><p>That’s much easier.</p><h3>Final Thoughts</h3><p>Linked Lists aren’t difficult because of the code.</p><p>They’re difficult because pointers feel abstract.</p><p>Once you stop seeing nodes and start seeing pointer responsibilities, every problem becomes far more predictable.</p><p>Don’t memorize “Reverse in k Groups.”</p><p>Memorize <strong>how reversal works.</strong></p><p>Everything else is just changing where you start, where you stop, and how you reconnect.</p><p>That’s the mental model that made Linked Lists finally click for me.</p><p>If this helped, I’d love to hear which data structure you’d like me to break down next — Trees, Graphs, Dynamic Programming, or Sliding Window.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18621e7cb479" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Stopped Memorizing Tree Problems. I Started Seeing Patterns Instead.]]></title>
            <link>https://medium.com/@ht976648/i-stopped-memorizing-tree-problems-i-started-seeing-patterns-instead-19297ac58a34?source=rss-3d167af838cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/19297ac58a34</guid>
            <dc:creator><![CDATA[Ht]]></dc:creator>
            <pubDate>Sun, 19 Jul 2026 19:16:41 GMT</pubDate>
            <atom:updated>2026-07-19T19:16:41.153Z</atom:updated>
            <content:encoded><![CDATA[<p>I used to think Binary Trees and Graphs were all about memorizing dozens of different algorithms.</p><p>Level Order Traversal.<br>Zigzag Traversal.<br>Right Side View.<br>Left Side View.<br>Lowest Common Ancestor.<br>Number of Islands.<br>Rotting Oranges.</p><p>Every problem looked different.</p><p>Until I realized something.</p><p><strong>Most of them are just the same pattern with one small modification.</strong></p><p>That realization completely changed how I approached interview preparation.</p><h3>Pattern 1: Level Order Traversal — The Foundation</h3><p>If there’s one traversal every interview candidate should master, it’s <strong>Level Order Traversal (BFS)</strong>.</p><p>The pattern is always the same:</p><ul><li>Push the root into a queue.</li><li>While the queue isn’t empty:</li><li>Store the current queue size.</li><li>Traverse exactly those nodes.</li><li>Push their children.</li><li>Store the current level.</li></ul><p>That’s it.</p><p>Once you truly understand this pattern, many “different” interview questions become tiny variations.</p><h3>Pattern 2: Zigzag Traversal</h3><p>At first glance, Zigzag Traversal looks like a completely new problem.</p><p>It isn’t.</p><p>The traversal is <strong>identical</strong> to Level Order Traversal.</p><p>The only difference?</p><p>Maintain a boolean flag.</p><pre>leftToRight = true</pre><p>After processing one level:</p><ul><li>If leftToRight is true → keep the order.</li><li>Otherwise → reverse the level (or insert accordingly).</li></ul><p>Finally,</p><pre>leftToRight = !leftToRight</pre><p>That’s literally the only additional logic.</p><p>The queue never changes.</p><p>The BFS never changes.</p><p>Only the output order changes.</p><h3>Pattern 3: Right Side View</h3><p>This became one of my favorite interview problems because of how elegant it is.</p><p>Again…</p><p>The BFS stays exactly the same.</p><p>After finishing one level, you’ll already have all nodes of that level stored in a temporary vector.</p><p>The answer?</p><p>Simply take</p><pre>temp.back()</pre><p>Store it.</p><p>Continue.</p><p>That’s the entire trick.</p><p>No complicated logic.</p><p>Just understanding that the last node of every level is the one visible from the right.</p><h3>Pattern 4: Left Side View</h3><p>Exactly the same idea.</p><p>Instead of</p><pre>temp.back()</pre><p>take</p><pre>temp.front()</pre><p>or</p><pre>temp[0]</pre><p>That’s it.</p><p>Same queue.</p><p>Same traversal.</p><p>Different observation.</p><h3>Pattern 5: Lowest Common Ancestor (Binary Tree)</h3><p>This is another problem I enjoy because the recursive logic is surprisingly clean.</p><p>The base cases are simple:</p><ul><li>If the current node is NULL, return NULL.</li><li>If the current node equals p or q, return the current node.</li></ul><p>Then recursively search:</p><ul><li>Left subtree</li><li>Right subtree</li></ul><p>Three possibilities appear.</p><h3>Case 1</h3><p>Both recursive calls return non-null.</p><p>That means one node was found on each side.</p><p>Current node is the LCA.</p><p>Return root.</p><h3>Case 2</h3><p>Only the left call returns a node.</p><p>Return left.</p><h3>Case 3</h3><p>Only the right call returns a node.</p><p>Return right.</p><p>The recursion naturally bubbles the answer upward.</p><p>No parent pointers.</p><p>No extra data structures.</p><p>Just recursion.</p><h3>Pattern 6: Number of Islands</h3><p>Initially this problem looked difficult.</p><p>Eventually I realized it’s simply BFS over a grid.</p><p>The workflow becomes:</p><ul><li>Maintain a visited matrix.</li><li>Scan every cell.</li><li>Whenever you find an unvisited land cell:</li><li>Increase island count.</li><li>Run BFS.</li><li>Mark the complete island as visited.</li></ul><p>The BFS itself is standard.</p><p>Store coordinates using</p><pre>queue&lt;pair&lt;int,int&gt;&gt;</pre><p>Use direction arrays:</p><pre>dx = {-1,0,1,0}<br>dy = {0,1,0,-1}</pre><p>Visit all valid neighbors.</p><p>Repeat.</p><p>Nothing more.</p><p>The important observation is that <strong>we don’t modify the original grid</strong>.</p><p>The visited matrix keeps the input untouched.</p><h3>Pattern 7: Rotting Oranges</h3><p>One of the best examples of <strong>Multi-Source BFS</strong>.</p><p>Instead of starting BFS from one node…</p><p>Start from every rotten orange.</p><p>Initially,</p><p>push every cell where</p><pre>grid[i][j] == 2</pre><p>into the queue.</p><p>Now all rotten oranges spread simultaneously.</p><p>During BFS:</p><ul><li>Visit only fresh oranges (grid == 1)</li><li>Mark them visited</li><li>Push them with time + 1</li></ul><p>The queue typically stores</p><pre>queue&lt;pair&lt;int,pair&lt;int,int&gt;&gt;&gt;</pre><p>where the first value represents time.</p><p>Maintain</p><pre>maxTime</pre><p>and update it while processing the queue.</p><p>Finally,</p><p>scan the grid one last time.</p><p>If any fresh orange remains,</p><p>return</p><pre>-1</pre><p>Otherwise,</p><p>return</p><pre>maxTime</pre><p>That final validation is something interviewers often expect.</p><h3>The Biggest Lesson</h3><p>For a long time I tried to memorize every solution.</p><p>It never worked.</p><p>The moment I started identifying reusable patterns, everything became easier.</p><p>I stopped seeing:</p><ul><li>Zigzag Traversal</li><li>Right View</li><li>Left View</li><li>Islands</li><li>Rotting Oranges</li></ul><p>as separate problems.</p><p>Instead, I saw:</p><ul><li>One BFS template</li><li>One recursive DFS template</li><li>Small modifications</li></ul><p>That’s how experienced problem solvers think.</p><p>Not by remembering hundreds of solutions.</p><p>But by recognizing a handful of patterns that solve hundreds of questions.</p><p>If you’re preparing for Google, Microsoft, Amazon, Adobe, Atlassian, or top Indian startups, don’t just solve problems.</p><p>Ask yourself after every question:</p><p><strong>“What pattern did I actually learn today?”</strong></p><p>That single question is often worth more than solving ten random problems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19297ac58a34" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why a Bloom Filter Can Store Millions of Records in Just 35 MB (And Why HashMap & Bitmap Couldn’t)]]></title>
            <link>https://medium.com/@ht976648/why-a-bloom-filter-can-store-millions-of-records-in-just-35-mb-and-why-hashmap-bitmap-couldnt-ecfa5ed24c03?source=rss-3d167af838cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecfa5ed24c03</guid>
            <dc:creator><![CDATA[Ht]]></dc:creator>
            <pubDate>Sat, 18 Jul 2026 13:10:00 GMT</pubDate>
            <atom:updated>2026-07-18T13:10:00.690Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IluZ4m9or5LTNGS3SHditw.png" /></figure><p><em>Inspired by:</em> <strong>Why Can a Bloom Filter Store 30 Million Data Entries in 35MB?</strong></p><p>There are very few data structures that completely change the way you think about storage.</p><p>For me, Bloom Filters were one of them.</p><p>At first, I thought the solution would simply be a <strong>HashMap</strong>. After all, HashMap gives average <strong>O(1)</strong> lookup time. Sounds perfect, right?</p><p>Not quite.</p><p>The deeper I explored, the more I realized that every solution solves one problem while introducing another.</p><p>Let’s see why.</p><h3>The First Thought: HashMap</h3><p>Suppose you want to check whether an ID has been seen before.</p><p>A HashMap seems like the obvious choice.</p><pre>Key -&gt; Exists</pre><p>Lookup?</p><p><strong>O(1)</strong> on average.</p><p>Insertion?</p><p><strong>O(1)</strong>.</p><p>So what’s the issue?</p><h3>Storage.</h3><p>Imagine storing <strong>30 million unique entries</strong>.</p><p>Every entry requires:</p><ul><li>the key itself</li><li>hash metadata</li><li>buckets</li><li>pointers</li><li>object overhead</li><li>collision handling</li></ul><p>Even though lookup is fast, the memory usage becomes enormous.</p><p>The real bottleneck isn’t time anymore.</p><p>It’s RAM.</p><h3>What About a Bitmap?</h3><p>Then comes another clever idea.</p><p>Instead of storing keys…</p><p>Store bits.</p><pre>0 0 1 0 1 1 0 0 ...</pre><p>If ID 25 exists,</p><p>Set bit number 25.</p><p>Beautiful.</p><p>Now every value consumes just <strong>1 bit</strong> instead of an entire object.</p><p>Storage drops dramatically.</p><p>Initially, this felt like the perfect solution.</p><p>Until another problem appeared.</p><h3>The Hidden Problem With Bitmaps</h3><p>Bitmaps only work well when IDs are dense and sequential.</p><p>Suppose your IDs look like this:</p><pre>15<br>37<br>104<br>10000000<br>987654321</pre><p>To represent ID <strong>987654321</strong>, the bitmap must allocate bits all the way up to index <strong>987654321</strong>.</p><p>That means hundreds of millions of unused bits.</p><p>You’re wasting memory just because one value happens to be large.</p><p>The bitmap doesn’t care whether only 5 IDs exist.</p><p>It cares about the <strong>largest index</strong>.</p><p>This makes bitmaps impractical for sparse or randomly distributed values.</p><h3>This Is Where Bloom Filters Become Brilliant</h3><p>Bloom Filters don’t store the actual values.</p><p>They don’t store keys.</p><p>They don’t store indexes.</p><p>Instead, they store <strong>evidence</strong>.</p><p>When inserting a value:</p><pre>User123</pre><p>Several independent hash functions are applied.</p><p>Example:</p><pre>Hash1(User123) -&gt; 105<br>Hash2(User123) -&gt; 2018<br>Hash3(User123) -&gt; 98765</pre><p>Those positions in the bit array are set to <strong>1</strong>.</p><pre>BitArray</pre><pre>...001...1.....1...</pre><p>That’s it.</p><p>No object.</p><p>No pointer.</p><p>No key.</p><p>Just bits.</p><h3>Checking Membership</h3><p>When checking whether an element exists, the same hash functions are run again.</p><p>If <strong>any one</strong> of those bits is <strong>0</strong>:</p><pre>Bit 105 = 0</pre><p>You immediately know:</p><blockquote><em>This element has </em><strong><em>definitely never been inserted.</em></strong></blockquote><p>No ambiguity.</p><p>No probability.</p><p>A single zero is enough.</p><p>This is called a <strong>definite negative</strong>.</p><h3>But What If All Bits Are 1?</h3><p>Now comes the interesting part.</p><p>Suppose all required bits are already set.</p><p>Does that guarantee the element exists?</p><p>Not necessarily.</p><p>Those bits could have been set by completely different elements.</p><p>So Bloom Filters answer:</p><blockquote><strong><em>“It probably exists.”</em></strong></blockquote><p>Not:</p><blockquote><strong><em>“It definitely exists.”</em></strong></blockquote><p>This is called a <strong>false positive</strong>.</p><p>The structure never produces false negatives.</p><p>Only false positives.</p><p>That trade-off is what makes Bloom Filters incredibly memory-efficient.</p><h3>The Magic Isn’t the Bit Array</h3><p>Initially, I thought the bit array was the real innovation.</p><p>It isn’t.</p><p>The real magic lies in using <strong>multiple independent hash functions</strong>.</p><p>Each inserted element influences several locations.</p><p>That spreads information across the array and dramatically reduces accidental matches.</p><p>Instead of storing millions of values, Bloom Filters store carefully distributed bit patterns.</p><p>That’s the breakthrough.</p><h3>The Most Surprising Part: False Positive Rate</h3><p>One thing that fascinated me most was how sensitive Bloom Filters are to the desired accuracy.</p><p>Suppose you accept a <strong>0.1% false positive rate</strong>.</p><p>The Bloom Filter may only need around <strong>35 MB</strong> for tens of millions of entries.</p><p>Now try improving accuracy.</p><pre>0.1%<br>↓</pre><pre>0.01%<br>↓</pre><pre>0.001%</pre><p>What happens?</p><p>The required bit array grows rapidly.</p><p>Sometimes from <strong>tens of megabytes</strong> into <strong>hundreds of megabytes or even gigabytes</strong>, depending on the number of stored elements.</p><p>In other words:</p><p>Higher accuracy costs memory.</p><p>Lower memory means accepting a few more false positives.</p><p>Bloom Filters let engineers choose where they want to sit on that trade-off curve.</p><h3>Why Companies Love Bloom Filters</h3><p>Large-scale systems don’t always need exact answers.</p><p>Sometimes they only need to quickly eliminate impossible cases.</p><p>Examples include:</p><ul><li>Checking if a URL has already been crawled</li><li>Preventing unnecessary database lookups</li><li>Detecting duplicate requests</li><li>Cache filtering</li><li>Distributed databases like Cassandra and Bigtable</li><li>Storage engines such as RocksDB</li></ul><p>Instead of querying expensive storage millions of times, a Bloom Filter answers most negative queries in microseconds using only a tiny amount of memory.</p><h3>Final Thoughts</h3><p>What I enjoyed most wasn’t just learning another data structure.</p><p>It was seeing the evolution of ideas.</p><ul><li><strong>HashMap</strong> gives excellent lookup speed but consumes significant memory.</li><li><strong>Bitmap</strong> dramatically reduces storage but only works efficiently for dense, sequential values.</li><li><strong>Bloom Filter</strong> takes a completely different approach — it doesn’t store the data at all. Instead, it stores probabilistic evidence that an element may have been seen.</li></ul><p>Sometimes the best optimization isn’t making an existing solution faster.</p><p>It’s changing the question entirely.</p><p>Instead of asking:</p><blockquote><em>“Can I store every value?”</em></blockquote><p>Bloom Filters ask:</p><blockquote><em>“Do I really need to?”</em></blockquote><p>And that shift in thinking is what makes them one of the most elegant data structures in computer science.</p><p><strong>Inspired by:</strong><br> <em>Why Can a Bloom Filter Store 30 Million Data Entries in 35MB?</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecfa5ed24c03" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What happens when 10 million users request the same Redis key at the same time?]]></title>
            <link>https://medium.com/@ht976648/what-happens-when-10-million-users-request-the-same-redis-key-at-the-same-time-bd16374440c2?source=rss-3d167af838cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd16374440c2</guid>
            <dc:creator><![CDATA[Ht]]></dc:creator>
            <pubDate>Tue, 14 Jul 2026 10:33:06 GMT</pubDate>
            <atom:updated>2026-07-14T10:33:06.908Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E-Pg2JQSdq7Rbhp8s-KnFg.jpeg" /></figure><p>Cristiano Ronaldo posts on X.</p><p>Or Elon Musk announces something major.</p><p>Within seconds, millions of users refresh the same post, profile, or tweet.</p><p>From the application’s perspective, every request is trying to read the same Redis key.</p><pre>GET post:987654</pre><p>This is known as the <strong>Redis Hot Key Problem</strong>.</p><p>A hot key is a key that receives a disproportionately high amount of traffic compared to every other key in the system.</p><p>At first glance, you might think:</p><p><em>“We’re using Redis Cluster, so the traffic should automatically be distributed.”</em></p><p>Unfortunately, that’s not how Redis Cluster works.</p><p>Redis shards data based on the <strong>hash of the key</strong>. Since every request is asking for the same key, its hash always maps to the same hash slot, which belongs to a single Redis node.</p><pre>Millions of Requests<br>        │<br>GET post:987654<br>        │<br>Hash Slot 8123<br>        │<br>Redis Node 3</pre><p>While the rest of the cluster sits relatively idle, one node suddenly experiences:</p><p>• CPU spikes<br>• Network bandwidth saturation<br>• Increased request latency<br>• Connection queue buildup<br>• Replication lag<br>• Potential failovers under extreme load</p><p>The database itself isn’t necessarily slow — the bottleneck is that a single Redis instance becomes overloaded.</p><h3>So, how do large-scale systems solve this?</h3><h3>1️⃣ Local Cache (One of the most effective solutions)</h3><p>Instead of querying Redis for every request, cache the hottest objects directly inside each application server using an in-memory cache such as Caffeine (Java) or an LRU cache.</p><pre>User<br>   │<br>Application Server<br>   │<br>Local Cache (RAM)<br>   │<br>Redis (only on cache miss)</pre><p>Now millions of requests are served from application memory instead of overwhelming Redis.</p><h3>2️⃣ Hot Key Replication (Manual Sharding)</h3><p>Since one key cannot be distributed automatically, we can create multiple copies.</p><p>Instead of:</p><pre>post:987654</pre><p>Create:</p><pre>post:987654:1<br>post:987654:2<br>post:987654:3<br>post:987654:4<br>post:987654:5</pre><p>The application randomly selects one replica during reads.</p><p>If 3 million requests arrive:</p><pre>Replica 1 → 600K<br>Replica 2 → 600K<br>Replica 3 → 600K<br>Replica 4 → 600K<br>Replica 5 → 600K</pre><p>Traffic is now distributed instead of hitting a single Redis node.</p><h3>3️⃣ Read Replicas</h3><p>For read-heavy workloads:</p><pre>Master<br>   │<br> ├── Replica 1<br> ├── Replica 2<br> └── Replica 3</pre><p>Writes continue to the master, while read traffic is spread across replicas.</p><p>This significantly increases read throughput, although replicas may briefly lag because replication is asynchronous.</p><h3>4️⃣ CDN / Edge Caching</h3><p>If the content is public — tweets, user profiles, videos, trending posts — it often doesn’t need to reach Redis at all.</p><p>Edge caches like Cloudflare or Fastly can serve many requests directly from locations closer to users, dramatically reducing backend load.</p><h3>5️⃣ Rate Limiting</h3><p>Rate limiting doesn’t eliminate hot keys, but it protects the infrastructure during sudden traffic spikes.</p><p>Popular algorithms include:</p><p>• Token Bucket<br>• Leaky Bucket<br>• Sliding Window</p><p>These prevent abuse and help keep the system stable during viral events.</p><h3>6️⃣ Cache Warming</h3><p>Sometimes you already know traffic is coming.</p><p>Think about:</p><p>• Apple product launches<br>• IPL finals<br>• FIFA World Cup<br>• Election results<br>• Black Friday sales</p><p>Instead of waiting for the first cache miss, preload the expected hot data into Redis before the event begins.</p><h3>7️⃣ TTL Optimization</h3><p>Choosing the right TTL matters.</p><p>If a trending post expires every few seconds, Redis repeatedly fetches it from the database.</p><p>A longer TTL for hot objects reduces cache misses and backend pressure.</p><h3>8️⃣ Prevent Cache Stampede</h3><p>Another common production issue occurs when a hot key expires.</p><p>Thousands — or even millions — of requests miss the cache simultaneously and hit the database at once.</p><p>Solutions include:</p><p>• Request coalescing (single-flight)<br>• Distributed mutex locks<br>• Background cache refresh<br>• Randomized TTL (TTL jitter)</p><p>These techniques ensure only one request rebuilds the cache while others wait or receive stale-but-safe data.</p><h3>Hot Key vs Big Key</h3><p>These are often confused but solve different problems.</p><p><strong>Hot Key</strong></p><ul><li>Small or large value</li><li>Extremely high access frequency</li><li>Causes CPU and traffic hotspots</li></ul><p><strong>Big Key</strong></p><ul><li>Very large value (for example, a 20 MB JSON object)</li><li>Causes slow network transfer, serialization overhead, memory fragmentation, and expensive eviction</li></ul><p>Instead of storing everything under one key:</p><pre>user:123</pre><p>Split it into logical pieces:</p><pre>user:123:profile<br>user:123:posts<br>user:123:followers<br>user:123:likes</pre><p>Or paginate large collections.</p><p>Fetching only the required data improves latency and reduces memory overhead.</p><p>One thing I enjoy about System Design is that many “simple” interview questions reveal much deeper distributed systems concepts.</p><p>A single viral tweet or celebrity post can expose bottlenecks involving hashing, partitioning, replication, caching, consistency, traffic engineering, and fault tolerance.</p><p>That’s why companies like Adobe, Meta, Uber, Amazon, Netflix, and X frequently discuss these scenarios in system design interviews.</p><p>📖 I recently came across an excellent article that inspired this topic and is worth reading:</p><p>🔗 <a href="https://medium.com/@umeshcapg/adobe-interview-what-do-you-do-if-a-key-in-redis-has-a-particularly-high-access-volume-8d40a1a975a2?sharedUserId=ht976648">https://medium.com/@umeshcapg/adobe-interview-what-do-you-do-if-a-key-in-redis-has-a-particularly-high-access-volume-8d40a1a975a2?sharedUserId=ht976648</a></p><p>Have you encountered a Redis hot key issue in production? I’d love to hear how your team solved it.</p><p>#Redis #SystemDesign #DistributedSystems #Caching #Scalability #BackendEngineering #SoftwareEngineering #HighPerformance #Database #Microservices #Architecture #TechInterview</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd16374440c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Slow Down to Move Ahead: Lessons on Growth, Learning, and Building a Career]]></title>
            <link>https://medium.com/@ht976648/slow-down-to-move-ahead-lessons-on-growth-learning-and-building-a-career-d259416952b8?source=rss-3d167af838cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/d259416952b8</guid>
            <dc:creator><![CDATA[Ht]]></dc:creator>
            <pubDate>Sat, 11 Jul 2026 03:31:56 GMT</pubDate>
            <atom:updated>2026-07-11T03:41:50.242Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RsT4MU4cJAqaf4aXN08yAA.jpeg" /></figure><p>In today’s world, everyone seems to be in a hurry.</p><p>We rush toward success, rush toward promotions, rush toward salaries, and sometimes even rush toward goals that we don’t fully understand. Social media constantly shows us people achieving incredible things at a young age, making it easy to believe that if we are not moving fast, we are falling behind.</p><p>But one lesson I’ve learned is that many of the most important things in life simply take time.</p><p>A strong career takes time.</p><p>Deep knowledge takes time.</p><p>Personal growth takes time.</p><p>The problem is that we often expect results before the process has had enough time to work.</p><h3>Growth Is Not Instant</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3F5pkHIJ5ONb1z3Hgo6Xkg.png" /></figure><p>Sometimes we panic because things are not happening as quickly as we expected.</p><p>We start comparing ourselves with others.</p><p>We question our abilities.</p><p>We wonder whether we chose the wrong path.</p><p>But often the issue isn’t that we’re failing. It’s that we’re trying to harvest results before the seeds have had a chance to grow.</p><p>Instead of rushing blindly, we should focus on improving ourselves every day. Small improvements may look insignificant in the short term, but over months and years they create extraordinary results.</p><p>The person who remains patient while consistently learning will eventually outperform the person who constantly changes direction out of panic.</p><h3>The Importance of Direction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*HrgjEWXhfB-v0Yk8Xk4ntA.jpeg" /></figure><p>Moving fast is not always an advantage.</p><p>If you’re heading in the wrong direction, speed only takes you further away from where you want to be.</p><p>That’s why it’s often better to move slowly in the right direction than quickly in the wrong one.</p><p>Many people become obsessed with finding shortcuts, but very few spend time making sure they are actually on the correct path.</p><p>A little patience and clarity can save years of wasted effort.</p><h3>Thinking Less, Doing More</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Fr7tu3nNFQKodeTKbmqB0A.jpeg" /></figure><p>One of the biggest obstacles to progress is overthinking.</p><p>We spend hours imagining worst-case scenarios:</p><ul><li>What if I fail?</li><li>What if nobody notices my work?</li><li>What if this decision is wrong?</li><li>What if I don’t succeed?</li></ul><p>Most of these fears never become reality.</p><p>They are simply projections created by the mind.</p><p>The more time we spend worrying, the less time we spend building.</p><p>Action creates clarity.</p><p>Experience creates confidence.</p><p>Progress comes from doing, not endlessly thinking about doing.</p><p>The best strategy is often simple: think enough to make a decision, then take action.</p><h3>The Power of Guidance</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UPh1qtCU2JVQWIFZ3dquSg.png" /></figure><p>Success is rarely a solo journey.</p><p>Having the right guidance can accelerate growth more than any course or book.</p><p>A mentor can help you avoid mistakes that took them years to understand.</p><p>A friend can provide a new perspective.</p><p>A community can expose you to opportunities you never knew existed.</p><p>Many people try to figure everything out alone. But learning from the experiences of others is one of the fastest ways to grow.</p><h3>What the Tech Industry Taught Me</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*ZwHdCDLEq9J85w-68DKW1g.jpeg" /></figure><p>In technology, many students become obsessed with checklists:</p><ul><li>DSA</li><li>System Design</li><li>Development</li><li>Certifications</li><li>Competitive Programming</li></ul><p>These things are important.</p><p>But there is another factor that many people underestimate: people.</p><p>Building genuine connections with professionals, mentors, founders, engineers, and learners can teach you lessons that no textbook can provide.</p><p>Conversations reveal real-world experiences.</p><p>Networking opens unexpected opportunities.</p><p>Learning from others helps you understand what actually matters in the industry.</p><p>Knowledge is powerful, but relationships often determine how effectively that knowledge can be applied.</p><h3>Don’t Chase Luxury Too Early</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*nIKlFAP_Lp2XRcJZuIMaOA.jpeg" /></figure><p>One mistake many young professionals make is focusing too much on luxury and external validation.</p><p>The latest gadgets.</p><p>The expensive lifestyle.</p><p>The status symbols.</p><p>While there’s nothing wrong with enjoying success, making luxury the primary goal can distract us from what truly matters: learning.</p><p>At a young age, knowledge compounds faster than money.</p><p>Skills create opportunities.</p><p>Experience creates confidence.</p><p>Learning creates long-term value.</p><p>The more we invest in ourselves, the greater the returns become later in life.</p><h3>Learning Is the One Asset Nobody Can Take Away</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QOqDHSUBeAn7SehY0ZuiQA.jpeg" /></figure><p>Life is unpredictable.</p><p>Projects fail.</p><p>Companies change.</p><p>Markets fluctuate.</p><p>Unexpected challenges appear.</p><p>Sometimes things don’t go according to plan.</p><p>But there is one thing that remains with you no matter what happens: your learning.</p><p>Skills can be applied again.</p><p>Knowledge can be reused.</p><p>Experience can be leveraged in new situations.</p><p>Everything else may change, but the lessons you’ve learned stay with you.</p><p>That is why investing in yourself is one of the safest investments you’ll ever make.</p><h3>Final Thoughts</h3><p>Life is not a race against everyone else.</p><p>It’s a process of becoming a better version of yourself.</p><p>Take your time.</p><p>Choose the right direction.</p><p>Think less and act more.</p><p>Learn from people who have walked the path before you.</p><p>Focus on growth instead of luxury.</p><p>And remember that every skill you develop becomes a permanent part of who you are.</p><p>Because in the end, success is not built by rushing.</p><p>It is built by consistent learning, patience, meaningful relationships, and the courage to keep moving forward even when progress feels slow.</p><p>Keep learning. Keep growing. The results will come.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d259416952b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>