<?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 Tanmay Gandhi on Medium]]></title>
        <description><![CDATA[Stories by Tanmay Gandhi on Medium]]></description>
        <link>https://medium.com/@tanmaygandhi2?source=rss-5fb0befe22fb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lYB1Agy_IhdehO1vCLd_Lw.jpeg</url>
            <title>Stories by Tanmay Gandhi on Medium</title>
            <link>https://medium.com/@tanmaygandhi2?source=rss-5fb0befe22fb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 09:46:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tanmaygandhi2/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[Andrej Karpathy’s LLM Wiki Pattern: I Built It in One Night]]></title>
            <link>https://medium.com/@tanmaygandhi2/andrej-karpathys-llm-wiki-pattern-i-built-it-in-one-night-fdcd72fb5c8a?source=rss-5fb0befe22fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdcd72fb5c8a</guid>
            <category><![CDATA[personal-branding]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Tanmay Gandhi]]></dc:creator>
            <pubDate>Sun, 17 May 2026 12:02:03 GMT</pubDate>
            <atom:updated>2026-05-17T12:02:03.535Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How Karpathy’s LLM Wiki pattern helped me ship a personal AI assistant in one night</em></p><figure><img alt="Dark-themed hero image with the title “I Built a Personal AI That Answers on My Behalf” in white and electric lime text, with a node graph and code snippet in the background." src="https://cdn-images-1.medium.com/max/690/1*QbfXU72wh24dvZtQQdjCQg.png" /><figcaption>Dark-themed hero image with the title “I Built a Personal AI <br>That Answers on My Behalf” in white and electric lime text, <br>with a node graph and code snippet in the background.</figcaption></figure><p>I’ve been a developer for 5.5 years. I’ve built EdTech platforms, integrated multiple SIS and CRM systems, led client implementations, and shipped products used by 100+ institutions.</p><p>But if you landed on my portfolio and wanted to know any of that — you’d have to read through a wall of text and hope you found the right section.</p><p>So I built something different. An AI that represents me. You ask it anything — my skills, my projects, what I’m currently building, whether I’m open to work — and it answers as me, in my voice, with accurate information.</p><p>Here’s exactly how I built it, what I got wrong first, and why the approach I ended up with is more interesting than the obvious solution.</p><h3>The Obvious Solution I Didn’t Use: RAG</h3><p>When most developers hear “AI + personal knowledge base,” they reach for RAG — Retrieval Augmented Generation. I did it too!</p><p>The setup is familiar:</p><ol><li>Dump your documents into a vector database</li><li>At query time, embed the user’s question</li><li>Retrieve the most “similar” chunks</li><li>Stuff those chunks into an LLM prompt</li><li>Get an answer</li></ol><p>RAG is genuinely powerful for large document collections. But for a personal assistant, it has a fundamental problem: <strong>it retrieves based on semantic similarity, not relevance to answering the question.</strong></p><p>Ask “are you open to work?” and your RAG pipeline might retrieve your skills section instead of your goals section — because “open to work” is semantically closer to a list of technologies than a career goals document. The retrieval step actively gets in the way.</p><p>There’s also the operational overhead — embeddings, a vector database, a retrieval pipeline, re-embedding whenever your knowledge changes. That’s a lot of infrastructure for a problem that doesn’t need it.</p><h3>The Insight: Andrej Karpathy’s LLM Wiki Pattern</h3><p>Karpathy proposed something more elegant. Instead of retrieving at query time, you <strong>pre-compile your knowledge</strong> into a structured wiki using an LLM — once, at write time.</p><p><a href="https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f">The original gist</a></p><p>The key insight is that modern LLMs have massive context windows. Claude Sonnet supports 200,000 tokens. My entire personal wiki — everything about me, my skills, my projects, my opinions — compiles to roughly 4,000 tokens. That’s <strong>2% of the available context window.</strong></p><p>At that scale, retrieval is solving a problem that doesn’t exist. Just send the whole thing.</p><p>The pattern has two parts:</p><p><strong>Write time:</strong> When you add or update knowledge, an LLM processes the new information, merges it with existing wiki files, resolves contradictions, and adds cross-references. The compiled output is clean, structured, and ready to use.</p><p><strong>Query time:</strong> The compiled wiki goes into the system prompt on every request. The LLM reads everything, reasons over it, and answers. No retrieval step. No missing context. No chunks that should have been included but weren’t.</p><pre>[ Raw MD Files ] → [ LLM Compiler ] → [ compiled_wiki.md ] → [ Query LLM ] → [ Answer ]<br><br>This compilation happens ONCE (or when files change).<br>Not on every query.</pre><figure><img alt="Side-by-side comparison of RAG vs LLM Wiki architecture. Left shows RAG’s multi-step retrieval pipeline with problems listed in red. Right shows LLM Wiki’s compile-once, query-with-full-context approach with benefits in green." src="https://cdn-images-1.medium.com/max/680/1*0koAV-mN5ej75Ht-dXNjzw.png" /><figcaption>Side-by-side comparison of RAG vs LLM Wiki architecture. <br>Left shows RAG’s multi-step retrieval pipeline with problems <br>listed in red. Right shows LLM Wiki’s compile-once, <br>query-with-full-context approach with benefits in green.</figcaption></figure><h3>What I Actually Built</h3><p>The architecture is simpler than it sounds:</p><pre>assistant.tanmaygandhi.com    →  Next.js frontend (Vercel)<br>api.tanmaygandhi.com          →  Express backend (Render)<br>  /tanmay-ai/chat             →  Streaming chat endpoint<br>  /tanmay-ai/status           →  Wiki compilation status<br>  /tanmay-ai/health           →  Health check</pre><h3>The Wiki Files</h3><p>I started by writing honest markdown files about myself:</p><ul><li>about_me.md — who I am, my background, my personality, my current situation</li><li>skills.md — technical skills with honest ratings and context (not just a list)</li><li>projects.md — projects I&#39;ve actually built, with scale and impact</li><li>SCHEMA.md — the personality and tone file. How the bot should sound, what it should never say, how to handle leads</li></ul><p>The SCHEMA.md is the most underrated file. It&#39;s what makes the bot sound like me and not a LinkedIn press release.</p><pre># SCHEMA.md excerpt<br>Tone: Direct. No corporate fluff. Slightly informal.<br>Confident without arrogance.<br>Honest — if something is outside Tanmay&#39;s expertise, say so.<br>Never use markdown formatting in responses. Plain prose only.<br>SHORT questions get ONE sentence. No elaboration.</pre><h3>The Compiler</h3><p>On server startup, this runs:</p><pre>async function compileWiki() {<br>  const rawFiles = fs.readdirSync(WIKI_DIR)<br>    .filter(f =&gt; f.endsWith(&quot;.md&quot;) &amp;&amp; f !== &quot;compiled_wiki.md&quot;);<br>  const rawContent = rawFiles.map(file =&gt; {<br>    const content = fs.readFileSync(path.join(WIKI_DIR, file), &quot;utf-8&quot;);<br>    return `\n\n---\n## SOURCE FILE: ${file}\n\n${content}`;<br>  }).join(&quot;\n&quot;);<br>  const response = await client.messages.create({<br>    model: &quot;claude-sonnet-4-20250514&quot;,<br>    max_tokens: 2048,<br>    messages: [{ role: &quot;user&quot;, content: compilerPrompt }],<br>  });<br>  fs.writeFileSync(COMPILED_WIKI_PATH, compiled, &quot;utf-8&quot;);<br>}</pre><figure><img alt="Render deployment logs showing the server starting, wiki compilation triggering, and the success message “Wiki compiled from 4 files → compiled_wiki.md” confirming the LLM Wiki pattern working in production." src="https://cdn-images-1.medium.com/max/1024/1*2c8eRZvOShVCy_xPe1-KyQ.png" /><figcaption>Render deployment logs showing the server starting, wiki <br>compilation triggering, and the success message “Wiki compiled <br>from 4 files → compiled_wiki.md” confirming the LLM Wiki <br>pattern working in production.</figcaption></figure><p>The compiler prompt tells the LLM to extract only what’s explicitly written, deduplicate across files, add a Quick Reference section at the top, and keep the SCHEMA behaviour rules verbatim at the end.</p><p><strong>Important rule:</strong> Extract only. Do not infer. Do not elaborate. Every sentence in the compiled wiki must be traceable to a source file.</p><p>I also added hash-based change detection — if the source files haven’t changed since the last compile, skip recompilation. No wasted API calls on restart.</p><pre>function hashWikiSources() {<br>  const files = fs.readdirSync(WIKI_DIR)<br>    .filter(f =&gt; f.endsWith(&quot;.md&quot;) &amp;&amp; f !== &quot;compiled_wiki.md&quot;)<br>    .sort();<br>  const content = files.map(f =&gt; <br>    fs.readFileSync(path.join(WIKI_DIR, f), &quot;utf-8&quot;)<br>  ).join(&quot;\n&quot;);<br>  return crypto.createHash(&quot;sha256&quot;).update(content).digest(&quot;hex&quot;);<br>}</pre><p>And a file watcher with a 5-second debounce — edit any wiki file, the server recompiles automatically. No restarts needed.</p><pre>fs.watch(WIKI_DIR, (eventType, filename) =&gt; {<br>  if (!filename?.endsWith(&quot;.md&quot;) || filename === &quot;compiled_wiki.md&quot;) return;<br>  clearTimeout(debounceTimer);<br>  debounceTimer = setTimeout(() =&gt; compileWiki(), 5000);<br>});</pre><h3>The Chat Endpoint</h3><p>Streaming responses, compiled wiki in system prompt, lead capture built in:</p><pre>app.post(&quot;/tanmay-ai/chat&quot;, async (req, res) =&gt; {<br>  res.setHeader(&quot;Content-Type&quot;, &quot;text/event-stream&quot;);<br>  const stream = await client.messages.stream({<br>    model: &quot;claude-sonnet-4-20250514&quot;,<br>    max_tokens: 1024,<br>    system: buildSystemPrompt(), // reads compiled_wiki.md<br>    messages: req.body.messages,<br>  });<br>  let fullResponse = &quot;&quot;;<br>  for await (const chunk of stream) {<br>    if (chunk.type === &quot;content_block_delta&quot;) {<br>      const text = chunk.delta.text;<br>      fullResponse += text;<br>      res.write(`data: ${JSON.stringify({ text })}\n\n`);<br>    }<br>  }<br>  // Auto-detect and log hiring/collaboration intent<br>  extractAndLogLead(fullResponse, lastUserMessage);<br>  res.write(`data: ${JSON.stringify({ done: true })}\n\n`);<br>  res.end();<br>});</pre><p>When the bot detects hiring or collaboration intent in its own response, it appends a [LEAD DETECTED] block and the server logs it to a leads.jsonl file. Passive lead capture — no forms, no friction.</p><h3>Things I Got Wrong Along the Way</h3><h3>1. I added prompt caching when I didn’t need it</h3><p>Anthropic’s API supports cache_control: { type: &quot;ephemeral&quot; } — it caches the system prompt server-side and dramatically reduces token costs on repeated requests.</p><p>I added it immediately because it seemed smart. Then I thought about it: my wiki is ~4,000 tokens. At Claude Sonnet pricing, that’s roughly $0.000012 per message. At 1,000 messages a month — $0.012.</p><p>The cache TTL is 5 minutes. In real usage as a personal assistant, most visitors will have a cold cache anyway. I was adding complexity to solve a cost problem I didn’t have.</p><p>I removed it. The code is simpler. The behaviour is identical for my use case.</p><p><strong>Lesson:</strong> Optimise for the actual problem, not the hypothetical one.</p><h3>2. Rate limits hit me harder than expected</h3><p>On a new Anthropic account with no credits loaded, you’re on a very tight rate limit — 8,000 output tokens per minute. The compiler alone consumes 2,048 tokens in one shot. Then you try to chat immediately after and hit the ceiling.</p><p>Fix: load $5 of credits. That moves you to Tier 1 instantly — limits jump significantly. The compiler and chat endpoint stop competing with each other.</p><h3>3. Railway’s free tier blocks outbound requests</h3><p>I deployed to Railway first. Everything looked right — API key present, code correct, server starting. But the Anthropic API call was failing with a generic “Connection error.”</p><p>Root cause: Railway’s free tier has IPv6 outbound restrictions. Even after enabling the IPv6 toggle, it didn’t resolve cleanly.</p><p>I switched to Render. The same code deployed without any networking issues. First try.</p><p><strong>Lesson:</strong> When you’re fighting infrastructure instead of building, switch the infrastructure.</p><h3>The UI</h3><p>Dark theme, split layout — sidebar with wiki status, suggestions, and links on the left; streaming chat on the right.</p><p>The wiki status panel is one of my favourite details. It shows:</p><ul><li>Whether the wiki is compiling, ready, or errored</li><li>Which files were compiled</li><li>When the last compilation happened</li></ul><figure><img alt="Close-up of the chat interface sidebar showing “wiki ready · 4 files” status with green checkmarks next to each compiled markdown file and the last compilation timestamp." src="https://cdn-images-1.medium.com/max/550/1*yAP3Rb23ADMPJwpnt6-oZw.png" /><figcaption>Close-up of the chat interface sidebar showing “wiki ready · <br>4 files” status with green checkmarks next to each compiled <br>markdown file and the last compilation timestamp.</figcaption></figure><p>Visitors can see the system working in real time. It makes the architecture transparent and — honestly — makes for a better first impression than a blank chat box.</p><p>Built with Next.js and Tailwind. No component library. Space Grotesk for the UI font, JetBrains Mono for the technical elements.</p><figure><img alt="Screenshot of assistant.tanmaygandhi.com showing a dark chat interface with a sidebar displaying wiki compilation status, suggested questions, and social links, alongside a live conversation with Tanmay’s AI assistant." src="https://cdn-images-1.medium.com/max/1024/1*Jy1OWkwpFgEFRujnwxk71g.png" /><figcaption>Screenshot of assistant.tanmaygandhi.com showing a dark chat interface with a sidebar displaying wiki compilation status, suggested questions, and social links, alongside a live conversation with Tanmay’s AI assistant.</figcaption></figure><h3>What This Is Actually Good For</h3><p>Beyond the technical exercise, this is a genuinely useful tool:</p><p><strong>For recruiters:</strong> They can ask exactly what they want to know — “what’s your experience with AWS?” or “have you led client implementations?” — and get a direct, accurate answer. No hunting through a PDF resume.</p><p><strong>For collaborators:</strong> “What are you currently building?” or “are you open to side projects?” gets an honest, real-time answer based on what I’ve written in my goals file.</p><p><strong>For personal branding:</strong> The system is live at assistant.tanmaygandhi.com. It&#39;s more interesting than a static portfolio and demonstrates LLM system design in a way that a resume bullet point can&#39;t.</p><p><strong>For lead capture:</strong> Every conversation where someone expresses hiring or collaboration intent gets logged automatically. I wake up to a leads.jsonl with name, intent, and context — without ever having to check my inbox.</p><h3>Stack Summary</h3><pre>Frontend:  Next.js 14, Tailwind CSS (Vercel)<br>Backend:   Node.js, Express (Render)<br>LLM:       Claude Sonnet via Anthropic API<br>Wiki:      Markdown files — no vector DB, no embeddings<br>DNS:       GoDaddy → custom domain on both services</pre><p>No database. No authentication. No embeddings. The entire system is markdown files, one Express server, and one Next.js app.</p><h3>What’s Next</h3><p>The wiki is a living document. I’ll keep adding to it:</p><ul><li>client_integrations.md — my Salesforce, Ellucian, Anthology integration experience</li><li>experience.md — full career timeline with honest context</li><li>opinions.md — my actual takes on EdTech, the Indian dev market, LLMs</li></ul><p>Each new file makes the bot noticeably smarter. No code changes. Just write, save, watch it recompile.</p><p>Longer term: I want to see if this is productizable. If I found it useful, other developers building personal brands might too. The setup is reproducible, the wiki pattern is generalizable, and the infrastructure costs are negligible.</p><h3>One More Thing — This Is Just v1</h3><p>What you’ll find at <a href="https://assistant.tanmaygandhi.com/">assistant.tanmaygandhi.com</a> right now is a first draft. The wiki has 4 files. The bot knows the basics — my skills, my projects, a few things about who I am.</p><p>But that’s kind of the point of this post. I wanted to validate the architecture first, not perfect the content. And it works — the pattern holds up, the compilation is fast, the answers are accurate to what I’ve written.</p><p>What makes this genuinely interesting is what happens as the wiki grows. Every file I add makes the bot more nuanced. opinions.md will give it real takes. client_integrations.md will let it speak to the depth of my enterprise work. experience.md will give it context for why I made the career decisions I did.</p><p>Right now it answers questions correctly. Eventually it’ll answer them the way I actually would — with the texture, the opinions, and the honesty of someone you’ve had a real conversation with. Less FAQ, more actually talking to me.</p><p>The architecture is proven. Now the interesting work begins — filling it with enough of myself that it stops feeling like a bot.</p><p>I’ll keep building it in public at <a href="https://www.instagram.com/tanmaygandhi.builds">@tanmaygandhi.builds</a>.</p><h3>Try It</h3><p>Chat with my AI at <a href="https://assistant.tanmaygandhi.com/"><strong>assistant.tanmaygandhi.com</strong></a></p><p>The repo is open source: <a href="https://github.com/tanmaygandhi2901/ai-assistant"><strong>github.com/tanmaygandhi2901/ai-assistant</strong></a></p><p>If you build your own version, I’d genuinely like to see it.</p><h3>Further Reading</h3><p>- <a href="https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f">Andrej Karpathy’s original LLM Wiki gist</a> — the idea this entire project is built on<br>- <a href="https://assistant.tanmaygandhi.com/">assistant.tanmaygandhi.com</a> — try the live version<br>- <a href="https://github.com/tanmaygandhi2901/ai-assistant">github.com/tanmaygandhi2901/ai-assistant</a> — full source code</p><p><em>I’m Tanmay Gandhi — Tech Lead with 5.5 years in JS, currently going deep on LLMs, Agentic AI and AI systems. I document what I build at </em><a href="https://www.instagram.com/tanmaygandhi.builds"><em>@tanmaygandhi.builds</em></a><em> and write here on Medium. If you want to collaborate or just talk shop — </em><a href="https://www.linkedin.com/in/tanmaygandhi-code/"><em>LinkedIn</em></a><em> or </em><a href="/service/mailto:tanmaygandhi2901@gmail.com"><em>email</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdcd72fb5c8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Got Tired of Not Fully Understanding What I Read — So I Built Something for Myself]]></title>
            <link>https://medium.com/@tanmaygandhi2/i-got-tired-of-not-fully-understanding-what-i-read-so-i-built-something-for-myself-d501519363e1?source=rss-5fb0befe22fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/d501519363e1</guid>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Tanmay Gandhi]]></dc:creator>
            <pubDate>Fri, 24 Apr 2026 20:49:12 GMT</pubDate>
            <atom:updated>2026-04-24T20:49:12.912Z</atom:updated>
            <content:encoded><![CDATA[<p>I read a lot.</p><p>Not in a “I should read more” kind of way, but genuinely.<br>Tech blogs, AI stuff, product breakdowns, random threads… anything that helps me stay sharp.</p><p>And most of the time, I enjoy it.</p><p>But there was this one thing that kept bothering me.</p><h3>I wasn’t always understanding what I was reading.</h3><p>Not completely.</p><p>Like… I’d get the gist.<br> I’d follow along.<br> But every now and then, something would feel slightly off.</p><ul><li>A sentence that feels heavier than it should</li><li>A word I’ve seen before, but not like <em>this</em></li><li>A concept that assumes I know more than I do</li></ul><p>And instead of stopping, I’d just… keep going.</p><p>Not because I understood it.<br>Just because it was easier.</p><h3>The alternative was worse</h3><p>Whenever I <em>did</em> try to understand properly, it looked like this:</p><ul><li>Highlight the text</li><li>Open a new tab</li><li>Search or ask AI</li><li>Copy-paste the sentence</li><li>Read the explanation</li><li>Come back</li><li>Try to reconnect everything</li></ul><p>It sounds fine when you say it once.</p><p>But do it 10 times in one article: and your brain is done.</p><p>You lose the flow.<br> You lose interest.<br> Sometimes you don’t even come back.</p><h3>So I started ignoring things I didn’t fully understand</h3><p>And that didn’t sit right with me.</p><p>Because the whole point of reading all this stuff was to <em>learn better</em>, not just skim faster.</p><p>That’s when something clicked.</p><h3>The problem wasn’t knowledge. It was friction.</h3><p>All the answers already exist.</p><p>Google has them.<br>AI definitely has them.</p><p>But the process of getting those answers?</p><p>It’s just… annoying.</p><blockquote><em>I don’t need smarter tools.<br>I need tools that don’t get in my way.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*gGT0HLBtjyeZaw-agRwKXw.png" /></figure><h3>So I built something for myself</h3><p>Nothing fancy.</p><p>Just a simple idea:</p><blockquote><em>What if I could highlight something and instantly understand it…<br> without leaving the page?</em></blockquote><p>No new tabs.<br>No typing.<br>No breaking focus.</p><p>Just:</p><p><strong>Select → understand → keep reading</strong></p><h3>That’s how this little Chrome extension started</h3><p>I didn’t think of it as a product at first.</p><p>It was just something I wanted while reading.</p><p>Something that could:</p><ul><li>Look at what I selected</li><li>Understand the context around it</li><li>Explain it in simple terms</li><li>And also tell me what it actually means</li></ul><p>Because I realized something really important while building it:</p><blockquote><em>Understanding isn’t just about meaning.<br> It’s also about context.</em></blockquote><p>You need both.</p><h3>A small example</h3><p>Let’s say you’re reading:</p><blockquote><em>“The agent dynamically optimizes inference latency…”</em></blockquote><p>You <em>could</em> look up:</p><ul><li>“Agent”</li><li>“Latency”</li></ul><p>But that won’t really help.</p><p>What you actually need is:</p><ul><li>What “agent” means in AI</li><li>What “inference latency” means in that system</li><li>And why that sentence matters</li></ul><p>That’s the difference between:</p><ul><li>Reading words</li><li>And actually getting what’s going on</li></ul><h3>The interesting part? Building it wasn’t the hard thing</h3><p>The AI part is… honestly accessible now.</p><p>What mattered more was everything around it:</p><ul><li>Making it fast enough</li><li>Making it feel natural</li><li>Making sure it doesn’t interrupt you</li></ul><p>I didn’t want it to feel like a tool.</p><p>I wanted it to feel like something that just <em>belongs there</em>.</p><h3>The first time it actually felt right</h3><p>I was reading something a bit dense.</p><p>Highlighted a sentence.<br>Got a clean explanation.<br>And just… continued reading.</p><p>No break. No friction.</p><p>That small moment felt bigger than I expected.</p><p>Because that’s exactly what I had been missing.</p><h3>So I decided to share it</h3><p>I cleaned it up a bit.<br>Put it out.<br>Open-sourced it.</p><p>Not because it’s perfect.</p><p>But because I figured — <br>if I’ve been facing this, someone else probably has too.</p><p>👉 GitHub: <a href="https://github.com/tanmaygandhi2901/context-search">https://github.com/tanmaygandhi2901/context-search</a><br> 👉 Chrome Extension: <a href="https://chromewebstore.google.com/detail/medpikanoaedpjdkcopaehpmdjnoadij">https://chromewebstore.google.com/detail/medpikanoaedpjdkcopaehpmdjnoadij</a></p><h3>What this taught me</h3><p>A few things stayed with me after building this:</p><p><strong>1. Small annoyances are worth paying attention to</strong><br> They usually hide good ideas.</p><p><strong>2. AI isn’t the advantage anymore</strong><br> Everyone has access to it.<br> How you <em>use</em> it is what matters.</p><p><strong>3. Context changes everything</strong><br> The same word can mean completely different things depending on where you see it.</p><h3>What I’m thinking about next</h3><p>There’s still a lot I want to improve:</p><ul><li>Making it faster</li><li>Making explanations even clearer</li><li>Letting users choose how deep they want to go</li><li>Supporting more types of content</li></ul><p>Nothing crazy. Just steady improvements.</p><h3>Final thought</h3><p>We’re reading more than ever.</p><p>But if we’re being honest: a lot of that reading is surface-level.</p><p>Not because we want it that way.<br>But because going deeper takes effort.</p><p>If I can reduce even a little bit of that effort — <br>for myself, and maybe for a few others —</p><p>that’s more than enough reason to keep building this.</p><p>If you end up trying it, I’d genuinely love to know how it feels to use.</p><p>And if you’ve ever had that moment where you think:</p><blockquote><em>“I get it… but not really”</em></blockquote><p>Yeah.<br>That’s exactly where this came from.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d501519363e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When AI Writes Your Production Code: A Real Incident That Took Down Our Internal Database]]></title>
            <link>https://medium.com/@tanmaygandhi2/when-ai-writes-your-production-code-a-real-incident-that-took-down-our-internal-database-11060b2427d9?source=rss-5fb0befe22fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/11060b2427d9</guid>
            <category><![CDATA[systems-thinking]]></category>
            <category><![CDATA[developer-mindset]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[senior-developer]]></category>
            <category><![CDATA[database-design]]></category>
            <dc:creator><![CDATA[Tanmay Gandhi]]></dc:creator>
            <pubDate>Wed, 11 Mar 2026 12:35:09 GMT</pubDate>
            <atom:updated>2026-03-11T12:42:01.556Z</atom:updated>
            <content:encoded><![CDATA[<p>A few days ago I ran into a production issue that looked small on the surface but ended up exposing a deeper engineering problem.</p><p>We started receiving alert emails saying that <strong>database connections had crossed 80% of the configured limit</strong>.</p><p>At first it didn’t look alarming. The system was still running and nothing had actually broken yet.</p><p>But eventually something did break.</p><p>Our internal production/development database <strong>started rejecting new connections</strong>, which meant internal testing suddenly stopped working. Multiple teams were blocked and what looked like a routine infrastructure alert turned into a debugging session.</p><p>As the senior developer on the team, the issue was assigned to me to investigate.</p><p>The interesting part is that the technical root cause was fairly simple.</p><p>The uncomfortable part was <strong>why it happened in the first place</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wr3qgVlCblx5vi9fZG5flA.jpeg" /><figcaption>AI Coding</figcaption></figure><h3>The First Clue Was in the Alert</h3><p>The alert itself was already hinting at the problem.</p><p>It clearly said that <strong>connection usage had crossed 80% of the configured limit</strong>.</p><p>When a database reaches its connection cap:</p><ul><li>new connections start getting rejected</li><li>services fail to open new sessions</li><li>requests begin failing</li></ul><p>This usually points to <strong>a connection pooling issue</strong>.</p><p>So the first thing I checked was how our services were connecting to the database.</p><h3>What the Code Looked Like</h3><p>We have three services that directly access the database.</p><p>While going through the code, I noticed something surprising: <strong>none of them had any pool configuration at all.</strong></p><p>The connection code looked roughly like this:</p><pre>mongoose.connect(DB_URI)</pre><p>That was it.</p><p>No tuning. No limits. No environment-specific configuration.</p><p>Ideally you want something closer to this:</p><pre>mongoose.connect(DB_URI, {<br>maxPoolSize: 10,<br>minPoolSize: 1,<br>maxIdleTimeMS: 30000,<br>serverSelectionTimeoutMS: 5000,<br>socketTimeoutMS: 45000<br>})</pre><p>These options control how aggressively your service consumes database connections and how those connections behave under load.</p><p>Without explicit configuration, <strong>MongoDB’s Node driver defaults to a pool size of 100 connections per client instance</strong>.</p><p>That default is fine for some cases but it becomes dangerous when multiple services and developer machines are all connecting to the same database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*Z1z88HdHqaOiPhCTcl21uQ.png" /></figure><h3>How the Connection Explosion Happened</h3><p>Once we mapped the architecture, the math became pretty obvious.</p><p>We had:</p><ul><li>3 services</li><li>each service using the default pool size of 100</li><li>multiple developers running services locally</li></ul><p>So the rough mental model looked like this:</p><p>Connections = 3 services × 100 pool size × N developers × M Instances</p><p>If 10 developers ran the services locally, that alone could create <strong>3000 possible connections</strong>.</p><p>And that doesn’t even include cloud instances or background workers.</p><p>To make things worse, developers were allowed to connect their local services directly to shared development databases.</p><p>That meant the database was receiving connection pools from:</p><ul><li>cloud service instances</li><li>multiple developer laptops</li><li>background jobs</li></ul><p>For a while the system survived this because traffic was still low.</p><p>But as usage increased, the connection pressure slowly built up until the database started rejecting new connections.</p><h3>The Second Problem: Connection Lifecycle</h3><p>While digging through the codebase, I also found another issue.</p><p>In a few places, connections were being created inside business logic like this:</p><pre>try {<br>const connection = await mongoose.createConnection(uri)<br>// perform some operations<br>await connection.close()<br>} catch (err) {<br>console.error(err)<br>}</pre><p>At first glance this looks fine.</p><p>But there’s a subtle problem here.</p><p>If execution fails <strong>after the connection is created but before it reaches the close statement</strong>, the connection might never be cleaned up.</p><p>Without a proper finally block or centralized connection management, these kinds of leaks slowly accumulate. Over time they contribute to connection exhaustion.</p><p>This is something I see quite often in AI-assisted backend code. The main flow works, but <strong>resource lifecycle management isn’t always handled carefully</strong>.</p><h3>Why the Issue Stayed Hidden for Months</h3><p>The tricky thing about this type of bug is that it doesn’t fail immediately.</p><p>For the first 5–6 months everything worked fine. The team was smaller, the product was new, and traffic was relatively low.</p><p>Under those conditions, the defaults were good enough and nobody questioned them.</p><p>But once the system started growing, those hidden assumptions started turning into operational problems.</p><p>This is where relying too heavily on AI-generated code becomes risky.</p><p>AI can produce code that <strong>works perfectly in local testing</strong>, but that doesn’t necessarily mean it behaves well under real-world load.</p><p>Things like:</p><ul><li>connection limits</li><li>resource cleanup</li><li>concurrency behavior</li><li>infrastructure constraints</li></ul><p>are rarely visible until the system actually scales.</p><h3>What We Changed</h3><p>To stabilize things, we introduced a few changes.</p><h3>1. Added explicit connection configuration</h3><p>We stopped relying on driver defaults and introduced environment-specific pool configuration in the codebase.</p><p>This gave us much better control over how many connections each service could create.</p><h3>2. Restricted database access from local machines</h3><p>Developers no longer have unrestricted access to shared environment databases from their laptops.</p><p>Access is now controlled by the Cloud team and limited to a small number of people.</p><p>This alone reduced connection pressure significantly.</p><h3>3. Added more realistic load testing</h3><p>This issue probably should have been caught earlier through concurrency and load testing.</p><p>A backend service isn’t truly healthy just because its endpoints work.</p><p>It needs to behave correctly under:</p><ul><li>scale</li><li>failure</li><li>concurrent traffic</li></ul><h3>4. Planning architectural improvements</h3><p>Long term, we’re planning to centralize database access so that connection management is easier to control and reason about.</p><p>Right now multiple services connect directly to the database, which makes it harder to predict connection usage.</p><h3>The Bigger Lesson</h3><p>The point of writing this isn’t to say that AI should not be used.</p><p>AI tools are incredibly useful and can speed up development significantly.</p><p>The real issue is <strong>how developers are using them</strong>.</p><p>What worries me is that AI is making it easier for developers to generate code without building the mental models needed to maintain it.</p><p>A developer who has never dealt with connection pooling can now integrate a database in minutes.</p><p>A developer who has never debugged concurrency issues can still ship code that appears perfectly fine in local testing.</p><p>But when systems scale, those missing fundamentals start to show.</p><h3>AI Should Accelerate Thinking , Not Replace It</h3><p>Good engineers use AI as a tool.</p><p>They still ask questions like:</p><ul><li>What are the defaults of this library?</li><li>How does this behave under load?</li><li>What happens if this fails halfway through?</li><li>Who owns the lifecycle of these resources?</li></ul><p>If those questions are skipped, AI doesn’t just speed up development.</p><p>It speeds up the creation of bugs that take much longer to discover.</p><h3>Final Thought</h3><p>This outage wasn’t caused by a complex bug.</p><p>It was caused by <strong>missing fundamentals</strong>.</p><p>Connection pooling is a basic backend concept, yet an entire service stack was running without proper configuration.</p><p>AI didn’t cause the problem.</p><p>But blind reliance on AI made it easier to ship code without understanding the consequences.</p><p>As AI becomes more powerful, the most valuable developers won’t be the ones who generate the most code.</p><p>They’ll be the ones who understand <strong>how their systems behave in production</strong>.</p><p>Because when production breaks, prompts won’t fix it.</p><p>Understanding will.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xj5DAiwMXTifmZepmWNncw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11060b2427d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Disaster Recovery in System Architecture: A Deep Dive]]></title>
            <link>https://medium.com/@tanmaygandhi2/disaster-recovery-in-system-architecture-a-deep-dive-2546ea5f91c6?source=rss-5fb0befe22fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/2546ea5f91c6</guid>
            <category><![CDATA[recovery-techniques]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[disaster-recovery]]></category>
            <dc:creator><![CDATA[Tanmay Gandhi]]></dc:creator>
            <pubDate>Sat, 11 Jan 2025 09:02:19 GMT</pubDate>
            <atom:updated>2025-01-11T09:02:19.048Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J5NBhSIda9-KubQaOKpxUw.jpeg" /></figure><p>In today’s digital age, system downtime can be catastrophic, leading to financial losses, reputational damage, and even legal repercussions. This is where Disaster Recovery (DR) comes into play. DR refers to the ability of an organization to recover and resume operations following a disruptive event, such as a natural disaster, cyberattack, or human error.</p><p>This blog post delves into the complexities of DR in system architecture, exploring advanced concepts and strategies to ensure business continuity.</p><h3>RPO and RTO: The Cornerstones of DR</h3><p>Before we dive into specific DR strategies, it’s crucial to understand two fundamental concepts: <strong>Recovery Point Objective (RPO)</strong> and <strong>Recovery Time Objective (RTO)</strong>.</p><ul><li><strong>RPO:</strong> This defines the maximum acceptable amount of data loss in case of a disaster. For instance, an RPO of one hour means that, at most, one hour’s worth of data can be lost.</li><li><strong>RTO:</strong> This defines the maximum acceptable downtime for an application or system. An RTO of two hours means the system must be restored within two hours of a disaster.</li></ul><p>Determining the appropriate RPO and RTO depends on various factors, including business criticality, regulatory requirements, and cost considerations.</p><h3>Minimizing RPO: The Quest for Zero Data Loss</h3><p>Traditional backup mechanisms, while essential, often lead to some data loss. To minimize RPO, organizations can leverage technologies like:</p><ul><li><strong>Real-time replication:</strong> This involves continuously copying data changes from a primary storage system to a secondary system, often located in a different geographical region. This ensures that the secondary system has an almost identical copy of the data, minimizing data loss in a disaster. Database replication tools (e.g., MySQL replication, Oracle Data Guard), storage-level replication (e.g., synchronous mirroring), and specialized software solutions are commonly used for this purpose. However, challenges like maintaining data consistency across geographically dispersed locations, dealing with network latency, and ensuring the secondary system can handle the write load need to be addressed.</li><li><strong>Continuous data protection (CDP):</strong> CDP goes beyond traditional backups by capturing every change made to data. This allows for granular recovery to any point in time, effectively eliminating data loss. Technologies like journal-based replication, snapshotting, and change block tracking are employed for CDP. While CDP offers benefits like granular recovery, reduced RPO, and improved data protection, it comes with challenges such as higher storage requirements and potential performance impact on the primary system.</li></ul><h3>Optimizing RTO: Reducing Downtime</h3><p>Reducing RTO requires strategies that enable rapid system recovery. Some common approaches include:</p><ul><li><strong>Failover clustering:</strong> This involves a group of servers that work together to provide high availability. If one server fails, another server in the cluster automatically takes over its workload. This can be achieved through active-passive clustering (one server is active, others are on standby) or active-active clustering (all servers are active, sharing the workload). Failover clustering offers benefits like high availability, reduced downtime, and improved fault tolerance, but it introduces complexities like increased cost and the potential for split-brain scenarios (where two servers believe they are the active node).</li><li><strong>Load balancing:</strong> Distributing incoming network traffic across multiple servers ensures that if one server fails, the others can handle the load. This can be done through Layer 4 (transport layer) load balancing (based on IP addresses and ports) or Layer 7 (application layer) load balancing (based on HTTP headers and content). Load balancing increases capacity, improves performance, and reduces the risk of single points of failure, but requires careful configuration and management of load balancers and can potentially lead to bottlenecks if the load balancer itself fails.</li><li><strong>Virtualization:</strong> Allows multiple virtual machines (VMs) to run on a single physical server. This improves resource utilization, simplifies management, and enhances disaster recovery capabilities. Virtualization enables easy migration of VMs to different physical servers, rapid provisioning of new VMs, and improved hardware utilization. However, it can introduce performance overhead, security concerns related to VM isolation, and reliance on the underlying virtualization infrastructure.</li></ul><h3>DR Strategies: A Spectrum of Approaches</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DmC7T950erzW0CD4" /></figure><p>There are several DR strategies, each with its own trade-offs in terms of cost, complexity, and recovery time.</p><ol><li><strong>Backup and Restore: </strong>This is the most basic and cost-effective approach, involving regular backups to a secondary location. However, recovery time can be significant as the entire system needs to be rebuilt from the backup.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_T7259KiAvj_-N48" /></figure><p><strong>2. Pilot Light:</strong> This strategy keeps a minimal version of the system running in a secondary location, primarily for data replication. While faster than backup and restore, it still requires significant effort to scale up the secondary environment in case of a disaster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dsy77vEhpRNCtDqi" /></figure><p><strong>3. Warm Standby:</strong> This approach maintains a scaled-down version of the primary environment in a secondary location, allowing for faster recovery. The secondary environment is kept up-to-date with data replication and can be quickly scaled up when needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yrZyzOIH3G_lMT2Q" /></figure><p><strong>4. Multi-Site Active/Active:</strong> This is the most advanced and expensive strategy, where two or more identical environments are active simultaneously. In case of a disaster, traffic is seamlessly redirected to the functioning environment, ensuring minimal downtime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wO6IX1cImY-TwXmE" /></figure><h3>Advanced DR Considerations</h3><ul><li><strong>Data consistency:</strong> Ensuring data consistency across multiple locations is critical, especially in transactional systems. Techniques like distributed consensus algorithms (e.g., Paxos, Raft, Zab) and two-phase commit protocols can help maintain data integrity. These techniques provide fault tolerance and improve reliability, but can be complex to implement and introduce performance overhead.</li><li><strong>Network latency:</strong> In geographically dispersed deployments, network latency can impact application performance. Techniques like global load balancing and content delivery networks (CDNs) can help mitigate latency issues. Global load balancing distributes traffic across servers in different regions, improving performance for users worldwide and providing disaster recovery capabilities. CDNs cache static content closer to users, improving website performance and reducing load on origin servers.</li><li><strong>Security:</strong> DR solutions must be designed with security in mind, ensuring data protection and compliance with regulatory requirements.</li><li><strong>Testing and validation:</strong> Regular DR testing is crucial to ensure the effectiveness of the solution and identify any potential issues.</li></ul><h3>Conclusion</h3><p>Disaster recovery is a complex but essential aspect of system architecture. By carefully considering RPO and RTO requirements and implementing appropriate DR strategies, organizations can minimize downtime and ensure business continuity in the face of disruptive events. Remember that DR is not a one-size-fits-all solution; the best approach depends on the specific needs and constraints of each organization.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2546ea5f91c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Monolith to Microservices: A Guide to Scaling Your Architecture with Load Balancers and API…]]></title>
            <link>https://medium.com/@tanmaygandhi2/from-monolith-to-microservices-a-guide-to-scaling-your-architecture-with-load-balancers-and-api-4ce9e56c60f5?source=rss-5fb0befe22fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ce9e56c60f5</guid>
            <category><![CDATA[monolithic-architecture]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Tanmay Gandhi]]></dc:creator>
            <pubDate>Sat, 11 Jan 2025 04:02:02 GMT</pubDate>
            <atom:updated>2025-01-11T04:02:02.956Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>From Monolith to Microservices: A Guide to Scaling Your Architecture with Load Balancers and API Gateways</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8mr1GYWBpLOejVnR7ga5uQ.jpeg" /><figcaption>Microservices Architecture</figcaption></figure><p><strong>Introduction</strong></p><p>Building scalable and reliable applications is crucial in today’s world of ever-increasing user demands. This post explores different architectural approaches, focusing on the evolution from monolithic structures to microservices. We’ll delve into load balancing and API gateways, essential components for managing and optimizing application performance.</p><p><strong>Monolithic Architecture</strong></p><p>A monolithic architecture is like a single, large container holding all application components. While simple to start with, it presents challenges as your application grows:</p><p><strong>Disadvantages:</strong></p><ul><li><strong>Slow Release Cycles:</strong> Every code change requires testing the entire application, leading to longer release cycles.</li><li><strong>Scaling Issues:</strong> Scaling a monolith often means replicating the entire application, even if only one component faces high demand, leading to inefficient resource use.</li><li><strong>Modularity Challenges:</strong> Tightly coupled components make it difficult to modify or update individual parts without affecting the whole system.</li><li><strong>All-or-Nothing Deployment:</strong> Deployments are risky, as any error can bring down the entire application.</li><li><strong>Scaling a Monolith:</strong> Imagine numerous requests hitting different parts of your application. If one area experiences a surge, you might add a new server. However, due to the monolithic structure, you’re scaling the <em>entire</em> application, not just the part under pressure. This results in unnecessary costs.</li></ul><p><strong>Microservices Architecture</strong></p><p>Microservices break down the application into smaller, independent services. This offers several advantages:</p><ul><li><strong>Independent Scaling:</strong> Each service can be scaled individually based on demand, optimizing resource usage and reducing costs.</li><li><strong>Improved Modularity:</strong> Loosely coupled services allow for easier updates and modifications without affecting other parts of the application.</li><li><strong>Faster Release Cycles:</strong> Smaller codebases allow for quicker testing and deployment of individual services.</li><li><strong>Fault Isolation:</strong> If one service fails, the rest of the application can continue to function.</li></ul><p><strong>Important Note:</strong> When scaling, ensure your database can handle the increased number of connections from multiple services.</p><p><strong>Hosting Microservices: EC2 and Containers</strong></p><p>Each microservice can be hosted on a separate EC2 instance with its own autoscaling configuration. For increased efficiency and portability, consider containerizing your microservices and deploying them on platforms like Amazon ECS or Kubernetes.</p><p><strong>Load Balancers: Distributing Traffic Efficiently</strong></p><p>Load balancers distribute incoming traffic across multiple backend services (EC2 instances, containers, or Lambda functions), ensuring no single server is overwhelmed.</p><ul><li><strong>Why Load Balancers?</strong> Imagine accessing your application without a load balancer. How would you determine which server to connect to? What happens if a server fails or autoscaling adds new instances? Load balancers address these challenges by:</li><li>Distributing traffic efficiently.</li><li>Monitoring the health of backend servers.</li><li>Providing a single point of contact for clients.</li></ul><p><strong>Types of Load Balancers:</strong></p><ul><li><strong>Application Load Balancer (ALB):</strong> Operates at Layer 7 (Application layer) of the OSI model. Routes traffic based on URL paths, enabling you to direct different requests to specific target groups. Supports SSL termination and validation using AWS Certificate Manager.</li><li><strong>Network Load Balancer (NLB):</strong> Operates at Layer 4 (Transport layer) of the OSI model. Routes traffic based on IP address and port. Ideal for high-performance applications and those requiring static IP addresses.</li></ul><p><strong>ALB vs. NLB:</strong></p><ul><li><strong>Spiky Traffic:</strong> NLBs generally handle sudden traffic spikes more effectively.</li><li><strong>Static IP:</strong> NLBs provide a static IP address, while ALBs use a DNS name. However, you can use Global Accelerator with an ALB to achieve a static IP.</li><li><strong>API Gateway Integration:</strong> REST APIs deployed through API Gateway use an NLB.</li><li><strong>Supported Targets:</strong> NLBs support EC2 instances and IP addresses, while ALBs support EC2 instances, IP addresses, and Lambda functions.</li><li><strong>Kubernetes:</strong> Both ALBs and NLBs support Kubernetes, but require additional configuration.</li></ul><p><strong>API Gateways: A Front Door for Your Microservices</strong></p><p>While load balancers distribute traffic, API gateways act as a central point of entry for your application, providing additional functionalities like security, rate limiting, and request transformation.</p><ul><li><strong>Why API Gateways?</strong> Directly accessing your microservices can become complex with millions of users. API gateways handle:</li><li><strong>Traffic Management:</strong> Handles spikes and protects backend services from overload.</li><li><strong>Authorization and Authentication:</strong> Verifies user identities and permissions.</li><li><strong>Request Transformation:</strong> Converts requests into formats understood by backend services.</li><li><strong>Other Dynamic Requests:</strong> Handles tasks not directly related to core business logic, allowing your microservices to focus on their specific functions.</li></ul><p><strong>API Gateway vs. ALB:</strong></p><ul><li><strong>Rate Limiting and Bursting:</strong> API Gateway provides built-in rate limiting and burst capacity to control traffic flow.</li><li><strong>Static IP:</strong> ALBs can have static IPs, while API Gateways use domain names.</li><li><strong>Protocol Support:</strong> API Gateways primarily use HTTPS, while ALBs support both HTTP and HTTPS.</li><li><strong>Request Validation:</strong> API Gateway can validate requests using templates (e.g., Apache Velocity) to ensure they contain required data.</li><li><strong>Spiky Traffic Handling:</strong> API Gateway generally handles spikes better due to its design and integration with other AWS services.</li><li><strong>Cross-Region and Cross-Account Functionality:</strong> API Gateway can integrate with Lambda functions across different regions and AWS accounts, while ALBs are region and account-specific.</li><li><strong>API Import/Export:</strong> API Gateway supports importing and exporting APIs using Swagger and OpenAPI specifications, facilitating portability.</li><li><strong>Authentication:</strong> API Gateway offers broader authentication options, including API keys, IAM, Cognito user pools, and external identity providers. ALBs typically integrate with OIDC-compliant providers.</li><li><strong>Caching:</strong> API Gateway can cache responses to improve performance, while ALBs do not have this capability.</li><li><strong>Timeout Limits:</strong> API Gateway has a shorter timeout limit (30 seconds) compared to ALBs (4000 seconds).</li><li><strong>Service Integration:</strong> API Gateway integrates with a wider range of AWS services, while ALBs primarily focus on EC2, Lambda, and IP addresses.</li><li><strong>Health Checks:</strong> ALBs have built-in health checks, while API Gateway requires manual implementation.</li><li><strong>Pricing:</strong> API Gateway follows a pay-per-use model, while ALBs are billed based on uptime, similar to EC2 instances.</li></ul><p><strong>Conclusion</strong></p><p>Choosing the right architecture is crucial for building scalable and resilient applications. While monolithic architectures are suitable for simpler applications, microservices offer greater flexibility and efficiency for complex systems. Load balancers and API gateways are vital components for managing traffic, ensuring high availability, and optimizing performance in a microservices environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ce9e56c60f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CAP Theorem: Navigating the Trade-offs in Modern Distributed Systems]]></title>
            <link>https://medium.com/@tanmaygandhi2/cap-theorem-navigating-the-trade-offs-in-modern-distributed-systems-992ea8511b1f?source=rss-5fb0befe22fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/992ea8511b1f</guid>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[cap-theorem]]></category>
            <category><![CDATA[system-architecture]]></category>
            <dc:creator><![CDATA[Tanmay Gandhi]]></dc:creator>
            <pubDate>Mon, 06 Jan 2025 05:02:36 GMT</pubDate>
            <atom:updated>2025-01-06T05:02:36.397Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s world of interconnected applications, distributed systems reign supreme. They offer scalability, fault tolerance, and improved performance. However, these benefits come with inherent challenges, and understanding the CAP theorem is crucial to navigating them effectively.</p><p>The CAP theorem, also known as Brewer’s theorem, states that a distributed data store can only provide two out of the following three guarantees:</p><ul><li><strong>Consistency:</strong> All nodes see the same data at the same time.</li><li><strong>Availability:</strong> Every request receives a (non-error) response, without the guarantee that it contains the most recent write.</li><li><strong>Partition tolerance:</strong> The system continues to operate despite an arbitrary number of messages being dropped (or delayed) by the network between nodes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*mdbCwi0VmFGGb7c6zUxpqg.png" /><figcaption>CAP Theorem.</figcaption></figure><p><strong>Why is the CAP Theorem Important?</strong></p><p>The CAP theorem isn’t just an abstract concept; it has real-world implications for how we design and build distributed systems. Here’s why it matters:</p><ul><li><strong>Guides Design Decisions:</strong> CAP theorem forces you to prioritize the most critical aspects of your system. Do you need absolute consistency, even at the risk of temporary unavailability? Or is availability paramount, even if it means occasional inconsistencies? This prioritization is key to selecting the right technology and architecture for your needs.</li><li><strong>Manages Expectations:</strong> It acknowledges that achieving all three guarantees simultaneously is impossible in a distributed system. This understanding prevents unrealistic expectations and promotes a pragmatic approach to system design.</li><li><strong>Facilitates Communication:</strong> CAP theorem provides a shared vocabulary for discussing distributed system design challenges, facilitating clearer communication between developers, architects, and stakeholders.</li><li><strong>Drives Innovation:</strong> By highlighting the limitations of traditional approaches, CAP theorem encourages the development of innovative solutions and the exploration of new technologies that offer better trade-offs between consistency, availability, and partition tolerance.</li></ul><p><strong>Illustrating the Trade-offs: A Practical Example</strong></p><p>Imagine a simple system with two nodes, Node1 and Node2, where you can read from Node1 and write to Node2. In an ideal world, both nodes are synced in real-time, offering both availability and consistency. But what happens when a network partition occurs?</p><p>If you continue to allow writes to Node2 while it’s disconnected from Node1, you sacrifice consistency. Node1 will serve stale data while Node2 holds the updated information. This highlights the core of the CAP theorem: in the face of network partitions, you must choose between consistency and availability.</p><p><strong>Exploring the Options: CP, AP, and the Elusive CA</strong></p><p>Let’s delve deeper into the possible combinations:</p><ul><li><strong>CP (Consistency and Partition Tolerance):</strong> Systems prioritizing consistency, like some configurations of DynamoDB, may offer strong consistency where reads always reflect the latest writes. However, this often means sacrificing availability. If a partition occurs, the system might refuse to serve requests until the connection is restored, ensuring data consistency but potentially causing downtime.</li><li><strong>AP (Availability and Partition Tolerance):</strong> Social media platforms often prioritize availability. They opt for eventual consistency, where data might be temporarily stale during a partition but will eventually become consistent once the connection is restored. This ensures continuous service but at the cost of temporary inconsistencies.</li><li><strong>CA (Consistency and Availability):</strong> While theoretically possible in a system without network partitions, this is a rare scenario in real-world distributed systems. Traditional relational databases (RDBMS) often operate under this assumption in a single-node setup. However, in a distributed environment, they usually employ mechanisms to handle partitions, often leaning towards a CP approach by sacrificing availability of partitioned nodes to maintain consistency.</li></ul><p><strong>Disadvantages of the CAP Theorem</strong></p><p>While insightful, the CAP theorem has limitations:</p><ul><li><strong>Oversimplification:</strong> It reduces complex distributed system behavior to three properties, potentially overlooking other crucial factors like latency and network performance.</li><li><strong>Focus on Network Partitions:</strong> It primarily addresses network failures, neglecting other potential failures within the system.</li><li><strong>Binary Choice:</strong> It seemingly presents a rigid either/or choice, while modern systems often employ more nuanced approaches with varying degrees of consistency and availability.</li></ul><p><strong>Beyond the Basics: Real-World Strategies</strong></p><p>In practice, handling network partitions often involves sophisticated strategies like:</p><ul><li><strong>Timestamps:</strong> Assigning timestamps to write operations allows systems to reconcile conflicting updates and propagate changes effectively once the connection is restored.</li><li><strong>Conflict-free replicated data types (CRDTs):</strong> These data structures allow concurrent operations without the need for coordination, enabling eventual consistency without conflicts.</li><li><strong>Quorum-based approaches:</strong> These techniques ensure that a majority of nodes agree on a value before it’s considered committed, increasing the likelihood of consistency.</li></ul><p><strong>CAP Theorem in Modern Context: Still Relevant?</strong></p><p>While the CAP theorem might not be the sole guiding principle in designing distributed systems today, it remains a valuable tool for understanding fundamental trade-offs. Modern systems often employ sophisticated techniques to mitigate the limitations imposed by CAP, but the core principle of balancing consistency, availability, and partition tolerance continues to be relevant.</p><p>By carefully considering the specific needs of your application and understanding the implications of the CAP theorem, you can make informed decisions about which aspects to prioritize, ensuring a robust and efficient distributed system.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=992ea8511b1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Distributed Systems: A Deep Dive into the Modern Architectural Paradigm]]></title>
            <link>https://medium.com/@tanmaygandhi2/distributed-systems-a-deep-dive-into-the-modern-architectural-paradigm-023eb0c572aa?source=rss-5fb0befe22fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/023eb0c572aa</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[system-architecture]]></category>
            <category><![CDATA[learning-and-development]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[modern-systems]]></category>
            <dc:creator><![CDATA[Tanmay Gandhi]]></dc:creator>
            <pubDate>Mon, 06 Jan 2025 03:31:38 GMT</pubDate>
            <atom:updated>2025-01-06T03:31:38.114Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s digital age, where applications are expected to handle massive amounts of data and users, traditional monolithic architectures are no longer sufficient. Distributed systems have emerged as a powerful paradigm to address these challenges, offering scalability, reliability, and performance.</p><h3>What are Distributed Systems?</h3><p>A distributed system is a system composed of multiple independent computers, or nodes, that communicate and coordinate with each other to achieve a common goal. These nodes can be located in different physical locations, connected through a network. Unlike monolithic systems, where all components reside on a single machine, distributed systems distribute the workload across multiple machines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d2J7cgeHFAHhNyIgqLotRg.jpeg" /><figcaption>Distributed Systems</figcaption></figure><h3>Why Use Distributed Systems?</h3><p>Distributed systems offer numerous advantages over traditional monolithic architectures:</p><p><strong>1. Scalability:</strong></p><ul><li><strong>Horizontal Scaling:</strong> Easily add more nodes to handle increased load, improving performance and capacity.</li><li><strong>Vertical Scaling:</strong> Upgrade individual nodes with more powerful hardware to handle heavier workloads.</li></ul><p><strong>2. Reliability:</strong></p><ul><li><strong>Fault Tolerance:</strong> If one node fails, the system can continue to operate, minimizing downtime.</li><li><strong>Redundancy:</strong> Data can be replicated across multiple nodes, ensuring data availability even in the event of hardware failures.</li></ul><p><strong>3. Performance:</strong></p><ul><li><strong>Parallel Processing:</strong> Distribute tasks across multiple nodes, significantly reducing processing time.</li><li><strong>Reduced Latency:</strong> Users can be served from the nearest node, minimizing response times.</li></ul><p><strong>4. Flexibility:</strong></p><ul><li><strong>Modular Design:</strong> Components can be independently developed, tested, and deployed.</li><li><strong>Agile Development:</strong> Rapidly adapt to changing requirements by deploying new features to specific nodes.</li></ul><p><strong>5. Cost-Effectiveness:</strong></p><ul><li><strong>Leverage Commodity Hardware:</strong> Utilize less expensive hardware by distributing the workload across multiple machines.</li><li><strong>Optimize Resource Utilization:</strong> Efficiently allocate resources based on real-time demand.</li></ul><h3>Key Concepts in Distributed Systems</h3><ul><li><strong>Node:</strong> A single computer or virtual machine that participates in the distributed system.</li><li><strong>Process:</strong> A running program on a node.</li><li><strong>Client-Server Model:</strong> A common architecture where clients request services from servers.</li><li><strong>Peer-to-Peer (P2P) Model:</strong> A decentralized architecture where nodes can act as both clients and servers.</li><li><strong>Distributed Shared Memory (DSM):</strong> A technique that allows multiple processes to access a shared memory space.</li><li><strong>Message Passing:</strong> A communication mechanism where processes exchange messages.</li><li><strong>Remote Procedure Call (RPC):</strong> A programming paradigm that allows a process to call a function on a remote node.</li></ul><h3>Challenges in Distributed Systems</h3><p>While distributed systems offer many benefits, they also present several challenges:</p><ul><li><strong>Complexity:</strong> Designing, implementing, and managing distributed systems is complex due to the inherent complexity of distributed computing.</li><li><strong>Network Latency:</strong> Network delays can impact performance and introduce challenges in synchronization.</li><li><strong>Data Consistency:</strong> Ensuring data consistency across multiple nodes can be difficult, especially in the presence of network partitions.</li><li><strong>Security:</strong> Protecting distributed systems from security threats, such as hacking and data breaches, requires careful consideration.</li><li><strong>Debugging and Monitoring:</strong> Identifying and troubleshooting issues in distributed systems can be challenging due to the distributed nature of the system.</li></ul><h3>Modern Architectural Patterns for Distributed Systems</h3><p>Several architectural patterns are commonly used in distributed systems:</p><ul><li><strong>Microservices Architecture:</strong> Breaking down a large application into smaller, independent services.</li><li><strong>Serverless Architecture:</strong> Offloading infrastructure management to cloud providers and focusing on writing functions.</li><li><strong>Event-Driven Architecture:</strong> Building systems that react to events, such as message queues and stream processing.</li><li><strong>Service-Oriented Architecture (SOA):</strong> Designing systems as a collection of services that communicate with each other.</li></ul><p>By understanding the fundamental concepts, challenges, and architectural patterns of distributed systems, developers can build scalable, reliable, and efficient applications that meet the demands of the modern digital landscape.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=023eb0c572aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Highly Available Systems: A System Design Perspective]]></title>
            <link>https://medium.com/@tanmaygandhi2/building-highly-available-systems-a-system-design-perspective-82b2e7558a12?source=rss-5fb0befe22fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/82b2e7558a12</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[aws-architecture]]></category>
            <category><![CDATA[high-availability]]></category>
            <category><![CDATA[system-architecture]]></category>
            <category><![CDATA[fault-tolerance]]></category>
            <dc:creator><![CDATA[Tanmay Gandhi]]></dc:creator>
            <pubDate>Sun, 05 Jan 2025 14:04:17 GMT</pubDate>
            <atom:updated>2025-01-05T14:04:17.561Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s always-on world, users expect applications to be available 24/7. Any downtime, even for a few minutes, can lead to lost revenue, frustrated customers, and damage to your brand reputation. This is where <strong>high availability</strong> comes into play.</p><p>High availability means that your system continues to operate even when some of its components fail. It’s like having backup singers ready to take over if the lead vocalist loses their voice. This is achieved by introducing <strong>redundancy</strong> into your system design. Think of it as having multiple engines on an airplane; if one fails, the others can keep the plane in the air.</p><h3>Identifying Single Points of Failure</h3><p>The first step towards building a highly available system is to identify <strong>single points of failure (SPOFs)</strong>. These are components that, if they fail, will bring down the entire system. Common SPOFs include:</p><ul><li><strong>Servers:</strong> A single server hosting your application is a prime example of an SPOF.</li><li><strong>Databases:</strong> If your database goes down, your application likely grinds to a halt.</li><li><strong>Load balancers:</strong> These distribute traffic across multiple servers, but if the load balancer itself fails, your users are left stranded.</li><li><strong>Network components:</strong> Routers, switches, and firewalls can all become SPOFs if not properly configured.</li></ul><p>Once you’ve identified your SPOFs, you can start to implement measures to make those components highly available.</p><h3>High Availability in the Cloud</h3><p>Cloud platforms like AWS offer a wealth of tools for building highly available systems. Let’s take an example:</p><p>Imagine your application is hosted on a single EC2 instance. Even with auto-scaling enabled, there will be some downtime when an instance fails and a new one spins up. To improve availability, you can:</p><ul><li><strong>Deploy to multiple regions:</strong> Run EC2 instances in different AWS regions. If one region experiences an outage, the other can take over.</li><li><strong>Use a load balancer:</strong> Distribute traffic across your instances to prevent overload and ensure that requests are routed to healthy instances.</li><li><strong>Leverage managed services:</strong> Services like AWS Lambda are inherently highly available, as they are deployed across multiple Availability Zones by default.</li></ul><h3>Fault Tolerance: The Next Level</h3><p>While high availability aims to minimize downtime, <strong>fault tolerance</strong> goes a step further. A fault-tolerant system can continue operating <strong>without any interruption</strong> even in the face of failures.</p><p>Let’s revisit our EC2 example. If you have two instances, each handling 50 transactions per second (TPS), and your peak load is 100 TPS, losing one instance will lead to performance degradation while a new one spins up.</p><p>To achieve fault tolerance, you could:</p><ul><li><strong>Increase capacity:</strong> Deploy three instances, each capable of handling at least 50 TPS. Even if one fails, the other two can handle the full load.</li><li><strong>Deploy across Availability Zones:</strong> Place two instances in each region. This way, even if an entire Availability Zone goes down, your application remains operational.</li></ul><p>Fault tolerance provides an even higher level of assurance than high availability, but it comes at a higher cost.</p><h3>High Availability vs. Fault Tolerance</h3><p>Here’s a table summarizing the key differences:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l7jXjO7RLamwezsD2PsfRw.png" /></figure><p>Choosing between high availability and fault tolerance depends on your specific needs and budget. For most applications, high availability is sufficient. However, for mission-critical systems where even a few seconds of downtime is unacceptable, fault tolerance is the way to go.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82b2e7558a12" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>