<?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 Manikandan Gobalakrishnan on Medium]]></title>
        <description><![CDATA[Stories by Manikandan Gobalakrishnan on Medium]]></description>
        <link>https://medium.com/@manigkrish?source=rss-2c8d9c074bd2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-LzqEEV_lKVVHq4QyAoIlQ.jpeg</url>
            <title>Stories by Manikandan Gobalakrishnan on Medium</title>
            <link>https://medium.com/@manigkrish?source=rss-2c8d9c074bd2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 07:26:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@manigkrish/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[Building the System Backbone for AgentTrust Gateway: Multi-Module Build, Shared Web Standards…]]></title>
            <link>https://manigkrish.medium.com/building-the-backbone-of-agenttrust-gateway-a-real-runnable-platform-starting-point-d0101ddbd67c?source=rss-2c8d9c074bd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0101ddbd67c</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[agentic-rag]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Manikandan Gobalakrishnan]]></dc:creator>
            <pubDate>Sat, 17 Jan 2026 00:05:42 GMT</pubDate>
            <atom:updated>2026-01-17T00:10:31.273Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building the System Backbone for AgentTrust Gateway: Multi-Module Build, Shared Web Standards, Runnable Services, Local Infra, and Automated Tests</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2v3cQ1slD_Plb2dSNEe7aw.png" /></figure><p><strong>AgentTrust Gateway (Agentic Commerce Trust + Scoped Tokens + Policy-RAG + Guardrailed Ops Agent) (with optional TAP verifier)</strong> is a production-oriented backend platform I’m building to help merchants and platforms handle a growing real-world problem: <strong>trustworthy agent-driven commerce</strong>.</p><p>As AI “shopping agents” begin to browse and buy on behalf of users, merchants need a dependable way to answer a few hard questions:</p><ul><li>Is this request coming from a legitimate, authorized agent — or malicious automation?</li><li>Can the agent act only within least-privilege limits?</li><li>If something goes wrong later, can we explain and audit what happened?</li></ul><p>This project’s end goal is to return clear outcomes like <strong>ALLOW / CHALLENGE / DENY</strong> for agent-initiated actions, backed by strong security checks, strict permissions, and auditability.</p><p>But before you can build advanced features, you need something more basic and more important: a system that is <strong>consistent, testable, runnable, and operationally clean from day one</strong>.</p><p>That’s exactly what I focused on in this phase of the project.</p><h3>What I built in this phase</h3><h3>1) A clean multi-module build that scales as the system grows</h3><p>I set up a <strong>Maven multi-module structure</strong> with a top-level parent build so every service and shared library follows the same standards and dependency rules.</p><p>This sounds small, but it’s a big production signal: it prevents “service sprawl” and keeps the repo coherent as more microservices are added.</p><h3>2) A shared “platform-web” library for consistent API behavior</h3><p>I created a shared library (libs/platform-web) that centralizes web standards that should be identical across services:</p><ul><li><strong>RFC 9457 Problem Details</strong> as the standard error response format (application/problem+json)</li><li><strong>W3C Trace Context</strong> support (traceparent, tracestate) so requests can be traced across services</li><li>A consistent <strong>correlation ID</strong> mechanism (X-Correlation-Id) for debugging and support workflows</li></ul><p>The key point is consistency: instead of every service reinventing error formats and tracing behavior, the platform provides it once and reuses it everywhere.</p><h3>3) Two runnable Spring Boot services with production-style conventions</h3><p>I brought up two services using Java 21 and Spring Boot 3.5.9:</p><ul><li><strong>gateway-service</strong> on port <strong>8080</strong></li><li><strong>admin-service</strong> on port <strong>8081</strong></li></ul><p>Both services expose:</p><ul><li>/healthz (liveness)</li><li>/readyz (readiness)</li></ul><p>Even at this early stage, these endpoints matter. They’re the starting point for real deployment health checks and operational maturity later.</p><h3>4) A local infrastructure stack that matches the real architecture</h3><p>I set up a local environment using Docker Compose with the same kinds of dependencies the full system will rely on:</p><ul><li>Postgres + pgvector</li><li>Redis</li><li>Kafka (single-node dev configuration)</li><li>MinIO (S3-compatible storage locally)</li></ul><p>This is not about “just making it run.” It’s about creating a development setup that is close to production assumptions, so future features can be added without constantly reworking the environment.</p><h3>5) Real automated tests that validate behavior</h3><p>I added automated smoke tests that validate the platform wiring and the contract behavior:</p><ul><li>Health endpoints return the expected JSON shape</li><li>Correlation headers exist and behave correctly</li><li>Error responses follow <strong>Problem Details</strong> format and match required invariants between headers and body fields</li></ul><p>This is important because it prevents regressions as the system grows. The tests prove that the shared platform behaviors are actually in effect — not just documented.</p><h3>6) Operator-friendly workflows and onboarding docs</h3><p>To make the repo easy to run and easy to review, I added:</p><ul><li>A simple Makefile workflow to run infra, services, and tests consistently</li><li>Local infra documentation (how to start/stop, ports, troubleshooting)</li><li>A verification checklist describing what “done” means for this milestone</li></ul><p>This reduces friction for future me and also makes the repo easier for someone else (including a hiring manager) to clone and validate quickly.</p><h3>Why this work matters</h3><p>The most common failure mode for portfolio systems is that they look impressive on paper but fall apart in execution: inconsistent service patterns, ad-hoc errors, missing tracing, unclear run steps, and no reliable tests.</p><p>This phase was about avoiding that trap.</p><p>Now, the project has a <strong>real spine</strong>:</p><ul><li>consistent API error behavior</li><li>trace + correlation foundations</li><li>runnable services with health endpoints</li><li>local dependencies that match the architecture</li><li>tests that validate the system actually behaves the way it claims</li></ul><p>With this backbone in place, the next layers cryptographic attestation verification, nonce replay protection, scoped token enforcement, policy-based explainability, and constrained ops automation — can be built on top without turning the system into a fragile demo.</p><h3>If you made it till here, thank you ❤️</h3><p>I’m sharing more such learnings from real backend on my journey.</p><blockquote><em>Connect with me through </em><a href="https://linktr.ee/manikandangkrish"><em>linktr.ee</em></a><em> to know more!</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0101ddbd67c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building AgentTrust Gateway: A Production-Grade Trust Layer for AI Shopping Agents]]></title>
            <link>https://manigkrish.medium.com/building-agenttrust-gateway-a-production-grade-trust-layer-for-ai-shopping-agents-sprint-0-90747265e323?source=rss-2c8d9c074bd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/90747265e323</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Manikandan Gobalakrishnan]]></dc:creator>
            <pubDate>Tue, 13 Jan 2026 20:12:39 GMT</pubDate>
            <atom:updated>2026-01-17T00:07:33.051Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*75xO2_uJiQz3iEXp2Rf-Ew.png" /><figcaption>AgentTrust Gateway</figcaption></figure><p>AI shopping agents are getting better at browsing, selecting, and buying products on behalf of users. That’s useful — but it also creates a real problem for merchants and platforms:</p><p>How do you know an incoming “agent request” is legitimate? How do you keep it limited to what it’s allowed to do? And how do you explain decisions later when something goes wrong?</p><p>That is the problem I’m solving with:</p><p><strong>AgentTrust Gateway (Agentic Commerce Trust + Scoped Tokens + Policy-RAG + Guardrailed Ops Agent) (with optional TAP verifier).</strong></p><p>This post explains what the project is, what it solves, and what I delivered in Sprint 0.</p><p><strong>What is the project?</strong></p><p>AgentTrust Gateway is a merchant control plane + gateway that returns a clear outcome for agent-initiated commerce actions:</p><ul><li>ALLOW</li><li>CHALLENGE</li><li>DENY</li></ul><p>The goal is to make these decisions secure, auditable, and explainable, without turning the system into a “demo chatbot.” The system is designed as a production-grade microservices platform, with strong security primitives and operational discipline from day one.</p><p><strong>The trust problem I’m solving</strong></p><p>When an AI agent tries to act like a buyer, especially for actions like “purchase,” a merchant needs answers to three questions:</p><p>1. Is this request really from a trusted agent?<br> Not a bot pretending to be one.</p><p>2. Is the agent authorized to do exactly this action?<br> For example: this merchant, this action, this amount, this time window, nothing more.</p><p>3. If I deny or challenge the request, can I explain why later?<br> For disputes, support cases, governance, and audits.</p><p>This project is built to make those answers measurable and repeatable.</p><p><strong>The architecture at a glance</strong></p><p>At the edge, an agent or merchant admin client hits a public endpoint. The gateway routes requests and enforces security controls and tenancy context. Behind it, private services handle attestation verification, token enforcement, decisioning, policy versioning, RAG explanations, and an ops agent capability with strict guardrails.</p><p>Key components in the design include:</p><ol><li>Gateway Service: authn/authz, rate limits, routing, tenant context</li><li>Admin Service / Control Plane API: internal auth, RBAC, onboarding</li><li>Attestation Service: verifies RFC 9421 HTTP Message Signatures and replay defenses</li><li>Agent Registry Service: keys, rotation, status</li><li>Token Service: scoped tokens + lifecycle</li><li>Decision Service: deterministic ALLOW/CHALLENGE/DENY</li><li>Policy Service: policy versioning and publishing</li><li>RAG Service: retrieval + explanation with citations (non-authoritative)</li><li>Ops Agent Service: allowlisted tools + JSON schema + idempotency</li><li>Python Ingestion Worker: chunk + embed + upsert for policy retrieval</li><li>Data and infra: PostgreSQL + pgvector, Redis, Kafka (MSK Serverless), S3, and OpenAI API</li></ol><p><strong>Sprint 0: what I actually delivered (and why it matters)</strong></p><p>Sprint 0 was intentionally docs + repo hygiene only. There is no service code yet, by design. The purpose was to prevent drift, enforce standards early, and make the repo safe and credible as a public, production-oriented project.</p><p>Here’s what I completed.</p><p><strong>1) Public repo guardrails</strong></p><p>Because the repository is public, Sprint 0 includes guardrails that reduce the risk of accidental credential leaks and weak CI practices.</p><p>What I put in place:</p><p>A documented public-repo guardrail policy (no secrets committed, strict posture). <br>A clear CI → AWS OIDC posture: workflows should use short-lived credentials at runtime (no long-lived AWS keys stored in GitHub). <br>Local and CI secret scanning controls (pre-commit + CI scanning) to catch issues early.</p><p>This is small, but it signals something important: I’m treating this like a real system from day one.</p><p><strong>2) Standards anchored to real specs (to prevent drift)</strong></p><p>In Sprint 0, I locked in core contracts so future services follow the same rules:</p><p>API error format based on RFC 9457 Problem Details. <br>Trace propagation based on W3C Trace Context (`traceparent`, `tracestate`) and correlation ID rules. <br>Event envelope standardized using CloudEvents 1.0, including a versioning rule and naming conventions.</p><p>These decisions reduce “reinventing conventions” later and make cross-service observability and debugging much easier.</p><p><strong>3) ADRs: the “constitution” of the system</strong></p><p>Sprint 0 includes a set of Architecture Decision Records that make key decisions explicit and hard to accidentally change later, including:</p><p>Stack and hosting baseline (AWS, region, ECS/ALB direction)<br>Blue/green deployment approach (ECS + CodeDeploy)<br>Eventing backbone (Kafka / MSK Serverless)<br>Vector storage approach (Postgres + pgvector)<br>RFC 9421 + TAP-compatible attestation profile<br>MVP auth model (internal JWT now, seam for future IdP)<br>Multi-tenancy model (tenant derived from verified identity, never request body)<br>Event envelope choice (CloudEvents)<br>Observability standard (trace context + structured logs)<br>LLM provider data policy (OpenAI usage with strict redaction and non-authoritative boundaries)</p><p>In other words: Sprint 0 established the rules so Sprint 1+ can focus on implementation without constantly re-debating fundamentals.</p><p><strong>4) Threat model v0 (including LLM and tool abuse risks)</strong></p><p>Because this project includes both RAG and a tool-calling ops agent, Sprint 0 includes a threat model that explicitly calls out two common failure modes:</p><p>Prompt injection / data exfiltration via RAG<br> Mitigations include redaction before any LLM call, retrieval filtering by tenant and published policy version, and “cite-or-refuse” behavior.</p><p>Ops agent tool abuse<br> Mitigations include allowlist-only tools, JSON schema validation for tool arguments, RBAC gates, idempotency, and full audit logging.</p><p>This is important because these are areas where systems often become unsafe “by accident.”</p><p><strong>5) Cost controls and environment strategy (budget-aware, interview-friendly)</strong></p><p>Sprint 0 also defines how the system will run across environments without surprise bills, including:</p><p>A four-environment model: local, staging, prod-lite, prod-managed<br>Explicit cost knobs (OpenAI budgets, Kafka topic/partition limits, Redis TTLs, log retention, storage lifecycle policies, etc.)</p><p>This matters for two reasons:</p><p>1. It keeps the project realistic for a solo developer budget.<br>2. It shows production thinking — cost is part of engineering.</p><p><strong>6) OpenAPI contracts and documentation scaffolding</strong></p><p>Sprint 0 includes OpenAPI files that act as early contract anchors for key surfaces:</p><p>Gateway endpoint surface (agent evaluate flow)<br>Admin/control plane surface (tenant onboarding)<br>Internal decision API surface</p><p>It also includes docs structure for runbooks and testing strategy, so implementation can plug into an established, consistent doc framework.</p><p>What Sprint 0 means for the next phase</p><p>Sprint 0 gave the project a solid, production-oriented foundation:</p><p>Security hygiene suitable for a public repo<br>Clear standards and contracts<br>Concrete architecture decisions captured and justified<br>Threat modeling that covers LLM and tool risks early<br>Cost and environment strategy designed to match reality</p><p>Now Sprint 1 can focus on turning this into runnable services — without losing coherence.</p><p><strong>Closing</strong></p><p>Sprint 0 was not about writing code. It was about making sure the project starts with discipline: standards, security posture, and a clear architecture that can scale into a real system.</p><p>If you’re building a serious portfolio project, this is the kind of work that prevents chaos later.</p><h3>If you made it till here, thank you ❤️</h3><p>I’m sharing more such learnings from real backend on my journey.</p><blockquote><em>Connect with me through </em><a href="https://linktr.ee/manikandangkrish"><em>linktr.ee</em></a><em> to know more!</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90747265e323" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Architecture]]></title>
            <link>https://manigkrish.medium.com/aws-architecture-1fa347243cf2?source=rss-2c8d9c074bd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fa347243cf2</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Manikandan Gobalakrishnan]]></dc:creator>
            <pubDate>Fri, 12 Dec 2025 23:02:39 GMT</pubDate>
            <atom:updated>2025-12-12T23:02:39.829Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*ekypei-LRGFFPiAh.jpeg" /></figure><p>If you look at AWS today, it’s easy to think it was designed by a group of geniuses sitting around a whiteboard saying:<br>“Let’s build the greatest cloud platform in history.”</p><p>Reality was nothing like that.</p><p>AWS wasn’t born from ambition<br>AWS was born from <strong>struggle</strong>.</p><p>Amazon (the e-commerce business) kept growing faster than the engineering teams could keep up. Every time developers wanted to launch a new product, they spent <strong>months</strong> building the same boring foundation:</p><ul><li>Buying servers</li><li>Setting up databases</li><li>Configuring networking</li><li>Handling storage</li><li>Managing security</li><li>Monitoring everything</li></ul><p>It didn’t matter whether the project was small or huge these same headaches kept happening.</p><p>The turning point came when someone finally said:</p><blockquote><em>“We are wasting our time building infrastructure again and again.<br>What if we build the foundation ONCE… and let everyone reuse it?”</em></blockquote><p>That idea was the seed of AWS not cloud computing as we know it, but <strong>the dream of reusable building blocks</strong>.</p><p>Nobody in the room realized they had just changed the history of technology.</p><h3>Chapter 1</h3><blockquote><em>Before AWS Could Sell Anything, It Had to Build the World</em></blockquote><p>You can’t build a cloud service without… a cloud to run it on.</p><p>So the first step wasn’t software.<br>It was <strong>real buildings</strong> data centers.</p><p>But Amazon did it differently.</p><p>Instead of one giant data center, they built <strong>Regions</strong> in different parts of the world each Region holding <strong>multiple Availability Zones (AZs independent data centers near each other but separated for safety)</strong>.</p><p>Each Availability Zone was connected by <strong>private high-speed fiber</strong> so systems could synchronize fast.</p><p>Why multiple AZs in each region?<br>Because Amazon learned from painful experience:</p><blockquote><em>“One building must never control the fate of the system.”</em></blockquote><p>If lightning hits one datacenter the others take over.<br>If one has a fire the others stay healthy.<br>If one disconnects nothing stops.</p><p>This design became <strong>the heart of reliability</strong> in AWS.</p><p>And then, they added something else:</p><p><strong>Edge Locations (small servers around the world so CloudFront can deliver content faster to nearby users).</strong></p><p>At this stage AWS had not yet <em>become</em> the cloud…<br>but it had <strong>prepared the Earth for it</strong>.</p><h3>Chapter 2</h3><blockquote><em>The Cloud Needed Streets and Neighborhoods: Networking</em></blockquote><p>Once the physical world was ready, AWS needed a way for customers to build digital worlds.</p><p>That’s when AWS introduced <strong>VPC (Virtual Private Cloud a private, isolated network for each customer)</strong>.</p><p>This changed everything.</p><p>Instead of giving people random servers on the internet, AWS said:</p><blockquote><em>“Here take your own digital city. You decide the streets. You decide the gates. You decide who enters and who doesn’t.”</em></blockquote><p>Inside the VPC, customers could build:</p><ul><li><strong>Public Subnets (areas that can talk to the internet)</strong></li><li><strong>Private Subnets (areas absolutely hidden from the internet)</strong></li></ul><p>To manage traffic inside that world, AWS added:</p><ul><li><strong>Internet Gateway (door between VPC and internet)</strong></li><li><strong>NAT Gateway (lets private servers access the internet without exposing them)</strong></li><li><strong>Route Tables (navigation maps that tell data where to go)</strong></li><li><strong>Security Groups (firewalls for services allow only approved traffic)</strong></li></ul><p>AWS had now given the world something no one else had ever offered:</p><blockquote><strong><em>Private, secure, customizable networking on demand.</em></strong></blockquote><p>This wasn’t just hosting anymore.<br>This was <strong>architecture</strong>.</p><h3>Chapter 3</h3><blockquote><em>Giving the Cloud a Mind: Compute</em></blockquote><p>Networking without computing means nothing.<br>So the next step was to give the cloud <strong>a brain</strong> a way to run applications.</p><p>The first big milestone was <strong>EC2 (virtual servers customers could launch whenever they needed)</strong>.</p><p>This was revolutionary.</p><p>Before EC2:</p><ul><li>Companies waited days, weeks, or months for servers.</li></ul><p>With EC2:</p><ul><li>You clicked a button and you had a server in minutes.</li></ul><p>Then AWS solved another big pain: <strong>load</strong>.</p><p>Some days customers have 10 users.<br>Some days they have 10 million.</p><p>So AWS created:</p><ul><li><strong>Auto Scaling (automatically add or remove servers based on traffic)</strong></li><li><strong>Application Load Balancer (smart router that sends users only to healthy servers)</strong></li></ul><p>This turned the cloud into something <strong>elastic</strong> growing and shrinking automatically.</p><p>Then came containers and serverless:</p><p>EvolutionWhat it solvedECSrun containers without manually configuring serversEKSsupport Kubernetes, a global industry standard Lambdarun code only when needed no servers at all</p><p>At this point, AWS compute could handle anything from:</p><ul><li>A tiny hobby app to A global system with millions of users per minute</li></ul><p>The cloud had evolved from a place to host programs into a <strong>thinking, adapting runtime environment</strong>.</p><h3>Chapter 4</h3><blockquote><em>Teaching the Cloud to Remember: Storage &amp; Databases</em></blockquote><p>Once apps were running on AWS, they needed a place to keep information <strong>and not lose it.</strong></p><p>This stage is where AWS became not just useful… but <strong>trusted</strong>.</p><p>First came <strong>S3 (infinite storage for files, backups, logs, images, documents)</strong>.<br>It stored data across multiple Availability Zones automatically.</p><p>Then AWS built <strong>EBS (hard-drive style storage attached to EC2)</strong><br>and <strong>Glacier (cheap long-term storage for archives)</strong>.</p><p>Then databases arrived and this was huge.</p><p>AWS released:</p><ul><li><strong>RDS (managed relational databases no setup pain)</strong></li><li><strong>Aurora (high-performance relational DB that heals and fails over automatically)</strong></li><li><strong>DynamoDB (NoSQL database with extreme performance and auto scaling)</strong></li><li><strong>ElastiCache Redis (super-fast memory store that returns frequent data instantly)</strong></li></ul><p>With these, AWS became capable of storing <strong>the world’s information </strong>safely.</p><p>Now AWS could run:</p><ul><li>banking systems</li><li>social networks</li><li>ecommerce stores</li><li>enterprise ERPs</li><li>and anything else that needed storage</li></ul><p>The cloud now had <strong>memory </strong>and a very reliable one.</p><h3>Chapter 5</h3><blockquote><em>The Cloud Learns to Communicate: Messaging</em></blockquote><p>As applications got more complex, AWS saw a new challenge:</p><p>Big systems aren’t one program.<br>They’re <strong>many programs talking to each other</strong>.</p><p>So AWS created:</p><ul><li><strong>SQS (message queue that stores tasks to process safely one-by-one)</strong></li><li><strong>SNS (notification system that sends messages to many receivers)</strong></li><li><strong>EventBridge (event bus that connects services based on events instead of direct calls)</strong></li><li><strong>Kinesis (streaming tech for real-time analytics and data pipelines)</strong></li></ul><p>This is what turned AWS into a platform for <strong>distributed systems</strong>.</p><p>Services no longer depended on each other.<br>If one service slowed down, others didn’t collapse.</p><p>The cloud became <strong>cooperative instead of fragile.</strong></p><h3>Chapter 6</h3><blockquote><em>Trust: The Soul of AWS</em></blockquote><p>AWS understood something early:</p><blockquote><em>A cloud that isn’t secure is worthless.</em></blockquote><p>So they put <strong>security in every layer</strong>, not just at the end.</p><p>Core pillars:</p><ul><li><strong>IAM (identity + permissions who is allowed to do what)</strong></li><li><strong>KMS (encrypt data so even if stolen, nobody can read it)</strong></li><li><strong>Secrets Manager (store credentials safely instead of exposing them in code)</strong></li><li><strong>Security Groups (internal firewalls around each resource)</strong></li><li><strong>WAF (blocks hackers and bad bots)</strong></li><li><strong>Shield (protects against massive DDoS attacks)</strong></li></ul><p>These didn’t just protect AWS.<br>They protected businesses, users, and trust.</p><p>The world noticed.</p><p>Banks adopted AWS.<br>Hospitals adopted AWS.<br>Governments adopted AWS.</p><p>Security was not a feature<br><strong>it was the foundation for global trust.</strong></p><h3>Chapter 7</h3><blockquote><em>Giving the Cloud Self-Awareness: Monitoring &amp; DevOps</em></blockquote><p>Once systems went online, AWS realized another challenge:</p><p>People didn’t just need infrastructure.<br>They needed <strong>control</strong>.</p><p>So AWS introduced:</p><ul><li><strong>CloudWatch (observability CPU, memory, logs, performance, alarms)</strong></li><li><strong>X-Ray (trace requests and find bottlenecks across microservices)</strong></li><li><strong>CloudTrail (audit logs who did what and when)</strong></li><li><strong>CodePipeline (build → test → deploy automatically)</strong></li><li><strong>CodeBuild &amp; CodeDeploy (automated deployment to reduce human error)</strong></li></ul><p>For the first time ever,<br>system owners didn’t have to guess what was happening.</p><p>They could <strong>see</strong>, <strong>measure</strong>, <strong>predict</strong>, and <strong>fix</strong> issues before users complained.</p><p>AWS had now become:</p><ul><li>smart</li><li>aware</li><li>controlled</li></ul><p>Not just “cloud hosting”<br>but <strong>cloud engineering</strong>.</p><h3>The Final Picture Everything Together</h3><p>All layers of AWS architecture</p><pre>PHYSICAL LAYER<br>  Regions → Availability Zones → Edge Locations<br>NETWORK LAYER<br>  VPC → Subnets → Internet/NAT Gateway → Security Groups → Route Tables<br>COMPUTE LAYER<br>  EC2 / ECS / EKS / Lambda + Load Balancer + Auto Scaling<br>STORAGE LAYER<br>  S3 / EBS / Glacier<br>DATABASE LAYER<br>  RDS → Aurora → DynamoDB → ElastiCache<br>MESSAGING LAYER<br>  SQS → SNS → EventBridge → Kinesis<br>SECURITY LAYER<br>  IAM • KMS • Secrets Manager • WAF • Shield<br>MONITORING &amp; DEVOPS LAYER<br>  CloudWatch • X-Ray • CloudTrail • CodePipeline</pre><p>Each layer supports the next.<br>No one layer does everything alone.</p><p>AWS wasn’t invented as <strong>one giant system</strong>.<br>It was built as <strong>a stack of solutions for real problems</strong>.</p><p>And that’s why it works.</p><h3>The Real Secret of AWS</h3><p>If you understand one thing about AWS architecture, let it be this:</p><blockquote><em>AWS didn’t start by trying to build the cloud.<br>AWS started by trying to remove pain.</em></blockquote><p>Every service exists because someone struggled with something:</p><ul><li>Too slow → Regions + CloudFront</li><li>Too fragile → Multi-AZ design</li><li>Hard to network → VPC</li><li>Hard to scale → Auto Scaling</li><li>Hard to manage → ECS, EKS, Lambda</li><li>Losing data → S3, Aurora, DynamoDB</li><li>Services crashing each other → SQS, SNS, EventBridge</li><li>Security mistakes → IAM, KMS, Secrets</li><li>No visibility → CloudWatch, X-Ray</li><li>Deployment stress → CodePipeline</li></ul><p>AWS solved human frustration<br>and that’s why AWS won.</p><p>AWS architecture is not just a technology diagram.<br>It’s <strong>a story of evolution</strong>.</p><p>It grew because people needed it.<br>It improved because people depended on it.<br>It became powerful because people trusted it.</p><p>And today, AWS is what it is because of one idea:</p><blockquote><em>Build the foundation once.<br>Let the world build on top of it.</em></blockquote><blockquote><em>Connect with me through </em><a href="https://linktr.ee/manikandangkrish"><em>linktr.ee</em></a><em> to know more!</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fa347243cf2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Fixed a Tricky torch.compile Logging Issue in PyTorch]]></title>
            <link>https://manigkrish.medium.com/how-i-fixed-a-tricky-torch-compile-logging-issue-in-pytorch-fc8b99ce3f83?source=rss-2c8d9c074bd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc8b99ce3f83</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[ml-framework]]></category>
            <dc:creator><![CDATA[Manikandan Gobalakrishnan]]></dc:creator>
            <pubDate>Thu, 04 Dec 2025 18:02:01 GMT</pubDate>
            <atom:updated>2025-12-08T18:44:18.177Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sXIbu4_vGn0z2fhmElrFgw.png" /></figure><p>Recently, I worked on and fixed a PyTorch Dynamo issue around torch.compile and logging.</p><p>On the surface, it sounded simple:</p><blockquote><em>“Expand </em><em>ignore_logger_methods so it can ignore arbitrary functions.”</em></blockquote><p>In reality, it touched:</p><ul><li>Dynamo internals (VariableTrackers, guards, builder logic)</li><li>Configuration (torch._dynamo.config) and backward compatibility</li><li>Tests and documentation</li><li>CI, linting, and the graph-break registry</li></ul><p>In this post, I’ll walk through:</p><ol><li>What the original issue was</li><li>How I designed and implemented the fix</li><li>What I learned about PyTorch internals and contributing at this scale</li><li>How PyTorch and its users benefit from this change</li></ol><h3>Background: torch.compile, logging, and graph breaks</h3><p>torch.compile uses TorchDynamo to trace Python code and build graphs that can be optimized and run efficiently.</p><p>But not all Python operations are “graph friendly.” Things like:</p><ul><li>print(...)</li><li>logging.Logger.info(...)</li><li>warnings.warn(...)</li></ul><p>are side-effectful and can cause <strong>graph breaks</strong> — places where Dynamo has to stop tracing and fall back to eager execution.</p><p>To give users some control over this, Dynamo already had two important configs:</p><ol><li>reorderable_logging_functions</li><li>ignore_logger_methods</li></ol><h3>reorderable_logging_functions</h3><p>This configuration allows certain logging-like functions to be <strong>reordered</strong> to the end of a graph region instead of causing a graph break.</p><p>Example:</p><pre>torch._dynamo.config.reorderable_logging_functions.add(print)<br><br>@torch.compile<br>def fn(x):<br>    x += 1<br>    print(&quot;log!&quot;)<br>    return torch.sin(x)<br>print(fn(torch.ones(3, 3)))</pre><p>Here, Dynamo:</p><ul><li>Traces the tensor ops into a graph</li><li>Delays the print calls to the end</li><li>Avoids a graph break</li></ul><p>But there are important <strong>restrictions</strong>:</p><ul><li>These functions must <strong>return </strong><strong>None</strong></li><li>Their arguments must be limited to <strong>tensors, constants, or format strings</strong></li></ul><p>Also, because calls are reordered, mutations between the original call and the actual execution can change what gets logged.</p><h3>ignore_logger_methods</h3><p>This config existed to completely <strong>ignore</strong> certain logging methods:</p><ul><li>They don’t run</li><li>They don’t get reordered</li><li>They don’t cause graph breaks</li></ul><p>But there was one big limitation:</p><blockquote><em>It only worked for </em><em>logging.Logger methods.</em></blockquote><p>You could ignore something like logger.info, but <strong>not</strong> arbitrary functions such as print or your own custom debug functions.</p><h3>The issue: ignore arbitrary functions, not just logger methods</h3><p>The concrete problem was:</p><blockquote><strong><em>Expand </em></strong><strong><em>ignore_logger_methods so it can handle arbitrary functions, not just </em></strong><strong><em>logging.Logger methods.</em></strong></blockquote><p>The desired behavior:</p><ul><li>Let users specify arbitrary callables to ignore, for example:</li></ul><pre>torch._dynamo.config.ignore_logging_functions.add(print)<br><br>@torch.compile(backend=&quot;eager&quot;, fullgraph=True)<br>def fn(x):<br>    print(x)<br>    x += 1<br>    return x<br><br>fn(torch.ones(3))  # no print</pre><p>These ignored functions should:</p><ul><li><strong>Not run</strong></li><li><strong>Not be reordered</strong></li><li><strong>Not cause graph breaks</strong></li></ul><p>This is different from reorderable_logging_functions. Reordering can still run the function, and can be problematic if arguments mutate. For some debug code, the safe and correct behavior is to treat it as a complete <strong>no-op</strong> inside the compiled region.</p><p>So I needed a design that:</p><ul><li>Generalizes ignoring to arbitrary functions</li><li>Keeps existing behavior working (backward compatibility)</li><li>Integrates cleanly with Dynamo’s internal model</li></ul><h3>Design: one unified config + a dedicated variable</h3><p>After exploring the code, I settled on this design:</p><ol><li>Introduce a new unified config: <strong>ignore_logging_functions</strong></li><li>Make the old ignore_logger_methods a <strong>backward-compatible alias</strong></li><li>Add a new Dynamo variable type: <strong>IgnoredFunctionVariable</strong></li><li>Update the variable builder so ignored callables are routed to this new variable</li><li>Update LoggingLoggerVariable to also use ignore_logging_functions</li><li>Add tests, docs, and registry updates to lock in the behavior</li></ol><p>Let’s go through each part.</p><h3>Step 1: Config changes — ignore_logging_functions + alias</h3><p>In torch/_dynamo/config.py, there was already:</p><ul><li>reorderable_logging_functions</li><li>ignore_logger_methods</li></ul><p>I introduced:</p><pre># A set of functions that will be ignored during Dynamo tracing.<br># These functions will NOT run, will NOT be reordered, and will NOT<br># cause graph breaks. They act as full no-ops.<br># Ignored functions can take any arguments, but MUST return None.<br># Functions should either be module-level functions, `logging.Logger.&lt;method&gt;`<br># (ignores that method for all `logging.Logger` instances) or<br># `logger_obj.&lt;method&gt;` (ignores that method only for the specific instance).<br># Other functions may or may not be ignored due to implementation details.<br># If you want to ignore a function that `ignore_logging_functions` is failing<br># to ignore, please submit an issue.<br>ignore_logging_functions: set[Callable[..., Any]] = set()</pre><p>Then I wired <strong>backward compatibility</strong> by making:</p><pre>ignore_logger_methods: set[Callable[..., Any]] = Config(<br>    alias=&quot;torch._dynamo.config.ignore_logging_functions&quot;<br>)</pre><p>So:</p><ul><li>New code can use ignore_logging_functions</li><li>Old code using ignore_logger_methods still works, but writes into the same underlying config</li></ul><p>Result: a single source of truth with a clean migration path.</p><h3>Step 2: A new IgnoredFunctionVariable</h3><p>Next, I needed Dynamo to represent “ignored function calls” in its own IR.</p><p>In torch/_dynamo/variables/misc.py, I added:</p><pre>class IgnoredFunctionVariable(VariableTracker):<br>    &quot;&quot;&quot;<br>    Represents a call to an arbitrary function that should be ignored.<br>    &quot;&quot;&quot;<br><br>    def call_function(<br>        self,<br>        tx: &quot;InstructionTranslator&quot;,<br>        args: &quot;list[VariableTracker]&quot;,<br>        kwargs: &quot;dict[str, VariableTracker]&quot;,<br>    ) -&gt; &quot;VariableTracker&quot;:<br>        # Completely skip execution and substitute None.<br>        return variables.ConstantVariable.create(None)</pre><p>Key idea:</p><ul><li>When Dynamo sees a function listed in ignore_logging_functions, it will wrap that function as an IgnoredFunctionVariable.</li><li>Calling this variable during tracing does <strong>not</strong> execute Python at all.</li><li>Instead, Dynamo just inserts ConstantVariable(None).</li></ul><p>This gives exactly the semantics we want:</p><blockquote><em>“Behave like a pure no-op that returns </em><em>None inside the compiled region.”</em></blockquote><h3>Step 3: Builder integration — routing ignored callables</h3><p>The next step was updating the builder in torch/_dynamo/variables/builder.py, which decides what kind of variable to construct for a given Python object.</p><p>There was already logic for reorderable logging:</p><pre>elif DebuggingVariable.is_reorderable_logging_function(value):<br>    # Put this above builtin_callable so that print() can be handled<br>    # along with other builtin debugging functions<br>    self.install_guards(GuardBuilder.BUILTIN_MATCH)<br>    return DebuggingVariable(value, source=self.source)</pre><p>I extended it with a branch for ignored functions:</p><pre>elif callable(value) and value in torch._dynamo.config.ignore_logging_functions:<br>    # Treat ignored functions as full no-ops<br>    self.install_guards(GuardBuilder.ID_MATCH)<br>    return IgnoredFunctionVariable(value, source=self.source)</pre><p>Notes:</p><ul><li>callable(value) ensures we’re dealing with functions/method-like objects.</li><li>GuardBuilder.ID_MATCH ensures the guard is tied to this <strong>exact</strong> function object identity, not just “any function.</li></ul><p>Now, a user can do:</p><pre>def dbg_fn(x):<br>    print(&quot;debug:&quot;, x)<br><br>torch._dynamo.config.ignore_logging_functions.add(dbg_fn)</pre><p>and any call to dbg_fn inside torch.compile will be:</p><ul><li>Ignored</li><li>Replaced with None</li><li>Executed without graph breaks</li></ul><h3>Step 4: Unifying logger behavior with the same config</h3><p>LoggingLoggerVariable represents logging.Logger methods inside Dynamo. It already had special logic, but I wanted everything to flow through the same ignore_logging_functions config.</p><p>In torch/_dynamo/variables/misc.py, I updated it roughly like this:</p><pre>class LoggingLoggerVariable(VariableTracker):<br>    &quot;&quot;&quot;<br>    Represents a call to any logging.Logger methods.<br>    &quot;&quot;&quot;<br><br>    def call_method(<br>        self,<br>        tx: &quot;InstructionTranslator&quot;,<br>        name,<br>        args: &quot;list[VariableTracker]&quot;,<br>        kwargs: &quot;dict[str, VariableTracker]&quot;,<br>    ) -&gt; &quot;VariableTracker&quot;:<br><br>        if tx.export:<br>            # For export cases, we can just make logging functions no-ops.<br>            return variables.ConstantVariable.create(None)<br><br>        method = getattr(self.value, name, None)<br>        function = getattr(method, &quot;__func__&quot;, None)<br><br>        ignore_set = torch._dynamo.config.ignore_logging_functions<br><br>        if method in ignore_set or function in ignore_set:<br>            return variables.ConstantVariable.create(None)<br><br>        unimplemented(<br>            gb_type=&quot;logging.Logger method not supported for non-export cases&quot;,<br>            context=f&quot;method: {self.value}.{name}, args: {args}, kwargs: {kwargs}&quot;,<br>            explanation=&quot;logging.Logger methods are not supported for non-export cases.&quot;,<br>            hints=[<br>                &quot;Add the logging method to `torch._dynamo.config.ignore_logging_functions`.&quot;,<br>            ],<br>        )</pre><p>So now:</p><ul><li>Arbitrary functions can be ignored via ignore_logging_functions</li><li>logging.Logger methods can also be ignored via the same config</li><li>Old ignore_logger_methods usage is transparently mapped to this</li></ul><p>I also updated the graph-break registry (torch/_dynamo/graph_break_registry.json) to mention ignore_logging_functions in the hint for unsupported logger methods.</p><h3>Step 5: Tests to lock in behavior</h3><p>To make this robust, I added several tests in test/dynamo/test_reorder_logs.py.</p><h3>a) Ignoring arbitrary functions as true no-ops</h3><pre>def test_ignore_arbitrary_function_noop(self):<br>    counters.clear()<br>    calls = []<br><br>    def dbg_fn(x):<br>        calls.append(&quot;ran&quot;)<br><br>    def f(x):<br>        dbg_fn(x)  # must be no-op inside Dynamo<br>        return x + 1<br><br>    x = torch.randn(3, 3)<br><br>    with torch._dynamo.config.patch(ignore_logging_functions={dbg_fn}):<br>        opt_f = torch.compile(backend=&quot;eager&quot;, fullgraph=True)(f)<br>        opt_out = opt_f(x)<br><br>    # function must never run<br>    self.assertEqual(calls, [])<br><br>    # output must match eager<br>    self.assertTrue(same(opt_out, x + 1))<br><br>    # no graph breaks allowed<br>    self.assertEqual(len(counters[&quot;graph_break&quot;]), 0)</pre><p>This verifies:</p><ul><li>Ignored functions do <strong>not</strong> run</li><li>Output is correct</li><li>No graph breaks occur</li></ul><h3>b) Return value becomes None under Dynamo</h3><p>Some debug functions might normally return a value. Inside Dynamo, they become None. I made that explicit in a test:</p><pre>def test_ignore_function_returns_none(self):<br>    counters.clear()<br><br>    def ignore_me(x):<br>        return &quot;should_not_run&quot;<br><br>    def f(x):<br>        y = ignore_me(x)  # Dynamo substitutes Constant(None)<br>        # Make y observable<br>        return x * 2 if y is None else x * 3<br><br>    x = torch.randn(3, 3)<br><br>    with torch._dynamo.config.patch(ignore_logging_functions={ignore_me}):<br>        opt_f = torch.compile(backend=&quot;eager&quot;, fullgraph=True)(f)<br>        opt_out = opt_f(x)<br><br>    eager_out = f(x)<br><br>    # outputs must match, and y must effectively be None in compiled mode<br>    self.assertTrue(same(opt_out, eager_out))<br>    self.assertTrue(same(opt_out, x * 2))<br><br>    # no graph breaks<br>    self.assertEqual(len(counters[&quot;graph_break&quot;]), 0)</pre><p>This confirms that:</p><ul><li>Ignored functions behave as if they return None in compiled mode</li><li>Program semantics remain consistent under fullgraph=True</li></ul><h3>c) Ignore vs reorder: no conflict</h3><p>I also checked that ignoring and reordering play nicely together:</p><pre>def test_ignore_function_does_not_conflict_with_reorderable(self):<br>    counters.clear()<br>    log = []<br><br>    def ignored(x):<br>        log.append(&quot;ignored&quot;)<br><br>    def reordered(x):<br>        log.append(&quot;reordered&quot;)<br><br>    with torch._dynamo.config.patch(ignore_logging_functions={ignored}):<br>        with torch._dynamo.config.patch(reorderable_logging_functions={reordered}):<br><br>            def f(x):<br>                ignored(x)<br>                reordered(x)<br>                return x + 1<br><br>            x = torch.ones(3, 3)<br>            opt_f = torch.compile(backend=&quot;eager&quot;, fullgraph=True)(f)<br>            opt_out = opt_f(x)<br><br>    # ignored must NOT run<br>    self.assertNotIn(&quot;ignored&quot;, log)<br><br>    # reordered MUST run<br>    self.assertIn(&quot;reordered&quot;, log)<br><br>    # output correct<br>    self.assertTrue(same(opt_out, x + 1))</pre><p>So:</p><ul><li>ignore_logging_functions truly skips execution</li><li>reorderable_logging_functions still works independently</li></ul><h3>Step 6: Documentation update</h3><p>Finally, I updated the documentation in<br> docs/source/compile/programming_model.common_graph_breaks.md under <strong>“Printing and logging”</strong>.</p><p>The key additions were:</p><ul><li>Mentioning the restrictions for reorderable_logging_functions</li><li>Introducing ignore_logging_functions and clarifying its contract</li></ul><p>The final snippet:</p><pre>## Printing and logging<br><br>Printing/logging/issuing warnings will result in a graph break.<br>You can try working around this by using `torch._dynamo.config.reorderable_logging_functions`.<br>This config is used to reorder logging functions so that they are called at the end of the<br>traced function, thus avoiding a graph break.<br>However, the logged contents may differ if, for example, a mutation occurs.<br><br>Note: `reorderable_logging_functions` has restrictions, these functions must return `None`,<br>and their arguments must be limited to tensors, constants, or format strings.<br><br>You can also use `torch._dynamo.config.ignore_logging_functions` to completely skip selected<br>logging functions during tracing.<br><br>Ignored functions can take any arguments, but MUST return `None`. Functions should either be<br>module-level functions, `logging.Logger.&lt;method&gt;` (ignores that method for all<br>`logging.Logger` instances) or `logger_obj.&lt;method&gt;` (ignores that method only for the<br>specific `logger_obj` instance). Other functions may or may not be ignored due to<br>implementation details; if you want to ignore a function that `ignore_logging_functions`<br>is failing to ignore, please submit an issue.Printing/logging/issuing warnings will result in a graph break.<br>You can try working around this by using `torch._dynamo.config.reorderable_logging_functions`.<br>This config is used to reorder logging functions so that they are called at the end of the<br>traced function, thus avoiding a graph break.<br>However, the logged contents may differ if, for example, a mutation occurs.</pre><p>I kept the original structure and just added the minimal lines needed.</p><h3>CI, lint, and registry: the “unseen” work</h3><p>After the main logic was done, there was still a lot of “plumbing” work:</p><ul><li>Fixing <strong>trailing spaces</strong>, blank lines with whitespace, and line length (&gt;120 chars)</li><li>Running lintrunner -a locally to align with the project’s formatting rules</li><li>Updating the <strong>graph-break registry</strong> (graph_break_registry.json) to keep hints in sync</li><li>Rerunning tests to make sure everything passed</li></ul><p>This is the kind of work that doesn’t look exciting in a diff, but is essential to land changes in a large project like PyTorch.</p><h3>What I learned from this issue</h3><h3>1. How Dynamo models Python semantics</h3><p>I learned how Dynamo represents Python code using:</p><ul><li>VariableTracker subclasses (like DebuggingVariable, IgnoredFunctionVariable)</li><li>Guards (BUILTIN_MATCH, ID_MATCH, TYPE_MATCH)</li><li>Builder logic that maps Python objects to IR nodes</li></ul><p>Designing IgnoredFunctionVariable to plug into this cleanly was a great deep dive into the internals.</p><h3>2. Backward compatibility is non-negotiable</h3><p>Instead of creating a new config and breaking old usage, I:</p><ul><li>Introduced ignore_logging_functions</li><li>Aliased ignore_logger_methods to it</li></ul><p>This pattern, one new canonical config, old name mapped to it , is critical in mature libraries.</p><h3>3. Minimal, focused changes are best</h3><p>It’s tempting to refactor more code or rewrite documentation heavily, but for a production library:</p><ul><li>Small, well-scoped changes</li><li>Clear behavior improvements</li><li>Minimal diff in docs</li></ul><p>…are easier to review, reason about, and maintain.</p><h3>4. Tests should prove semantics, not just “it runs”</h3><p>The tests I added checked:</p><ul><li>That ignored functions <strong>never run</strong></li><li>That outputs match eager mode</li><li>That no graph breaks occur</li><li>That ignored functions behave as None in compiled semantics</li><li>That ignoring and reordering configs work together safely</li></ul><p>This kind of testing catches regressions in behavior, not just crashes.</p><h3>5. Dealing with CI and lint is part of the work</h3><p>A good chunk of time went into:</p><ul><li>Reading lint errors carefully</li><li>Cleaning whitespace and formatting</li><li>Keeping the registry and docs consistent</li></ul><p>It’s all part of working in a big shared codebase.</p><h3>How PyTorch benefits from this change</h3><p>This change unlocks a much more flexible way to combine <strong>real-world Python code</strong> with torch.compile.</p><p>Now users can:</p><ul><li>Ignore arbitrary debug functions, for example:</li><li>print</li><li>Custom logger wrappers</li><li>Monitoring hooks</li><li>Avoid graph breaks caused purely by logging or debugging</li><li>Keep performance benefits of torch.compile without rewriting all their logging code</li></ul><p>At the same time:</p><ul><li>Existing users of ignore_logger_methods are still supported</li><li>They automatically benefit from the new unified behavior under ignore_logging_functions</li></ul><p>In short:</p><blockquote><em>PyTorch now has a cleaner, more powerful way to treat logging and debug functions as “pure no-ops” inside compiled graphs, without giving up correctness or backward compatibility.</em></blockquote><p>For me personally, it was a solid achievement:</p><ul><li>I dug into Dynamo internals</li><li>Designed and implemented a new feature end-to-end</li><li>Updated tests, docs, and registry</li><li>Got the change merged into a major open-source library</li></ul><p>And now, whenever someone writes:</p><pre>torch._dynamo.config.ignore_logging_functions.add(print)</pre><p>and their training loop just works with torch.compile, there’s a small piece of code behind the scenes IgnoredFunctionVariable and friends, that I put there.</p><h3>If you made it till here, thank you ❤️</h3><p>I’m sharing more such learnings from real backend on my journey.</p><blockquote><em>Connect with me through </em><a href="https://linktr.ee/manikandangkrish"><em>linktr.ee</em></a><em> to know more!</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc8b99ce3f83" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloudflare Outage of November 2025]]></title>
            <link>https://manigkrish.medium.com/cloudflare-outage-of-november-2025-28a7ee25450a?source=rss-2c8d9c074bd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/28a7ee25450a</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[outage]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[cloudflare-outage]]></category>
            <category><![CDATA[cloudflare]]></category>
            <dc:creator><![CDATA[Manikandan Gobalakrishnan]]></dc:creator>
            <pubDate>Fri, 21 Nov 2025 17:04:13 GMT</pubDate>
            <atom:updated>2025-11-21T17:04:13.868Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*JpRM9Votx_FJ_UVl.png" /></figure><p>On the afternoon of <strong>18 November 2025</strong>, the internet didn’t feel normal.<br>At first it was subtle a few apps slowing down, some websites refusing to load, a couple of unexpected “internal server error” messages. No one panicked. We’ve all seen websites glitch before.</p><p>But then, almost in synchrony, everything began failing.</p><p>ChatGPT stalled.<br>X (formerly Twitter) became unreachable for thousands.<br>SaaS dashboards wouldn’t open.<br>Online games froze mid-match.<br>E-commerce checkouts crashed at the final payment step.</p><p>For millions of users from office workers to developers to casual browsers it felt like the digital world suddenly hit a wall.</p><p>Hours later, it became clear:<br><strong>Cloudflare</strong>, one of the most important companies in the internet’s infrastructure, had gone down.</p><p>This is the full story of what truly happened not just the headlines, but the chain of events, the hidden systems, the human decisions, and how engineers around the world scrambled to get the web back on its feet.</p><h3>What Cloudflare Really Is…</h3><p>Before diving into the chaos, let’s understand the role Cloudflare silently plays in our digital lives.</p><p>Cloudflare is not a search engine. Not a social network.<br>It’s something far more foundational.</p><p>Imagine the internet as a vast city.<br>Every website is a home, shop, or office.<br>Cloudflare is the <strong>city’s roads, traffic signals, toll booths, security guards, and power lines</strong> all rolled into one.</p><p>Here’s what Cloudflare does in everyday language:</p><h3>✓ It speeds up websites</h3><p>Copies of sites are stored around the planet, closer to users.</p><h3>✓ It protects websites</h3><p>It blocks attacks, filters bad bots, and stops suspicious traffic.</p><h3>✓ It routes traffic</h3><p>Every time you open a Cloudflare-protected website, your request goes through them first.</p><p>This underlying role gives Cloudflare incredible influence. Roughly:</p><p><strong>20% of the entire web touches Cloudflare.</strong></p><p>So when Cloudflare stumbles, the whole internet feels the shockwave.</p><p>And on November 18, it didn’t just stumble.<br>It tripped, fell, and accidentally pulled down half the web with it.</p><h3>The First Signs of Trouble</h3><p>At around <strong>11:20 UTC</strong>, Cloudflare engineers pushed a routine change.<br>Just another update in the constant stream of tiny adjustments they make each day.</p><p>The update affected a part of Cloudflare you probably never heard of:</p><p><strong>Bot Management</strong><br>the silent system that determines if a visitor is a real human or an automated script.</p><p>To run this system, Cloudflare uses something called a <strong>feature file</strong> think of it like a rulebook containing the behaviors of good bots and suspicious bots.</p><p>The update was supposed to slightly modify that file.<br>Except it didn’t.</p><p>Because of an internal permissions issue, the file didn’t just change.<br>It <strong>doubled in size.</strong><br>Unexpectedly. Unintentionally. Invisibly at first.</p><p>This was the moment the spark touched the fuse.</p><h3>When One File Broke the Internet</h3><p>The oversized rule file did something nobody anticipated:</p><p>It triggered a bug deep inside Cloudflare’s <strong>HTTP proxy software</strong> the heart of the system that handles incoming traffic.</p><p>That software wasn’t designed to accept such a huge file.<br>When it tried, it simply… <strong>crashed</strong>.</p><p>And not in one locationCloudflare is global.<br>The file automatically syncs to <strong>every Cloudflare data center</strong> across the world.</p><p>Here’s the terrifying timeline:</p><ol><li>The bad file reaches the first proxy.</li><li>The proxy tries to load it.</li><li>It fails and shuts down the module.</li><li>Traffic routed through that module collapses.</li><li>The file propagates automatically to another region.</li><li>The same failure happens there.</li><li>And then another.</li><li>And another.</li><li>And suddenly, massive parts of Cloudflare’s network are choking.</li></ol><p>Engineers call these “cascading failures”.<br>Humans call it “everything is going down”.</p><p>Within minutes:</p><ul><li>Pages began returning <strong>502</strong> and <strong>503</strong> errors.</li><li>Apps that hadn’t failed in years suddenly felt fragile.</li><li>IT teams worldwide started asking, “Is the internet down?”</li><li>Downdetector graphs shot up instantly.</li></ul><p>This was no localized glitch.<br>The <strong>backbone of the internet</strong> was failing globally.</p><h3>How Regular People Experienced the Chaos</h3><p>While engineers were staring wide-eyed at cascading logs, the rest of the world was having a very different experience.</p><blockquote><em>Messages weren’t sending.</em></blockquote><blockquote><em>Login pages stalled.</em></blockquote><blockquote><em>E-commerce websites froze.</em></blockquote><blockquote><em>Developers couldn’t access their own dashboards.</em></blockquote><blockquote><em>ChatGPT returned nothing but blank screens.</em></blockquote><blockquote><em>X showed “something went wrong”.</em></blockquote><p>In India, <strong>the outage was felt most during late afternoon</strong> and evening.<br>For many, it felt like an invisible storm passing through the internet, leaving outages behind like fallen trees.</p><p>This wasn’t a single site going down.<br>It was a domino effect first one service, then another, then dozens.</p><h3>Inside Cloudflare’s</h3><p>Imagine being in Cloudflare’s network operations center at that moment.</p><p>Dashboards turning red.<br>Traffic graphs plummeting.<br>Regions blinking offline one by one.<br>Alerts pouring in faster than they can be read.</p><p>Engineers quickly realized:</p><blockquote><em>“Something is taking down our entire HTTP pipeline.”</em></blockquote><p>The moment they traced it back to the Bot Management feature file, everything clicked.</p><p>The file was corrupt.<br>The proxies were collapsing because of it.<br>And it was already <strong>everywhere</strong>.</p><p>Fixing this wasn’t as simple as pressing “undo”.</p><p>Because:</p><ul><li>Every data center needed to discard the broken file</li><li>Every service relying on it needed to restart</li><li>Propagation had to be stopped</li><li>The stable version had to be pushed out surgically</li><li>And everything had to recover <strong>without overwhelming the network again</strong></li></ul><p>This was the tech equivalent of open-heart surgery…<br>with the patient awake…<br>and running a marathon…<br>in the middle of a hurricane.</p><h3>The Road to Recovery</h3><p>Cloudflare’s response unfolded in several steps:</p><h3>1. Stop the rollout</h3><p>They immediately halted the distribution of the bloated file.</p><h3>2. Roll back to a known-good version</h3><p>A stable feature file from earlier was redeployed across the network.</p><h3>3. Restart affected systems</h3><p>Many proxy modules needed manual or automated restarts to return to service.</p><h3>4. Validate global traffic flow</h3><p>Engineers monitored every region as traffic slowly returned to normal.</p><p>By <strong>14:30 UTC</strong>, the internet began to breathe again.<br>By <strong>17:06 UTC</strong>, Cloudflare confirmed the crisis was fully resolved.</p><p>What took minutes to break took hours of intense, coordinated work to repair.</p><h3>Was This a Cyber Attack?</h3><p>No.</p><p>Cloudflare emphasized this was:</p><ul><li><strong>Not a hack</strong></li><li><strong>Not malware</strong></li><li><strong>Not a DDoS attack</strong></li><li><strong>Not an intrusion</strong></li></ul><p>This was an <em>internal failure</em> the kind that reminds us even the strongest systems have weak points.</p><h3>What This Outage Really Teaches Us</h3><h3>1. The internet is more fragile than we think</h3><p>Under the glossy surface, the web depends on countless silent systems.</p><h3>2. Centralization is a double-edged sword</h3><p>Cloudflare makes the web faster and safer but it also concentrates risk.</p><h3>3. A tiny bug can create a global failure</h3><p>Sophisticated systems can fail in surprisingly simple ways.</p><h3>4. Transparency matters</h3><p>Cloudflare’s detailed post-mortem helped the entire industry learn from the mistake.</p><h3>5. Engineering is human</h3><p>Behind the scenes, real people were sweating over code, logs, and failing systems.</p><h3>The Outage That Will Be Remembered</h3><p>For a few hours, the world glimpsed how dependent we truly are on invisible infrastructure.<br>Most people won’t remember the technical details the oversized file, the failing modules, the permissions bug.</p><p>But they’ll remember how it <em>felt</em>:</p><ul><li>Like the digital world paused.</li><li>Like the internet’s heartbeat skipped.</li><li>Like we were reminded that even giants can fall.</li></ul><p>Cloudflare fixed the issue and the internet returned to normal…<br>but the story remains a powerful reminder:</p><p>The web is vast, but it’s also delicate.<br>And behind <strong>every click, every message, every page load</strong> there are layers of systems we never see, held together by engineers who quietly keep the world running.</p><p><strong>More About Cloudflare Outage</strong> <a href="https://blog.cloudflare.com/18-november-2025-outage/">https://blog.cloudflare.com/18-november-2025-outage/</a></p><blockquote><em>Connect with me through </em><a href="https://linktr.ee/manikandangkrish"><em>linktr.ee</em></a><em> to know more!</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28a7ee25450a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Made My Java Code 77x Faster (7000ms → 90ms) With Minimal Changes]]></title>
            <link>https://manigkrish.medium.com/how-i-made-my-java-code-77x-faster-7000ms-90ms-with-minimal-changes-44f8cd892e26?source=rss-2c8d9c074bd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/44f8cd892e26</guid>
            <category><![CDATA[sde-interview]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Manikandan Gobalakrishnan]]></dc:creator>
            <pubDate>Fri, 31 Oct 2025 22:17:06 GMT</pubDate>
            <atom:updated>2025-10-31T22:22:21.640Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*YuNIWcYVdHZwXaFW.png" /></figure><p>A few days ago, I was solving a simple problem in Java. Or at least, I <strong>thought</strong>it was simple.</p><blockquote><strong><em>Given an array of integers, count how many pairs (i, j) exist such that </em></strong><strong><em>i &lt; jand </em></strong><strong><em>arr[i] + arr[j] == target.</em></strong></blockquote><p>Sounds basic, right? So, like many others, I wrote the first thing that came to my mind — a double for-loop that checks all pairs.</p><p>It worked… until I tested it on a big array.</p><p><strong>7000 milliseconds.</strong><br>That’s <strong>7 seconds</strong>, and trust me, it felt like forever.</p><p>So I thought, “Can I do better?”</p><p>Turns out, yes <strong>much better</strong>.</p><h3>The Problem Statement</h3><p>You are given:</p><ul><li>An integer array arr</li><li>A target value T</li></ul><p>You need to <strong>count the number of pairs (i, j)</strong> such that:</p><ul><li>i &lt; j</li><li>arr[i] + arr[j] == T</li></ul><p>That’s it. Simple enough.</p><h3>Step 1: First Thoughts — The Brute Force Way</h3><p>As a beginner, my first instinct was to use a <strong>nested loop</strong>. We check every possible pair of elements and see if their sum equals the target.</p><p>Code:</p><pre>int count = 0;<br>for (int i = 0; i &lt; arr.length; i++) {<br>    for (int j = i + 1; j &lt; arr.length; j++) {<br>        if (arr[i] + arr[j] == target) {<br>            count++;<br>        }<br>    }<br>}</pre><h3>Pros:</h3><ul><li>Very easy to understand.</li><li>Covers all valid pairs.</li></ul><h3>Cons:</h3><ul><li>Time complexity = O(n²)</li><li>Terribly slow for large inputs.</li></ul><h3>Performance Testing</h3><blockquote><em>Let’s say the array has 10,000 elements.<br>With nested loops, that’s nearly </em><strong><em>50 million comparisons</em></strong><em>.</em></blockquote><blockquote><em>That’s why this approach was taking </em><strong><em>over 7000 milliseconds</em></strong><em> (7 seconds) on big inputs.</em></blockquote><blockquote><em>Even though it gives the correct answer, it’s far from efficient.</em></blockquote><blockquote><em>And in coding interviews or real production code, </em><strong><em>efficiency is everything.</em></strong></blockquote><h3>Step 2: Rethinking the Problem: The “Smarter” Approach</h3><p>Let’s break it down:</p><p>Suppose the current number is num.<br>We want to find if there&#39;s any <strong>previous number</strong> such that:</p><pre>num + prevNum == target</pre><p>Which means:</p><pre>prevNum = target - num</pre><p>That gives us an idea:</p><blockquote><em>“Can we store previous numbers and check if </em><em>target - num is already there?</em></blockquote><p>And that’s exactly where <strong>HashMap</strong> comes into play.</p><h3>Step 3: HashMap to the Rescue</h3><p>We use a HashMap to store <strong>frequencies</strong> of numbers we’ve seen so far.<br>For every number in the array, we:</p><ol><li>Check if target - num exists in the map.</li><li>If it does, we add the frequency to the count.</li><li>Then, we update the current number’s frequency in the map.</li></ol><p>Code:</p><pre>int count = 0;<br><br>Map&lt;Integer, Integer&gt; freqMap = new HashMap&lt;&gt;();<br><br>for (int num : arr) {<br><br>    int complement = target - num;<br><br><br>    // If complement is already in the map, we found some pairs<br><br>    if (freqMap.containsKey(complement)) {<br><br>        count += freqMap.get(complement);<br>    }<br><br><br>    // Update frequency of current number<br><br>    freqMap.put(num, freqMap.getOrDefault(num, 0) + 1);<br>}</pre><h3>Why this works:</h3><ul><li>We’re looping through the array only <strong>once</strong>.</li><li>At every step, we check if we’ve already seen the number we need to form a valid pair.</li></ul><p>Time Complexity: O(n)</p><p>Space Complexity: O(n)</p><h3>Real Performance Test</h3><blockquote><em>I used the same array of 10,000 elements and ran both versions.</em></blockquote><blockquote><strong><em>Brute force:</em></strong><em> 7000ms+</em></blockquote><blockquote><strong><em>HashMap version:</em></strong><em> ~90ms</em></blockquote><blockquote><em>That’s more than </em><strong><em>75 times faster.</em></strong></blockquote><blockquote><em>And we didn’t do anything “advanced” — just used the </em><strong><em>right data structure</em></strong><em> and </em><strong><em>rethought the logic</em></strong><em>.</em></blockquote><h3>What I Learned</h3><p>Here are the 5 biggest lessons I took away:</p><h3>1. Brute Force is OK at First</h3><p>It’s okay to write the slow version first. It helps you understand the problem better.</p><h3>2. Watch Your Time Complexity</h3><p>If your solution is O(n²), and n can be large chances are it’s not scalable.</p><h3>3. HashMaps Are Powerful</h3><p>HashMaps (or dictionaries) are life-savers when you need:</p><ul><li>Fast lookup</li><li>Frequency count</li><li>Complement logic</li></ul><h3>4. Know Common Patterns</h3><p>This problem follows the classic <strong>Two-Sum pattern</strong>, one of the most common problems in interviews.</p><p>Once you recognize the pattern, the solution becomes much easier.</p><h3>5. Optimize Your Thinking</h3><p>In many cases, speed isn’t about writing faster code. It’s about <strong>changing how you think about the problem.</strong></p><h3>Final Thoughts</h3><p>When I first solved this problem, I was happy it worked. But when I optimized it and saw a <strong>90ms runtime</strong>, I felt like a real engineer.</p><blockquote><em>Clean, fast, and readable code isn’t about being clever it’s about being smart with your approach.</em></blockquote><blockquote><em>If you’re preparing for interviews, building projects, or just improving your Java skills/DSA, take a little extra time to </em><strong><em>analyze your logic</em></strong><em>. That’s where the real growth happens.</em></blockquote><p>Connect with me through <a href="https://linktr.ee/manikandangkrish">linktr.ee</a> to know more!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44f8cd892e26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How We Actually Design Databases in Interviews vs. When Building Real Systems]]></title>
            <link>https://manigkrish.medium.com/hiii-30de150d0b83?source=rss-2c8d9c074bd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/30de150d0b83</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[interview]]></category>
            <dc:creator><![CDATA[Manikandan Gobalakrishnan]]></dc:creator>
            <pubDate>Fri, 24 Oct 2025 17:49:10 GMT</pubDate>
            <atom:updated>2025-11-17T19:06:46.615Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*BDbHTkbb6qJnqW-n" /></figure><p>I’ve been on both sides of database design.</p><ul><li>In interviews, it feels neat and clean.</li><li>In real life, it feels messy, unpredictable, and full of surprises.</li></ul><blockquote><em>Let me explain both, step by step, so you see the difference clearly.</em></blockquote><h3>The Interview Way: Clean and Impressive</h3><p>In interviews, time is short and expectations are clear. You’re not building a full system, you’re just showing how you think. That’s why most interview designs look like this:</p><p>Example: <strong>Food Delivery App (like Swiggy/Zomato)</strong></p><ul><li>A Users table with id, name, email.</li><li>A Restaurants table with id, name, location.</li><li>An Orders table with user_id, restaurant_id, total_amount, status.</li><li>An Order_Items table with order_id, item_name, price.</li><li>A Payments table with order_id, amount, method, status.</li></ul><p>And then you add the finishing touches:</p><ul><li>“We’ll normalize to avoid redundancy.”</li><li>“We’ll add indexes on user_id and restaurant_id.”</li><li>“For scale, we’ll shard by user_id and use caching.”</li></ul><p>That’s it. The schema looks clean, logical, and easy to explain in 10 minutes.</p><p>In interviews, nobody asks:</p><ul><li><em>“What if payments fail three times?”</em></li><li><em>“How do you handle refunds or promo codes?”</em></li><li><em>“What happens when a billion rows pile up and you need to add a new column?”</em></li></ul><p>Because the interviewer’s goal is not to test production reality. They just want to see if you can think in a structured way.</p><p>So interviews are like building a <strong>blueprint of a house</strong>. It looks pretty on paper.</p><h3>The Real-Life Way: Messy and Full of Trade-offs</h3><p>Now let’s talk about real systems. The moment you actually build something like a food delivery app, things get complicated very fast.</p><p>That single Orders table? It explodes into many:</p><ul><li>orders (main order details)</li><li>order_items (because one order can have many items)</li><li>order_discounts (because customers use coupons)</li><li>order_payments (because orders have multiple payments sometimes)</li><li>order_payment_attempts (because payments fail and retry)</li><li>order_refunds (because cancellations happen)</li><li>order_audit_logs (because you need history for support and compliance)</li></ul><p>Already messy, right? And this is just one part of the system.</p><h3>Performance challenges</h3><p>In interviews, we normalize everything. But in real systems, too many JOINs kill performance.</p><p>For example: fetching one order along with its items, discounts, and payments required 7+ JOINs. Way too slow for customers waiting on the app.</p><p>So we broke the “pure” rules and <strong>denormalized some data</strong> into a read-friendly model and cached it in Redis.</p><h3>Migrations hurt</h3><p>In interviews, you say: <em>“We’ll add a column for delivery_instructions.”</em><br>In real life, the orders table already has 300 million rows. Adding a column can lock the table for hours.<br>We had to:</p><ul><li>Add the column silently.</li><li>Backfill in small batches.</li><li>Test rollback in staging.</li><li>Monitor replication lag.<br>That “simple column” took two weeks to roll out safely.</li></ul><h3>Business rules rewrite schemas</h3><p>Originally, we just had one payment_status column in the orders table.<br>But finance said: <em>“We need partial payments, multiple attempts, and settlements with banks.”</em></p><p>That meant creating new tables: order_payments, order_payment_attempts, settlement_records.</p><p>What was a neat design on day one kept changing again and again as business rules evolved.</p><h3>Compliance and audits</h3><p>Nobody in interviews asks: <em>“How will you track every single data change for regulatory audits?”</em><br>But in fintech or banking, this is mandatory.<br>We had to create audit_trails storing:</p><ul><li>what changed</li><li>old value</li><li>new value</li><li>who changed it</li><li>when it changed</li></ul><p>Without this, we’d fail compliance checks.</p><h3>Indexes are not always good</h3><p>In interviews, you proudly say</p><p><em>“We’ll add an index on email for faster lookup.”</em></p><p>In real systems, indexes speed up reads but slow down writes. At one point, we had so many indexes that inserts slowed down by 40%. We had to carefully drop and redesign indexes.</p><h3>The Real Difference: Interviews vs Real Life</h3><p>When you put both experiences together, the contrast is huge.</p><ul><li>In interviews, entities are few. In real life, they multiply quickly.</li><li>In interviews, normalization is the golden rule. In real life, denormalization saves performance.</li><li>In interviews, scaling is just a buzzword. In real life, scaling means partitioning data, handling cache invalidation, and planning migrations.</li><li>In interviews, migrations are a one-liner. In real life, migrations can take weeks and break production if not done carefully.</li><li>In interviews, compliance is never discussed. In real life, compliance and audits drive half of your design decisions.</li></ul><h3>Lessons I’ve Learned</h3><ol><li><strong>The perfect schema doesn’t exist.</strong> Whatever you design today will evolve tomorrow.</li><li><strong>Design for change, not just for today.</strong> Always ask: “What if requirements change next month?”</li><li><strong>Performance beats theory.</strong> Sometimes denormalization and caching are the only way to keep systems fast.</li><li><strong>Indexes are powerful but dangerous.</strong> Use them carefully.</li><li><strong>Business and compliance matter as much as technical design.</strong> Ignore them, and your system will fail in production.</li></ol><h3>Final Thought</h3><p>In interviews, database design is about <strong>impressing with clarity</strong>.<br>In real life, database design is about <strong>surviving change, scale, and chaos</strong>.</p><p>The first one gets you the job.<br>The second one keeps your system alive at 3 AM when a billion-row migration goes wrong.</p><p>And honestly, both skills are valuable.</p><p>One proves you can think.</p><p>The other proves you can build.</p><p><strong>NOTE</strong>: It’s not detailed yet, but I’ll be launching my website soon, where you’ll find more details in a clearer and more organized way. Thanks for your patience.</p><blockquote><em>Connect with me through </em><a href="https://linktr.ee/manikandangkrish"><em>linktr.ee</em></a><em> to know more!</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30de150d0b83" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How We Cut Response Time(Latency) From 3s to 120 ms.]]></title>
            <link>https://manigkrish.medium.com/cfvgbhn-0b33f6be9304?source=rss-2c8d9c074bd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/0b33f6be9304</guid>
            <dc:creator><![CDATA[Manikandan Gobalakrishnan]]></dc:creator>
            <pubDate>Wed, 15 Oct 2025 16:29:43 GMT</pubDate>
            <atom:updated>2025-10-27T15:57:54.451Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*CS3wvpjtpvpPcZ1p" /></figure><p>When you open a website or app, you expect it to respond <em>instantly</em>.<br>That’s <strong>low latency</strong> the time between when a user does something and when the system responds.</p><p>If your system takes too long, people leave.<br>If it feels instant, people stay longer, trust it more, and even recommend it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*uCYSUPgYCDuNY2Tr" /></figure><p>After years of building and fixing backend systems in fintech and e-commerce, I’ve realised that making a system low-latency is not one single trick it’s a combination of <strong>architecture decisions, coding practices, and infrastructure setup</strong>.</p><h3>1. Reduce Network Hops</h3><p>Every time a request travels between different servers or services, it adds time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*i-NIOeYRXXjEOumP" /></figure><p><strong>Example:</strong><br>Imagine you want to get the balance of a user account.</p><ul><li><strong>Bad way:</strong> API → Auth Service → Profile Service → Balance Service → Database. (4 hops)</li><li><strong>Better way:</strong> API → Balance Service (direct DB access). (1 hop)</li></ul><p>Even a 50ms delay per hop adds up quickly.</p><p><strong>How to do it:</strong></p><ul><li>Remove unnecessary micro service calls.</li><li>Place services that talk often close to each other.</li><li>Use <strong>edge servers/CDNs</strong> for content close to the user.</li></ul><h3>2. Cache Frequently Used Data</h3><p>If the data doesn’t change often, don’t fetch or calculate it every time <strong>store it in memory</strong> for quick access.</p><p><strong>Example:</strong><br>A stock price app calling the database for the same price every second is wasteful.</p><ul><li>Store it in <strong>Redis</strong> with a 1-second TTL, and read from cache instead of DB.</li><li>Result: From 100ms DB query → 2ms cache lookup.</li></ul><p><strong>Best practices:</strong></p><ul><li>Use in-memory caches (Redis, Memcached).</li><li>Cache at multiple levels (browser, CDN, server).</li><li>Set sensible expiry times to avoid stale data.</li></ul><h3>3. Optimise Database Queries</h3><p>Slow database queries are one of the most common causes of high latency.</p><p><strong>Example:</strong><br>An e-commerce site fetching product details with SELECT * from a table with 10 million rows will crawl.</p><ul><li>Instead, use SELECT name, price FROM products WHERE id = ?</li><li>Add an <strong>index</strong> on id for faster lookups.</li></ul><p><strong>Tips:</strong></p><ul><li>Avoid unnecessary joins.</li><li>Use read replicas for high-read workloads.</li><li>Precompute heavy results and store them.</li></ul><h3>4. Batch and Parallel Requests</h3><p>Sending multiple small requests one by one increases wait time.</p><p><strong>Example:</strong><br>A report system fetching data for 12 months:</p><ul><li><strong>Slow way:</strong> 12 separate API calls in sequence → 12 seconds.</li><li><strong>Fast way:</strong> Batch all months in 1 request → 1 second.</li><li>Or run 12 calls <strong>in parallel</strong> → still ~1 second.</li></ul><p><strong>Tools:</strong></p><ul><li>Async programming (Java CompletableFuture, Node.js async/await).</li><li>Message queues (Kafka, RabbitMQ) for non-critical tasks.</li></ul><h3>5. Reduce Data Transfer</h3><p>Sending too much data is like delivering a truckload when you only need a backpack.</p><p><strong>Example:</strong><br>A user profile API sending <em>every</em> detail (address history, preferences, etc.) when UI only needs name and photo wastes bandwidth.</p><p><strong>Fix:</strong></p><ul><li>Send only the required fields.</li><li>Compress large payloads (GZIP).</li><li>Use <strong>gRPC</strong> or binary formats for high-frequency calls.</li></ul><h3>6. Focus on the Critical Path</h3><p>The “critical path” is the minimum work required to give the user their answer.</p><p><strong>Example:</strong><br>In a ticket booking system:</p><ul><li>User clicks “Book” → Check seat availability → Confirm booking → Respond.</li><li>Sending email or logging analytics should happen <strong>after</strong> the response, not before.</li></ul><p>This single change can cut seconds from response time.</p><h3>7. Measure and Profile Everything</h3><p>You can’t improve what you don’t measure.</p><p><strong>Example:</strong><br>A payments API had a random 800ms delay. Profiling showed that 500ms was being spent logging to a slow external service. We made logs async, and latency dropped instantly.</p><p><strong>Tools:</strong></p><ul><li>Jaeger, Zipkin (request tracing)</li><li>Datadog, New Relic (monitoring)</li><li>Always track <strong>p50, p90, p99 latency</strong> not just average.</li></ul><h3>8. Push Work to the Client or Edge</h3><p>Don’t make the server do what the browser can handle.</p><p><strong>Example:</strong></p><ul><li>Validate form inputs in the browser before sending to backend.</li><li>Preload product images before the user clicks “View”.</li><li>Use service workers to serve cached content instantly.</li></ul><h3>9. Scale Before Traffic Hits</h3><p>A fast system at low traffic can become slow during peak hours.</p><p><strong>Example:</strong><br>An online sale crashed our order service because it handled 500 req/sec fine but failed at 5,000 req/sec.<br>Solution:</p><ul><li>Auto-scale servers.</li><li>Use load balancers.</li><li>Keep hot replicas in high-demand regions.</li></ul><h3>10. Avoid Cold Starts</h3><p>If you’re using serverless (like AWS Lambda), the first request after idle time can be slow.</p><p><strong>Example:</strong></p><ul><li>Lambda cold start: 1–2 seconds.</li><li>Keep functions “warm” by sending periodic pings.</li><li>Or keep a minimal instance always running.</li></ul><h3>Final Words</h3><p>Low latency is <strong>not</strong> just about making things fast it’s about <strong>making users feel like the system is instant</strong>.<br>You do this by:</p><ul><li>Cutting unnecessary work</li><li>Keeping data close</li><li>Doing heavy tasks later or in parallel</li><li>Measuring and improving continuously</li></ul><p>The secret?<br>Design your system so the <strong>user’s wait time is as short as possible</strong>, even if the backend is doing a lot more after the response.</p><blockquote><em>Connect with me through </em><a href="https://linktr.ee/manikandangkrish"><em>linktr.ee</em></a><em> to know more!</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0b33f6be9304" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Reason I Sometimes Ditch Kafka for Redis Streams]]></title>
            <link>https://manigkrish.medium.com/hii-c1453c2007eb?source=rss-2c8d9c074bd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1453c2007eb</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[hld]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[lld]]></category>
            <dc:creator><![CDATA[Manikandan Gobalakrishnan]]></dc:creator>
            <pubDate>Tue, 07 Oct 2025 17:08:32 GMT</pubDate>
            <atom:updated>2025-10-27T16:07:04.895Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*Xe3uByXSz_B7kOEc" /></figure><p>I’ve lost count of how many times I’ve heard this debate in team chats or architecture reviews:</p><p><em>Let’s just use Kafka, it’s the industry standard.<br>No, Redis Streams can do it and is way simpler.</em></p><p>And then someone says <em>“Let’s POC both”</em>, which is corporate-speak for <em>“this will drag on for weeks.”</em></p><p>both Redis Streams and Kafka are amazing but they’re built for <strong>different jobs</strong>. If you treat them as the same thing, you’ll either:</p><ul><li>Over-engineer and drown in complexity, or</li><li>Under-engineer and crash into scaling issues later.</li></ul><h3>Redis Streams</h3><p>Redis Streams is <strong>not</strong> a separate tool it’s built right into Redis (since v5.0). If you’re already using Redis for caching, sessions, leaderboards, or queues, Streams is like discovering a hidden turbo button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*YkWFe5zOf_XSVkNu" /></figure><h3>How it feels in real life:</h3><ul><li><strong>Super fast </strong>I’ve seen sub-millisecond delays between publish and consume. Great for “right now” stuff.</li><li><strong>Can limit history</strong> You can keep only the last X events, so no endless disk growth.</li><li><strong>Simple setup</strong> If you already have Redis, you’re ready to go.</li><li><strong>Consumer groups</strong> Multiple workers can share the load without stepping on each other.</li></ul><p><strong>Example:</strong><br>We built a live game feed for an online chess platform. Every move had to appear instantly for spectators. Redis Streams was perfect we only needed the last 200 moves and speed mattered more than storing history forever.</p><h3>Kafka</h3><p>Kafka is <strong>not just a queue</strong> it’s a full event streaming backbone designed for <strong>huge scale and durability</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*p5uIwnLeKJ1AZKNn" /></figure><h3>How it feels in real life:</h3><ul><li><strong>Long-term storage</strong> Keep events for months or years. Replay them anytime.</li><li><strong>Scales like crazy </strong>Millions of events per second? No problem.</li><li><strong>Exactly-once delivery</strong> (with some setup) Great for financial or critical data.</li><li><strong>Complex pipelines</strong> Join, aggregate, transform data in real time with Kafka Streams or kSQL.</li></ul><p><strong>Example:</strong><br>I worked with a fintech company that had to store every single transaction for <strong>7 years</strong> for compliance. Kafka was the obvious choice durable, fault-tolerant, and replayable for audits. Redis Streams here would have been risky and non-compliant.</p><h3>Why People Mix Them Up</h3><p>Both can:</p><ul><li>Deliver events to multiple consumers</li><li>Support acknowledgments</li><li>Replay recent messages</li><li>Work in event-driven systems</li></ul><p><strong>But in reality:</strong></p><ul><li><strong>Redis Streams</strong> = low-latency, short-lived messages</li><li><strong>Kafka</strong> = long-term, large-scale event history</li></ul><h3>When to Pick Redis Streams</h3><ul><li>You care about <strong>now</strong>, not forever.</li><li>You want ultra-low latency.</li><li>You already have Redis running.</li><li>Your data fits in memory or can be trimmed.</li></ul><p>tip: Sometimes I use Redis Streams for <strong>real-time UX</strong> and Kafka for the <strong>long-term pipeline</strong>.</p><h3>When to Pick Kafka</h3><ul><li>You <strong>must not lose data</strong> (finance, healthcare, compliance).</li><li>You need <strong>long-term replay</strong>.</li><li>You expect <strong>massive scale</strong>.</li><li>Many systems will consume the same events.</li></ul><p><em>tip :</em> If you expect your system to grow fast, starting with Kafka can save you a painful migration later.</p><h3>The Hybrid Approach (My Favorite)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*3aT4K5dew9qbI6Z6" /></figure><ul><li>Redis Streams → instant updates for chat, leaderboards, notifications.</li><li>Kafka → permanent, replayable storage for analytics, ML, and audits.</li></ul><p><strong>Example:</strong> Taxi app ride request flow:</p><ul><li><strong>Redis Streams</strong> → Notifies nearby drivers immediately.</li><li><strong>Kafka</strong> → Stores the event for billing, fraud checks, and reports.</li></ul><h3>How I Decide in Real Life</h3><p>I ask myself 3 questions:</p><ol><li>If I lose the last hour of events, is it catastrophic? → <strong>Yes = Kafka</strong></li><li>Do I need to replay months-old events? → <strong>Yes = Kafka</strong></li><li>Do I need ultra-low latency without Kafka’s overhead? → <strong>Yes = Redis Streams</strong></li></ol><p>If I can’t answer all confidently, I often do <strong>Redis Streams for hot path</strong> and <strong>Kafka for cold path</strong>.</p><h3>Final Analogy</h3><ul><li><strong>Redis Streams</strong> → A bike fast, agile, easy to maintain, perfect for quick trips.</li><li><strong>Kafka</strong> → A freight train slower to start, but can carry massive loads long distances.</li><li><strong>Both together</strong> → Use the bike for urgent deliveries, and the train for bulk shipments.</li></ul><p><strong>Short Ending:</strong><br>In the end, it’s not Redis Streams <em>vs</em> Kafka it’s knowing when to ride the bike and when to run the train.</p><p><strong><em>Happy System Designing!</em></strong></p><blockquote><em>Connect with me through </em><a href="https://linktr.ee/manikandangkrish"><em>linktr.ee</em></a><em> to know more!</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1453c2007eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Essential Load Balancing Algorithms to Master for System Design Success]]></title>
            <link>https://manigkrish.medium.com/jjm-050865bbd066?source=rss-2c8d9c074bd2------2</link>
            <guid isPermaLink="false">https://medium.com/p/050865bbd066</guid>
            <dc:creator><![CDATA[Manikandan Gobalakrishnan]]></dc:creator>
            <pubDate>Fri, 03 Oct 2025 18:00:11 GMT</pubDate>
            <atom:updated>2025-10-08T17:37:26.103Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Unlock the Key Load Balancing Techniques with Explanations, Real-World Applications, and In-Depth Learning Resources</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*QhlYYgINuw0YZFo6TJ-LAQ.png" /><figcaption>High-Level Design of Load Balancer Algorithms</figcaption></figure><p>Before we deep dive, Let us go through some facts below:</p><ul><li><em>Amazon found that a delay of just 100 milliseconds in page load time can result in a 1% decrease in sales.</em></li><li><em>According to IDC, the average cost of an unplanned application outage is between $10,000 and $1 million per hour, depending on the industry and scale of operations.</em></li><li><em>Netflix serves over 232 million subscribers worldwide, requiring efficient load balancing across its global infrastructure to deliver seamless streaming experiences.</em></li><li><em>In 2020, DDoS attacks grew by 151% compared to the previous year, with the largest attack peaking at 2.3 Tbps.</em></li><li><em>Meta (Formerly Facebook), with over 3 billion monthly active users, relies on advanced load-balancing to manage billions of interactions per second</em></li><li><em>During events like Black Friday, online retailers can experience traffic spikes up to 10x their usual load</em></li></ul><p>Nowadays, system design interview performance is a crucial factor in confirming a candidate, to make sure he or she really can design scalable and efficient systems on the job. A deep understanding of essential load-balancing algorithms is crucial for creating systems with variable traffic flow efficiently and with high availability. Let’s delve into the top load-balancing algorithms that you should know, along with explanations, real-world applications, and additional resources that will deepen your understanding.</p><h3>1. Round Robin</h3><h3>Explanation</h3><p>Round Robin is one of the simplest and most commonly used load-balancing algorithms. It sends client requests, one after another, to a group of servers. A server, after completing the processing of a request, will take the next incoming request and turn it in the server list.</p><h3>Real-World Application</h3><p>Round-robin can also be used to divide an incoming set of HTTP requests evenly among several web servers in a web server farm. This ensures that no single server is overwhelmed by the traffic.</p><h3>Learning Resources</h3><ul><li><a href="https://www.f5.com/glossary/round-robin-load-balancing">Understanding Round Robin Load Balancing</a></li><li><a href="https://www.educative.io/answers/what-is-the-round-robin-load-balancing-technique">When to Use Round Robin in Load Balancing</a></li></ul><h3>2. Weighted Round Robin</h3><h3>Explanation</h3><p>Weighted Round Robin gives a scoring factor to each server according to how strong or capable it is. The more highly scored server receives the highest number of requests, allowing for better use of the resources.</p><h3>Real-World Application</h3><p>This method is useful in a hybrid server environment where some servers have more processing power or memory and can handle a higher number of requests.</p><h3>Learning Resources</h3><ul><li><a href="https://webhostinggeeks.com/blog/what-is-weighted-round-robin/">Weighted Round Robin in Depth</a></li><li><a href="https://www.ituonline.com/tech-definitions/what-is-weighted-round-robin-wrr/">Best Practices for Configuring Weighted Round Robin</a></li></ul><h3>3. Sticky Round Robin</h3><h3>Explanation</h3><p>Sticky Round Robin is the form of Round Robin that ensures requests from the same client always go to the same server each and every time. This “stickiness” usually works with session cookies or IP addresses to keep each user connected with just one server.</p><h3>Real-World Application</h3><p>The Sticky Round Robin is extremely useful in scenarios where maintaining user session information is important. Examples include online banking or shopping websites, where a user’s action needs to be continued by the same server. This method prevents problems like losing shopping cart data upon a client’s request when requests go to different servers.</p><h3>Learning Resources</h3><ul><li><a href="https://serverfault.com/questions/261539/load-balancing-best-practices-for-persistence">Sticky Sessions in Load Balancing: Best Practices</a></li><li><a href="https://docs.aws.amazon.com/prescriptive-guidance/latest/load-balancer-stickiness/welcome.html">Managing Session Persistence with Sticky Round Robin</a></li></ul><h3>4. Least Connections</h3><h3>Explanation</h3><p>The Least Connections algorithm sends requests to the server that has the fewest active connections at a given point in time. This method may work when the servers all have similar abilities and the processing time of a request differs.</p><h3>Real-World Application</h3><p>This algorithm is ideal for environments like database(DB) servers, where the processing time can be unpredictable and varies significantly between the requests.</p><h3>Learning Resources</h3><ul><li><a href="https://www.educative.io/answers/what-is-the-least-connections-load-balancing-technique">Least Connections Algorithm Explained</a></li><li><a href="https://docs.netscaler.com/en-us/citrix-adc/current-release/load-balancing/load-balancing-customizing-algorithms/leastconnection-method.html">Implementing Least Connections Load Balancing</a></li></ul><h3>5. IP/URL Hash</h3><h3>Explanation</h3><p>IP Hash uses the client’s IP address to determine which of the available servers should handle the request. It converts the IP address into a number, and this number is used to connect the client to one of the servers. In this way, the same client will be able to work with the same server.</p><h3>Real-World Application</h3><p>Basically, the hash of IP is used in scenarios where session persistence cannot be afforded. This includes e-commerce sites that depend on the maintenance of users’ shopping carts across requests.</p><h3>Learning Resources</h3><ul><li><a href="https://knowledge.broadcom.com/external/article?legacyId=2006129">Understanding IP Hashing in Load Balancing</a></li><li><a href="https://kemptechnologies.com/resources/glossary/source-ip-hash-load-balancing">Source IP Hash Load Balancing</a></li></ul><h3>6. Least Response Time</h3><h3>Explanation</h3><p>Least Response Time directs requests to the server that will respond the fastest. It blends elements of the Least Connections technique with a server’s instantaneous response times in order to make its decision.</p><h3>Real-World Application</h3><p>This algorithm is particularly effective in environments where response times from the server are critical, say live streaming platforms that may have latency issues impacting user experience.</p><h3>Learning Resources</h3><ul><li><a href="https://www.educative.io/answers/what-is-the-least-response-time-load-balancing-technique">Optimizing with Least Response Time</a></li><li><a href="https://docs.netscaler.com/en-us/citrix-adc/current-release/load-balancing/load-balancing-customizing-algorithms/leastresponsetime-method.html">How to Implement Least Response Time Load Balancing</a></li></ul><h3>7. Consistent Hashing</h3><h3>Explanation</h3><p>Consistent Hashing shares requests using a hash value that comes from the client request. It reduces the need to move requests around when servers are added or taken away, which makes it great for changing server setups.</p><h3>Real-World Application</h3><p>Consistent Hashing is widely used to minimize disruption in scaling within distributed caching systems like Memcached.</p><h3>Learning Resources</h3><ul><li><a href="https://adityagoel123.medium.com/consistent-hashing-57306dd24c2">Consistent Hashing: A Deep Dive</a></li><li><a href="https://highscalability.com/consistent-hashing-algorithm/">Why Consistent Hashing is Essential for Scalable Systems</a></li></ul><h3>8. Randomized Load Balancing</h3><h3>Explanation</h3><p>This is a technique where requests go to servers randomly. It is pretty simple yet amazingly effective in cases when the traffic is even and the servers have relatively similar abilities.</p><h3>Real-World Application</h3><p>Randomized Load Balancing is used when it’s better to keep things simple and there isn’t a need for complicated distribution rules, like in small web applications.</p><h3>Learning Resources</h3><ul><li><a href="https://www.eecs.harvard.edu/~michaelm/postscripts/mythesis.pdf">The Power of Randomized Load Balancing</a></li><li><a href="https://www.jscape.com/blog/load-balancing-algorithms">Random vs. Round Robin: Which Is More Effective?</a></li></ul><p>Mastering these essential load-balancing algorithms is a key to acing system design interviews. Each of the algorithms has an important role in ensuring that distributed systems and applications work, are reliable, and can easily scale up or down. You will enhance your understanding by looking at added learning resources for each algorithm that helps you understand how they are used in real-life scenarios and their detailed aspects.</p><p>Remember, load balancing is not just about distributing the traffic but also making efficient use of the available resources to keep the user experience smooth and seamless even under variable loads and conditions.</p><p>Thanks for reading! Please share this guide with others if you, in any way, found it useful so they can also do these sets of exercises. If you have thoughts, questions, and/or resources, head down to our comments section.</p><p><strong><em>Happy System Designing!</em></strong></p><blockquote><em>Connect with me through </em><a href="https://linktr.ee/manikandangkrish"><em>linktr.ee</em></a><em> to know more!</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=050865bbd066" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>