<?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[Debugging Diaries - Medium]]></title>
        <description><![CDATA[Lessons from the Software Trenches - Medium]]></description>
        <link>https://medium.com/debugging-diaries?source=rss----8e1ee92b126e---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Debugging Diaries - Medium</title>
            <link>https://medium.com/debugging-diaries?source=rss----8e1ee92b126e---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 06:22:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/debugging-diaries" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How Do We Scan Docker Images for Vulnerabilities?]]></title>
            <link>https://medium.com/debugging-diaries/how-do-we-scan-docker-images-for-vulnerabilities-3582de2c9c9f?source=rss----8e1ee92b126e---4</link>
            <guid isPermaLink="false">https://medium.com/p/3582de2c9c9f</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[vulnerability]]></category>
            <dc:creator><![CDATA[Pradyuman]]></dc:creator>
            <pubDate>Fri, 11 Sep 2026 17:48:36 GMT</pubDate>
            <atom:updated>2026-09-11T17:48:34.885Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently joined Microsoft’s Security organization, and scanning Docker images for vulnerabilities has become part of my day-to-day work. At some point, I started wondering: <strong>what actually happens when we scan a Docker image for vulnerabilities?</strong></p><p>Spoiler alert: the basic idea isn’t particularly complex. What makes it interesting are the details hidden behind that seemingly simple scan.</p><p>So let’s take a step back and understand what is actually happening under the hood, using <strong>Trivy</strong> as an example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xbfoSHG6_nSoyboO2DBt-g.png" /></figure><h3>What is a Docker image, really?</h3><p>Before understanding image scanning, we first need to understand what we’re scanning.</p><p>A Docker image is essentially a <strong>read-only blueprint of a container’s filesystem and configuration</strong>. An image is built from a series of filesystem layers, where each layer represents changes made during the image build — for example, installing packages, adding application files, or modifying configuration.</p><p>These layers are eventually presented as a single unified filesystem when the container runs. Alongside the layers, the image also contains metadata such as the entrypoint, environment variables, working directory, and user.</p><p>For example, an image might contain something conceptually like:</p><pre>Docker Image<br>│<br>├── Ubuntu filesystem<br>├── OpenSSL<br>├── curl<br>├── Python<br>├── Python packages<br>├── Application files<br>└── Image configuration</pre><p>And this is exactly what makes vulnerability scanning possible. <strong>We don’t need to run the container to understand much of what is inside it.</strong></p><h3>Trivy doesn’t need to run your container</h3><p>One of the interesting things about Trivy is that it can scan an image <strong>without starting a container from it</strong>.</p><p>Instead, Trivy works with the image itself, inspecting its layers and metadata. It essentially looks at the filesystem that would be available inside the container and tries to build an inventory of the software components present there.</p><p>These components exist at different levels.</p><p>At the operating-system level, the image may contain packages installed through package managers such as:</p><pre>dpkg    → Debian / Ubuntu<br>rpm     → RHEL / Fedora and others<br>apk     → Alpine</pre><p>But that’s only part of the story.</p><p>An image might also contain application-level dependencies:</p><pre>Python  → pip packages<br>Node.js → npm packages<br>Java    → JAR dependencies<br>Ruby    → gems<br>Go      → Go modules</pre><p>So the first job of the scanner is essentially:</p><blockquote><strong><em>What software is inside this image, and what versions of that software are installed?</em></strong></blockquote><p>For example, Trivy might build an inventory that looks something like:</p><pre>Ubuntu 22.04</pre><pre>openssl     3.0.2-0ubuntu1.15<br>curl        7.81.0-1ubuntu1<br>libc6       2.35-0ubuntu3</pre><pre>Python</pre><pre>requests    2.31.0<br>urllib3     2.0.7</pre><p>Once we have this inventory, the actual vulnerability matching can begin.</p><h3>From a package to a CVE</h3><p>Suppose Trivy discovers:</p><pre>openssl 3.0.2-0ubuntu1.15</pre><p>How does it determine whether this is vulnerable?</p><p>At first, the problem sounds trivial. Find vulnerabilities associated with OpenSSL, look at the affected versions, and compare them with the installed version.</p><p>For example, imagine a vulnerability says:</p><pre>Affected: &lt; 3.0.12<br>Fixed:    3.0.12</pre><p>A naive implementation could simply do:</p><pre>Installed: 3.0.2<br>Fixed:     3.0.12</pre><pre>3.0.2 &lt; 3.0.12<br>       ↓<br>   Vulnerable</pre><p>But this can produce incorrect results. The reason is <strong>vendor backporting</strong>.</p><h3>The version number isn’t always the whole story</h3><p>Linux distributions don’t always wait for an upstream project to release a completely new version before shipping a security fix. Instead, distributions such as Ubuntu and Debian often <strong>backport security patches</strong> into the versions they already maintain.</p><p>Imagine that an OpenSSL vulnerability is fixed upstream in version:</p><pre>3.0.12</pre><p>Ubuntu could take that security patch and apply it to its existing OpenSSL package, producing something like:</p><pre>3.0.2-0ubuntu1.18</pre><p>The upstream version still looks like 3.0.2, but the Ubuntu package may now contain the security fix.</p><p>If a scanner simply compared:</p><pre>3.0.2 &lt; 3.0.12</pre><p>it would incorrectly report the package as vulnerable.</p><p>This is why vulnerability matching is more interesting than a simple version comparison.</p><p>Trivy needs to understand <strong>which ecosystem the package belongs to, how that ecosystem versions packages, and what the relevant security advisory says about that specific package</strong>.</p><p>For our example, the relevant comparison might instead be:</p><pre>Installed:<br>3.0.2-0ubuntu1.15<br>Fixed:<br>3.0.2-0ubuntu1.18</pre><p>Now the comparison is meaningful.</p><pre>     3.0.2-0ubuntu1.15<br>              ↓<br>        older than<br>              ↓<br>     3.0.2-0ubuntu1.18</pre><p>Therefore, Trivy can report the package as vulnerable. If the image contained:</p><pre>3.0.2-0ubuntu1.20</pre><p>it would be at or beyond the fixed revision and would not be reported for that particular vulnerability.</p><p>The same fundamental process applies to application dependencies such as Python, npm, and Maven packages, although each ecosystem has its own package formats, versioning rules, and vulnerability advisories.</p><p>So that innocent-looking result:</p><pre>openssl → CVE-XXXX-YYYY → HIGH</pre><p>actually represents a chain of decisions:</p><pre>Image<br>  ↓<br>Identify OS<br>  ↓<br>Identify package<br>  ↓<br>Identify package version<br>  ↓<br>Identify ecosystem<br>  ↓<br>Find relevant vulnerability advisories<br>  ↓<br>Interpret the package version<br>  ↓<br>Check whether the installed version is affected<br>  ↓<br>Report the vulnerability</pre><h3>Why can the same image produce different results?</h3><p>There is another interesting property of vulnerability scanning: <strong>the scan result can change even when the image doesn’t.</strong></p><p>Suppose I build an image today containing:</p><pre>openssl 3.0.11</pre><p>and scan it. At this point, the vulnerability database might contain no known vulnerability affecting that particular package version. The scan could therefore return a clean result.</p><p>A week later, a new vulnerability is disclosed.</p><p>Nothing about my image has changed. The layers are exactly the same, the package version is exactly the same, and the application is exactly the same. But the vulnerability database now contains new information.</p><p>Running the scan again could produce:</p><pre>Before:<br>0 vulnerabilities<br><br>After:<br>1 HIGH vulnerability</pre><p>This is because a vulnerability scan is effectively a function of two things:</p><pre>Scan result =<br>    Image contents<br>    +<br>    Vulnerability intelligence available at scan time</pre><p>This is also why keeping the scanner and its vulnerability database up to date is important. A clean scan today doesn’t guarantee that the same image will remain clean tomorrow.</p><h3>Does finding a CVE mean the application is exploitable?</h3><p>Not necessarily. This is probably the most important caveat when interpreting vulnerability scan results.</p><p>Suppose Trivy reports:</p><pre>openssl → CVE-XXXX-YYYY → HIGH</pre><p>What we know is that the image contains a version of OpenSSL associated with that known vulnerability.</p><p>What we <strong>don’t automatically know</strong> is whether our application can actually be exploited through it.</p><p>For example, the vulnerable functionality might never be used by the application. The affected service might not be exposed to the network. The vulnerable code path might not be reachable in the application’s execution flow. Runtime configuration or other security controls might also prevent exploitation.</p><p>So the finding should be interpreted as:</p><blockquote><strong><em>“This image contains a software component associated with a known vulnerability.”</em></strong></blockquote><p>It should not automatically be interpreted as:</p><blockquote><strong><em>“This application can definitely be compromised.”</em></strong></blockquote><p>Determining the actual risk requires additional context: how the component is used, which code paths are reachable, how the application is exposed, what privileges the container has, and what other runtime controls are in place.</p><h3>So what is image scanning actually doing?</h3><p>At its core, Docker image vulnerability scanning is surprisingly straightforward. The scanner doesn’t magically understand whether your application is secure. It performs a series of relatively well-defined steps:</p><pre>               Docker Image<br>                     │<br>                     ▼<br>             Inspect image layers<br>                     │<br>                     ▼<br>             Identify OS/packages<br>                     │<br>                     ▼<br>          Identify application dependencies<br>                     │<br>                     ▼<br>             Build software inventory<br>                     │<br>                     ▼<br>          Match against vulnerability data<br>                     │<br>                     ▼<br>          Account for ecosystem/versioning<br>                     │<br>                     ▼<br>                Scan results</pre><p>The complexity comes from the details: different operating systems, different package managers, different ecosystems, vendor backports, constantly changing vulnerability intelligence, and the fact that a vulnerable component doesn’t necessarily mean an exploitable application.</p><p>And that, in a nutshell, is what happens behind a command as simple as:</p><pre>trivy image myapp:latest</pre><p>What looks like a single command is really <strong>software inventory + vulnerability intelligence + version matching</strong> working together.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3582de2c9c9f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/debugging-diaries/how-do-we-scan-docker-images-for-vulnerabilities-3582de2c9c9f">How Do We Scan Docker Images for Vulnerabilities?</a> was originally published in <a href="https://medium.com/debugging-diaries">Debugging Diaries</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What really happens to a row after you INSERT it?]]></title>
            <link>https://medium.com/debugging-diaries/what-really-happens-to-a-row-after-you-insert-it-bc1a3ff3f3b7?source=rss----8e1ee92b126e---4</link>
            <guid isPermaLink="false">https://medium.com/p/bc1a3ff3f3b7</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[memory-management]]></category>
            <category><![CDATA[relational-databases]]></category>
            <dc:creator><![CDATA[Pradyuman]]></dc:creator>
            <pubDate>Mon, 18 May 2026 05:31:00 GMT</pubDate>
            <atom:updated>2026-05-18T05:31:00.655Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XgUSJKCWnNwCBW66er4TPA.png" /></figure><p>You run:</p><pre>INSERT INTO users (id, name) VALUES (1, &#39;Pradyuman&#39;);</pre><p>From the outside, it feels like the row just “<em>goes into a table</em>”. Internally, something very different happens. That row is broken down into bytes, placed into a fixed-size memory page, and tracked using offsets — not direct pointers.</p><p>Let’s zoom into a single page and follow the journey of just one row.</p><p>Databases don’t store data as tables. They store data as pages. A page is a fixed-size block (<em>typically 8KB</em>), and it’s the smallest unit of storage and I/O. Inside a page, there are three regions: <em>a header</em> (metadata about the page), <em>a data region</em> (where row bytes live), and <em>a slot directory</em> (which points to where each row is stored).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*NI96LUNeov6biAvVsKMmjA.png" /></figure><p>Now our data reaches a page.</p><p>The engine first checks if there’s enough free space to accommodate the new row. If not, it moves to another page. Once a suitable page is found, the row is prepared for storage.</p><p>The row isn’t stored as a struct. It is serialized into a compact byte representation. For example:</p><p>(id=1, name=’Pradyuman’)</p><p>might look like:</p><p>[header][null bitmap][id][name_length][name_bytes]</p><p>This byte sequence is then written into the data region — specifically at the end of the available free space. The data region grows upward, keeping writes contiguous and minimizing movement.</p><p>But writing the data is only half the story.</p><p>To keep track of where each row lives, the page maintains a slot directory. A new slot entry is added, which stores the offset of this row inside the page.</p><p>This indirection is subtle but powerful. The row can move within the page (due to updates or compaction), and only the slot needs to be updated — not every reference to the row.</p><p>At this point, our row is inside the page as a sequence of bytes in the data region, with a corresponding slot entry pointing to its location. Reads use the slot directory to locate the row, updates can move the row and simply update the slot, and deletes can mark the slot and clean up later.</p><p>From the outside, it looks like a simple INSERT, but inside the page, it’s a careful balance of layout, indirection, and space management.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc1a3ff3f3b7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/debugging-diaries/what-really-happens-to-a-row-after-you-insert-it-bc1a3ff3f3b7">What really happens to a row after you INSERT it?</a> was originally published in <a href="https://medium.com/debugging-diaries">Debugging Diaries</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Happens When You Call a Container Running on a Kubernetes Cluster?]]></title>
            <link>https://medium.com/debugging-diaries/what-happens-when-you-call-a-container-running-on-a-kubernetes-cluster-18db2d47e430?source=rss----8e1ee92b126e---4</link>
            <guid isPermaLink="false">https://medium.com/p/18db2d47e430</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Pradyuman]]></dc:creator>
            <pubDate>Mon, 06 Apr 2026 12:31:01 GMT</pubDate>
            <atom:updated>2026-04-06T12:31:01.470Z</atom:updated>
            <content:encoded><![CDATA[<p>You type curl http://my-service.default.svc.cluster.local:8080/api from another pod. A response comes back in 50ms. But between that request and response, at least 8 different systems touched that packet. Let&#39;s trace every single hop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KC2xRC2kdvlmyp-KFsU8Yw.png" /></figure><h3>Layer 0: The Container Network Stack</h3><p><strong>System #1: Container Runtime (containerd/Docker)</strong></p><p>Your curl command executes inside the container&#39;s isolated network namespace. The container has:</p><ul><li>Its own /etc/resolv.conf pointing to the Kubernetes DNS service (usually 10.96.0.10:53)</li><li>Its own routing table</li><li>Its own iptables rules (inherited from the host, but isolated)</li><li>An eth0 interface connected to the pod network</li></ul><p>The curl process makes a DNS query to resolve my-service to an IP address.</p><h3>Layer 1: DNS Resolution (CoreDNS / kube-dns)</h3><p><strong>System #2: CoreDNS Pod</strong></p><p>The DNS query my-service.default.svc.cluster.local hits CoreDNS running in kube-system namespace. CoreDNS doesn&#39;t actually resolve this by looking up a database—it queries the Kubernetes API Server via the watch protocol to find Services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ii2u_MwmVWKx0zPOURl4PQ.png" /></figure><blockquote>Note: If you query just my-service (short name) from a pod in the same namespace, the search domains in /etc/resolv.conf automatically expand it to my-service.default.svc.cluster.local. But using the FQDN directly is explicit and skips the search path resolution.</blockquote><p>The DNS response returns the ClusterIP (a virtual IP, never actually assigned to any real interface).</p><blockquote><strong>Key insight:</strong> The ClusterIP 10.0.1.50 doesn&#39;t exist anywhere. It&#39;s a routing fiction maintained by the network layer.</blockquote><h3>Layer 2: TCP Connect (Client-side Kernel)</h3><p><strong>System #3: Pod’s Kernel Network Stack</strong></p><p>The container’s curl process issues a socket() → connect() system call targeting 10.0.1.50:8080.</p><p>The kernel’s TCP/IP stack in the pod’s network namespace:</p><ol><li>Allocates an ephemeral source port (e.g., 54321)</li><li>Creates a TCP socket in SYN_SENT state</li><li>Builds a TCP SYN packet:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OqMt2qwZ6YBb69E5dEc07w.png" /></figure><p>But here’s the critical part, this packet cannot be routed as-is. The destination IP is virtual.</p><h3>Layer 3: iptables NAT Rules (kube-proxy)</h3><p><strong>System #4: Host Node’s kube-proxy</strong></p><p>Before the packet leaves the pod, it hits the host’s iptables rules installed by kube-proxy. kube-proxy watches all Service objects and maintains a set of NAT rules.</p><p>For my-service, kube-proxy creates rules like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VUFl8q4L7CmP4CQZHvQxjA.png" /></figure><p><strong>What happens:</strong></p><ol><li>The packet with dest IP 10.0.1.50 matches the KUBE-SERVICES rule</li><li>It’s randomly selected to go to one endpoint (e.g., 10.0.3.20)</li><li>iptables performs DNAT (Destination NAT):</li></ol><ul><li>Original dest IP: 10.0.1.50</li><li>New dest IP: 10.0.3.20</li><li>The rewrite happens transparently to the application</li></ul><p>The packet now looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z9VAyjQfAaqdOch_xzLlJA.png" /></figure><h3>Layer 4: Network Overlay (Flannel/Calico)</h3><p><strong>System #5: Flannel/CNI Plugin</strong></p><p>The packet now needs to traverse the cluster network. If Flannel is the CNI:</p><ol><li><strong>Pod-to-host routing:</strong> The pod’s default route sends all non-local traffic to the host gateway (veth pair bridge).</li><li><strong>Host routing decision:</strong> The host kernel checks its routing table:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G3KOFfQlZuAXlf1A2HWIjA.png" /></figure><p>3. <strong>Same-node vs cross-node:</strong></p><ul><li>If pod B is on the <strong>same node</strong>: packet is bridged directly, goes to pod B’s veth interface</li><li>If pod B is on a <strong>different node</strong>: packet enters the Flannel VXLAN tunnel</li></ul><p>For cross-node, Flannel encapsulates:</p><pre>Original packet (source pod to dest pod IP 10.0.3.20)<br>↓<br>Flannel wraps it in UDP:<br>  Outer source: Node A IP (e.g., 35.201.100.50)<br>  Outer dest: Node B IP (e.g., 35.201.100.51)<br>  UDP port: 4789 (VXLAN)<br>  Inner packet: original TCP packet</pre><p>This outer packet travels across the VPC network (GCP, AWS, etc.).</p><h3>Layer 5: VPC/Cloud Network</h3><p><strong>System #6: Cloud Provider’s Network (GCP/AWS/Azure)</strong></p><p>The encapsulated packet traverses the cloud provider’s network. Each provider implements this differently:</p><ul><li><strong>GCP (Google Cloud):</strong> VPC networking with firewall rules. Routes packets between node IPs, evaluates firewall rules to allow UDP 4789 (VXLAN).</li><li><strong>AWS:</strong> Uses Security Groups and NACLs (Network Access Control Lists) to filter traffic between nodes.</li><li><strong>Azure:</strong> Enforces Network Security Groups and route tables.</li></ul><p>In general, for intra-cluster traffic (same availability zone or region):</p><pre>Outer packet route: Node A IP → Node B IP<br>Network overhead: UDP 4789 (VXLAN tunnel port)<br>Latency: ~1-2ms within same zone<br>Packet size: ~20-30 bytes overhead from VXLAN encapsulation</pre><p>If nodes are in different regions or availability zones, latency increases significantly (50–150ms depending on provider and geography).</p><h3>Layer 6: Network Interface Card (NIC) / Receive Path</h3><p><strong>System #7: Destination Node’s Kernel</strong></p><p>The VXLAN-encapsulated packet arrives at Node B’s eth0. The kernel performs three key operations:</p><ol><li><strong>Receives the UDP packet on eth0</strong> — Kernel recognizes UDP port 4789 (VXLAN)</li><li><strong>VXLAN decapsulation</strong> — The kernel module vxlan extracts the inner packet:</li></ol><pre>Removes outer headers (Ethernet, IP, UDP, VXLAN)<br>Exposes inner packet: Src: 10.0.2.15:54321 → Dest: 10.0.3.20:8080</pre><p>3. <strong>Routes to the pod’s veth interface</strong> — Kernel routing table matches destination IP 10.0.3.20 to veth-pod-b:</p><pre># Routing table entry:<br>10.0.3.0/24 dev veth-pod-b onlink<br># Packet forwarded to veth-pod-b (host side of the pair)</pre><p>The decapsulated packet is now ready to enter pod B’s network namespace through the veth pair.</p><h3>Layer 7: Container Destination (Pod Network Interface)</h3><p><strong>System #8: Destination Pod’s Kernel &amp; Container</strong></p><p>The packet enters pod B’s eth0 (the veth pair). The kernel in pod B’s namespace:</p><ol><li>Receives the packet</li><li>Matches it to a listening socket on port 8080</li><li>Wakes up the application (the API server process)</li></ol><p>The application reads the HTTP request and generates a response.</p><h3>The Return Path (Response, 50ms → 0ms)</h3><p>The response packet follows a similar path, but in reverse. Here’s where it gets subtle.</p><pre>Pod B&#39;s app sends HTTP 200 response<br>↓<br>Pod B kernel sends from 10.0.3.20:8080 → 10.0.2.15:54321<br>↓<br>kube-proxy reverse-NAT: 10.0.1.50:8080 ← 10.0.2.15:54321<br>↓<br>Flannel: Encapsulate in VXLAN (if cross-node)<br>↓<br>Cloud network: Route back to Node A<br>↓<br>Node A: Decapsulate VXLAN<br>↓<br>Pod A kernel receives response<br>↓<br>curl process reads the response</pre><h3>Connection Tracking: The Stateful Magic</h3><p><strong>Crucially:</strong> The reverse NAT is tracked via conntrack (connection tracking). The kernel remembers that traffic to 10.0.1.50 belongs to this connection and automatically performs reverse SNAT.</p><p><strong><em>Without conntrack, responses wouldn’t work. Here’s why:</em></strong></p><p>When pod A sends to the service IP (10.0.1.50:8080), iptables rewrites it to the actual pod IP (10.0.3.20:8080). But pod B doesn’t know about the service IP — it only knows it received a packet from 10.0.2.15:54321 on port 8080. When pod B responds, it sends the packet back to 10.0.2.15:54321.</p><p>If there’s no translation, pod A receives:</p><pre>Response: Src: 10.0.3.20:8080 → Dest: 10.0.2.15:54321</pre><p>But pod A’s TCP stack expects:</p><pre>Response: Src: 10.0.1.50:8080 → Dest: 10.0.2.15:54321</pre><p><strong>conntrack solves this:</strong> It remembers the original DNAT transformation and automatically rewrites the response source IP back to 10.0.1.50, making the entire exchange transparent to the application.</p><h3>Same-Node Response Path</h3><p>If pod B is on the <strong>same node</strong> as pod A, the packet never leaves the host. In this case:</p><ol><li><strong>Forward path:</strong> Pod A sends to 10.0.1.50:8080 → iptables rewrites dest to 10.0.3.20:8080 → packet reaches pod B</li><li><strong>conntrack entry created:</strong> Connection remembered with the original service IP</li><li><strong>Reverse path:</strong> Pod B sends response from 10.0.3.20:8080 to 10.0.2.15:54321</li><li><strong>iptables sees the reverse packet:</strong> Checks conntrack, rewrites source from 10.0.3.20:8080 back to 10.0.1.50:8080</li><li><strong>Pod A receives:</strong> The response appears to come from the service IP, exactly as expected</li></ol><h3>Cross-Node Response Path</h3><p>If pod B is on a <strong>different node</strong>, it’s slightly more complex but same principle:</p><ol><li><strong>Forward path:</strong> Pod A sends to 10.0.1.50:8080 → iptables DNAT rewrites to 10.0.3.20:8080 → Flannel encapsulates in VXLAN → sent across network</li><li><strong>conntrack entry on Node A:</strong> Connection tracked with the DNAT transformation</li><li><strong>Pod B receives &amp; responds:</strong> App sends response to 10.0.2.15:54321 → Flannel encapsulates → sent back to Node A</li><li><strong>Node A receives response:</strong> VXLAN decapsulates → conntrack matches the packet to the original DNAT entry → reverse SNAT rewrites source back to 10.0.1.50</li><li><strong>Pod A receives:</strong> Response appears to come from the service IP</li></ol><p>Both paths work because <strong>conntrack remembers the transformation and applies it bidirectionally.</strong></p><h3>The Reason for Bidirectional Tracking</h3><p>You might ask: “Why can’t the responding packet just rewrite itself?”</p><p>The answer is: <strong>TCP’s strict addressing requirements.</strong></p><p>When pod A opens a socket to 10.0.1.50:8080, the TCP layer establishes a connection identified by a 4-tuple:</p><pre>(Source IP: 10.0.2.15, Source Port: 54321, Dest IP: 10.0.1.50, Dest Port: 8080)</pre><p>The TCP state machine stores this 4-tuple and expects all packets belonging to this connection to match it exactly. The kernel maintains this state to:</p><ul><li>Verify that incoming packets belong to an established connection</li><li>Track sequence numbers and ACK numbers</li><li>Ensure packets arrive in order</li><li>Detect and reject out-of-order or duplicate packets</li></ul><p>When pod B’s process sends a response, it has no knowledge of the service IP. It only knows:</p><ol><li>A packet arrived on port 8080 from 10.0.2.15:54321</li><li>The local pod IP is 10.0.3.20</li><li>It needs to send a response back</li></ol><p>So pod B’s response naturally comes from:</p><pre>Source IP: 10.0.3.20, Source Port: 8080<br>Dest IP: 10.0.2.15, Dest Port: 54321</pre><p>But if this response reaches pod A’s TCP stack without rewriting, something breaks:</p><pre>Pod A&#39;s TCP state: Connection (10.0.2.15:54321 ↔ 10.0.1.50:8080)<br>Incoming response: From 10.0.3.20:8080<br><br>TCP layer checks: &quot;Is this packet part of my connection?&quot;<br>- Dest IP matches? Yes (10.0.2.15 ✓)<br>- Dest Port matches? Yes (54321 ✓)<br>- Source IP matches? NO! (Expected 10.0.1.50, got 10.0.3.20 ✗)<br>- Source Port matches? NO! (Expected 8080, got 8080 ✓)<br>Result: Connection is rejected or logged as an error</pre><p><strong>This is why conntrack is essential.</strong> It operates below the application and even below the TCP stack’s view. It remembers:</p><pre>Original connection request: 10.0.2.15:54321 → 10.0.1.50:8080<br>Actual destination after NAT: 10.0.3.20:8080</pre><p>When the response comes back from 10.0.3.20:8080, conntrack recognizes it and rewrites the source IP back to 10.0.1.50 before the TCP stack sees it:</p><pre>Response arrives: 10.0.3.20:8080 → 10.0.2.15:54321<br>Conntrack matches it to the DNAT entry<br>Rewrites to: 10.0.1.50:8080 → 10.0.2.15:54321<br>TCP stack sees: Response from 10.0.1.50:8080 (✓ matches the connection)</pre><p>This rewriting happens in the kernel’s netfilter layer — <strong>before</strong> the packet reaches the application or even the TCP protocol handler. The entire exchange appears perfectly normal to the TCP stack and the application, as if it were talking directly to a pod at 10.0.1.50.</p><p>This is the magic that makes the service abstraction work seamlessly.</p><h3>The 8 Systems That Touched Your Packet</h3><ol><li><strong>Container Runtime</strong> — Set up the isolated network namespace</li><li><strong>CoreDNS</strong> — Resolved my-service to 10.0.1.50</li><li><strong>Pod’s Kernel Network Stack</strong> — Created the TCP socket and SYN packet</li><li><strong>kube-proxy (iptables rules)</strong> — Rewrote the destination to an actual pod IP</li><li><strong>Flannel/CNI</strong> — Encapsulated the packet for cross-node travel (if needed)</li><li><strong>Cloud Provider’s Network</strong> — Routed the outer packet</li><li><strong>Destination Node’s Kernel</strong> — Decapsulated and routed to the destination pod</li><li><strong>Destination Pod’s Container</strong> — Received the packet and processed it</li></ol><p>That brings us to the packet’s journey through a Kubernetes cluster. By composing eight independent systems — DNS, iptables, conntrack, the overlay network, and the cloud provider’s routing — Kubernetes creates an abstraction so seamless that applications never see the complexity underneath.</p><p>The magic isn’t in any single system. It’s in how they coordinate: CoreDNS resolves to a virtual IP, kube-proxy rewrites it to a real one, conntrack remembers the transformation, and the network layer carries it across nodes. Each layer does one thing well, and together they create the illusion of direct pod-to-pod communication.</p><p>The next time you curl a service and get a response in 50ms, remember: that&#39;s not magic. That&#39;s eight systems working in perfect synchrony, orchestrating packets across your infrastructure so your applications never have to think about where anything actually lives.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18db2d47e430" width="1" height="1" alt=""><hr><p><a href="https://medium.com/debugging-diaries/what-happens-when-you-call-a-container-running-on-a-kubernetes-cluster-18db2d47e430">What Happens When You Call a Container Running on a Kubernetes Cluster?</a> was originally published in <a href="https://medium.com/debugging-diaries">Debugging Diaries</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unpacking System X #3: Designing a Scalable Notification Service]]></title>
            <link>https://medium.com/debugging-diaries/unpacking-system-x-3-designing-a-scalable-notification-service-7c9ce47439aa?source=rss----8e1ee92b126e---4</link>
            <guid isPermaLink="false">https://medium.com/p/7c9ce47439aa</guid>
            <category><![CDATA[high-level-design]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Pradyuman]]></dc:creator>
            <pubDate>Sat, 07 Feb 2026 19:02:35 GMT</pubDate>
            <atom:updated>2026-02-07T19:02:34.521Z</atom:updated>
            <content:encoded><![CDATA[<p>Designing a notification system often appears straightforward: producers emit events to a queue, and consumers pick them up to deliver messages across different channels. This approach works well at small scale, but it starts to break down as load increases and traffic becomes bursty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l0Yl5DS2cO3eT7Lt7NdmiA.png" /></figure><p>At the scale of platforms like Instagram, a single action — such as a celebrity posting an update — can trigger millions of notifications at once. If this fan-out isn’t handled carefully, it can easily overwhelm queues, workers, and downstream services, turning a simple feature into a serious scalability problem. In this blog, we’ll focus on how to design notification systems that can survive and operate efficiently under such extreme workloads.</p><h3>1. Understanding the Problem</h3><p>If we break the notification problem down, it naturally splits into two parts. First, we need to receive events from other services without blocking the sender for a long time. Second, we need to deliver notifications through different channels — such as in-app, email, or SMS. These two concerns have very different latency and reliability requirements and should not be tightly coupled.</p><h3>2. High-Level Design</h3><p>Thinking from first principles, the system should absorb events as quickly as possible, while notification delivery can happen asynchronously. An event bus fits this model well: it allows producers to emit events like new posts, likes, or follower additions with minimal overhead. Each event type can be mapped to its own partition, with dedicated worker groups consuming and processing them. These workers then push messages to a separate queue, behind which another set of workers is responsible for delivering notifications to their final destinations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C_7FVunMfW8xXQ2YnQ4rlQ.png" /></figure><p>Let’s start by breaking down the first part of the pipeline. The system receives events from multiple producer services, such as likes, posts, or follower updates. These events are published to the event bus, from where a pool of processor workers consumes them asynchronously. This ensures producers are never blocked and the system can absorb spikes in traffic gracefully.</p><h3>3. Processor Workers (Decision Layer)</h3><p>Processor workers form the core decision-making layer of the notification system. They consume raw events from the event bus and apply all the business logic required to turn an event into a meaningful notification. For each event, they determine <strong>who</strong> should be notified, <strong>what</strong> the notification content should be, and <strong>which channels</strong> should be used for delivery.</p><p>This is also where system-level policies are enforced — such as rate limiting, deduplication, batching, or temporarily dropping notifications when a user has already received too many within a short time window. Once processing is complete, the worker generates a normalized notification request containing the message payload, metadata, and delivery method, and pushes it to the notification queue.</p><h3>4. Delivery Workers (Execution Layer)</h3><p>Delivery workers are responsible for executing the final step: delivering notifications to their intended destinations. They consume pre-processed requests from the notification queue and forward them to the appropriate channels such as in-app push, email, or SMS.</p><p>Unlike processor workers, delivery workers are intentionally kept simple. They do not perform any business logic or decision-making. Their responsibilities are limited to making network calls, handling retries, and dealing with transient failures or third-party outages. This separation ensures that delivery issues never impact event processing and allows each delivery channel to scale, fail, and recover independently.</p><p>That brings us to the high-level design of a scalable notification service. By clearly separating event ingestion, decision-making, and delivery into independent layers, the system remains resilient under bursty workloads while staying simple to reason about and evolve. With this structure, the system can safely absorb millions of events per minute without coupling producer latency to notification delivery.</p><p>As scale and requirements grow, additional optimizations — such as smarter fan-out strategies, per-channel rate limiting, or deeper delivery guarantees — can be layered onto this foundation without changing the core design. This makes the system not just scalable today, but adaptable for the long term.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c9ce47439aa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/debugging-diaries/unpacking-system-x-3-designing-a-scalable-notification-service-7c9ce47439aa">Unpacking System X #3: Designing a Scalable Notification Service</a> was originally published in <a href="https://medium.com/debugging-diaries">Debugging Diaries</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unpacking System X #2: Designing a Parking Lot]]></title>
            <link>https://medium.com/debugging-diaries/unpacking-system-x-2-designing-a-parking-lot-4c7e5edb09fa?source=rss----8e1ee92b126e---4</link>
            <guid isPermaLink="false">https://medium.com/p/4c7e5edb09fa</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[lld]]></category>
            <dc:creator><![CDATA[Pradyuman]]></dc:creator>
            <pubDate>Wed, 04 Feb 2026 05:10:29 GMT</pubDate>
            <atom:updated>2026-02-04T05:10:27.961Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to the second part of <em>Unpacking System Design</em>. This time, I picked one of the most frequently asked problems in <strong>LLD interviews</strong> and tried to solve it under a <strong>strict 50-minute time constraint</strong>.</p><p>The idea was simple: simulate a real interview scenario. Limited time forces you to think faster, make trade-offs, and decide what actually matters. You don’t get the luxury of building the “perfect” design — you have to prioritize, skip non-essential features, and still ship something that works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3piB8xnhMkK6UletyjM4eA.png" /></figure><p><em>Spoiler alert:</em> the first iteration was far from perfect — and that’s exactly the point.</p><h3>Scoping the Problem</h3><p>Once the problem statement was clear, the next step was to <strong>lock the scope</strong>. In LLD rounds, scope control is half the battle. Over-engineering is just as dangerous as under-designing.</p><p>For this iteration, I consciously limited the system to the following features:</p><ul><li><strong>Three types of parking slots</strong>: Bike, Car, and Jeep</li><li><strong>Single-floor parking lot</strong> (no multi-floor complexity — for now)</li><li><strong>Availability check</strong> for parking spots</li><li><strong>Ticket generation at check-in</strong></li><li><strong>Exit using the ticket</strong>, with total parking cost calculation</li></ul><p>Everything else — dynamic pricing, multiple entry/exit gates, persistence, concurrency handling — was intentionally left out to stay within time.</p><h3>Iteration 1: What I built under time pressure</h3><p>In the first iteration, I tried to code everything <strong>in one go</strong>, without overthinking abstractions. The objective was to move fast and cover the core flows within the time limit.</p><p>I was able to implement three major features. Below, I’ll walk through each feature and show the exact code used to support it.</p><h3>1. Three Types of Parking Slots</h3><p>Although the problem statement talked about <strong>Bike, Car, and Jeep</strong>, I internally modeled them as <strong>Small, Medium, and Large</strong> parking slots. At this stage, I optimized for speed rather than correctness of domain modeling, which led to inconsistent representations across the codebase.</p><h4>Slot Definition</h4><pre>type parkingSlot struct {<br>    ID             string<br>    AllowedVehicle string<br>    Occupied       bool<br>    OccupiedBy     *string<br>}</pre><p>Each slot stores:</p><ul><li>Its unique ID</li><li>The allowed vehicle type (as a string)</li><li>Occupancy state</li><li>Registration number of the parked vehicle</li></ul><h4>Slot Creation by Type</h4><pre>func createParkingSlots(size int, typ string) []parkingSlot {<br>    ps := make([]parkingSlot, 0)<br>    for i := range size {<br>        newSlot := parkingSlot{<br>            ID:             typ + &quot;-&quot; + fmt.Sprint(i),<br>            AllowedVehicle: typ,<br>            Occupied:       false,<br>        }<br>        ps = append(ps, newSlot)<br>    }<br>    return ps<br>}</pre><p>Here:</p><ul><li>Slot types are passed as strings (&quot;sm&quot;, &quot;md&quot;, &quot;lg&quot;)</li><li>Slot IDs are generated using the same string representation</li></ul><p>This worked functionally, but mixing representations (&quot;S&quot; vs &quot;sm&quot;) later became a source of confusion.</p><h3>2. Single-Floor Parking Initialization</h3><p>To keep the design simple, I limited the parking lot to <strong>a single floor</strong>. Internally, I represented the parking lot as a slice of slot groups, where <strong>each index implicitly mapped to a slot type</strong>.</p><pre>func createParking(sm, md, lg int) [][]parkingSlot {<br>    parking := make([][]parkingSlot, 0)<br>    parking = append(parking, createParkingSlots(sm, &quot;sm&quot;))<br>    parking = append(parking, createParkingSlots(md, &quot;md&quot;))<br>    parking = append(parking, createParkingSlots(lg, &quot;lg&quot;))<br>    return parking<br>}</pre><p>This introduced a hidden contract:</p><ul><li>Index 0 → Small slots</li><li>Index 1 → Medium slots</li><li>Index 2 → Large slots</li></ul><p>While simple to implement, this made the code harder to read and tightly coupled slot behavior to ordering.</p><h3>3. Availability Check</h3><p>To check availability, I used a <strong>linear scan</strong> over all slots of a particular type and counted the unoccupied ones.</p><pre>func availableSlots(ps *[]parkingSlot) int {<br>    count := 0<br>    for _, p := range *ps {<br>        if !p.Occupied {<br>            count++<br>        }<br>    }<br>    return count<br>}</pre><p>This approach is:</p><ul><li>Easy to reason about</li><li>Efficient enough for small inputs</li><li>Not ideal for scaling or frequent queries</li></ul><p>At this stage, simplicity was prioritized over optimization.</p><h3>4. Slot Allocation (Check and Occupy)</h3><p>Once availability was confirmed, the first unoccupied slot was assigned to the vehicle.</p><h4>Occupying a Slot</h4><pre>func occupySlot(ps *[]parkingSlot, regNumber string) string {<br>    for i := range *ps {<br>        if !(*ps)[i].Occupied {<br>            (*ps)[i].Occupied = true<br>            (*ps)[i].OccupiedBy = &amp;regNumber<br>            return (*ps)[i].ID<br>        }<br>    }<br>    return &quot;&quot;<br>}</pre><p>This function:</p><ul><li>Mutates slot state directly</li><li>Uses a first-available allocation strategy</li><li>Relies on passing slices by reference to persist state</li></ul><h4>Mapping Vehicle Type to Slot Group</h4><pre>func checkAndOccupy(parking *[][]parkingSlot, typ, regNumber string) (*string, error) {<br>    var ind int<br>    switch typ {<br>    case &quot;S&quot;:<br>        ind = 0<br>    case &quot;M&quot;:<br>        ind = 1<br>    case &quot;L&quot;:<br>        ind = 2<br>    }<br>    if availableSlots(&amp;(*parking)[ind]) == 0 {<br>        return nil, fmt.Errorf(&quot;No Slot available&quot;)<br>    }<br>    slot := occupySlot(&amp;(*parking)[ind], regNumber)<br>    return &amp;slot, nil<br>}</pre><p>This is where multiple early design decisions come together:</p><ul><li>String-based vehicle typing</li><li>Index-based slot classification</li><li>Direct mutation of internal structures</li></ul><p>While effective, this logic became increasingly brittle as the system grew.</p><h3>5. Passing State by Reference</h3><p>Throughout the implementation, I deliberately passed slices and structures <strong>by reference</strong> to ensure:</p><ul><li>Slot occupancy updates were reflected correctly</li><li>No accidental value copies occurred</li><li>Additional memory allocation was avoided</li></ul><p>Although technically correct, this approach increased coupling and exposed internal state more than necessary — something I fixed in later iterations.</p><h3>Why This Version Hit a Wall</h3><p>By the end of the first iteration, it was clear that:</p><ul><li>Adding ticketing and pricing would require refactoring most functions</li><li>Index- and string-based logic did not scale</li><li>The lack of domain abstractions made extension risky</li></ul><p>This realization led to <strong>Iteration 2</strong>, where the focus shifted from speed to structure.</p><h3>Iteration 2: Slowing Down to Design It Right</h3><p>After finishing the first iteration, one thing was clear:</p><blockquote>adding more features on top of that code would mean fighting the design instead of extending it.</blockquote><p>So for the second iteration, I consciously slowed down. The goal shifted from <em>“get it working”</em> to <em>“make it evolvable”</em> — while still keeping the scope interview-friendly.</p><p>Below are the key improvements and the code that enabled them.</p><h3>1. Tickets as a First-Class Concept</h3><p>In this iteration, entry into the parking lot no longer just returns a slot number. Instead, the system generates a <strong>ticket</strong> that represents the entire parking lifecycle.</p><pre>type Ticket struct {<br>	ID        string<br>	RegNumber string<br>	SlotNo    string<br>	VehType   string<br>	Time      time.Time<br>}</pre><p>A ticket captures everything required at exit time:</p><ul><li>Which vehicle entered</li><li>Where it was parked</li><li>What type it was</li><li>When it entered</li></ul><p>Ticket creation is centralized:</p><pre>func NewTicket(regNo, slotNo, vehType string) *Ticket {<br>	return &amp;Ticket{<br>		ID:        slotNo + &quot;_&quot; + regNo,<br>		RegNumber: regNo,<br>		SlotNo:    slotNo,<br>		VehType:   vehType,<br>		Time:      time.Now(),<br>	}<br>}</pre><p>This single abstraction removed a lot of hidden coupling that existed in Iteration 1.</p><h3>2. Explicit Pricing Model</h3><p>Pricing is no longer implicit or hardcoded inside logic paths. Each vehicle type now has a clearly defined hourly rate.</p><pre>var priceChart = map[string]float64{<br>	&quot;Bike&quot;: 0.1,<br>	&quot;Car&quot;:  0.3,<br>	&quot;Jeep&quot;: 0.5,<br>}</pre><p>This makes pricing:</p><ul><li>Easy to reason about</li><li>Easy to change</li><li>Ready for future extensions (slabs, dynamic pricing, etc.)</li></ul><h3>3. Parking Slot as a Proper Entity</h3><p>Slots are no longer anonymous entries in a slice.</p><pre>type ParkingSlot struct {<br>	ID       string<br>	Occupied bool<br>	SlotType string<br>}</pre><p>Creation is encapsulated behind a constructor:</p><pre>func NewParkingSlot(id, slotType string) *ParkingSlot {<br>	return &amp;ParkingSlot{<br>		ID:       id,<br>		Occupied: false,<br>		SlotType: slotType,<br>	}<br>}</pre><p>This makes slot identity explicit and separates <strong>what a slot is</strong> from <strong>how it is stored</strong>.</p><h3>4. Parking Lot Modeled Using Maps</h3><p>The parking lot is now represented as:</p><pre>map[string][]*ParkingSlot</pre><p>Initialization becomes self-describing and removes index-based assumptions.</p><pre>func createParking(capacity map[string]int) map[string][]*ParkingSlot {<br>	res := make(map[string][]*ParkingSlot)<br>	for typ, count := range capacity {<br>		var pk []*ParkingSlot<br>		for i := range count {<br>			pk = append(pk, NewParkingSlot(typ+&quot;_&quot;+fmt.Sprint(i), typ))<br>		}<br>		res[typ] = pk<br>	}<br>	return res<br>}</pre><p>This design:</p><ul><li>Improves readability</li><li>Makes adding new vehicle types trivial</li><li>Eliminates hidden contracts based on ordering</li></ul><h3>5. Availability Checks as Standalone Operations</h3><p>Availability is now a clean query, independent of allocation.</p><pre>func checkAvailability(typ string, parking map[string][]*ParkingSlot) bool {<br>	for _, slot := range parking[typ] {<br>		if !slot.Occupied {<br>			return true<br>		}<br>	}<br>	return false<br>}</pre><p>Slot counts are also queryable directly:</p><pre>func countAvailableSlots(typ string, parking map[string][]*ParkingSlot) int {<br>	count := 0<br>	for _, slot := range parking[typ] {<br>		if !slot.Occupied {<br>			count++<br>		}<br>	}<br>	return count<br>}</pre><p>This separation made the system easier to extend and test.</p><h3>6. Slot Allocation with Ticket Generation</h3><p>Slot allocation now does more than just mark occupancy.</p><pre>func allotSlot(typ, regNumber string, parking map[string][]*ParkingSlot) *Ticket {<br>	for _, ps := range parking[typ] {<br>		if !ps.Occupied {<br>			ps.Occupied = true<br>			ticket := NewTicket(regNumber, ps.ID, typ)<br>			tickets[ticket.ID] = ticket<br>			return ticket<br>		}<br>	}<br>	return nil<br>}</pre><p>This flow cleanly ties:<br><strong>entry → slot allocation → ticket issuance</strong></p><h3>7. Exit Flow and Cost Calculation</h3><p>Exiting the parking lot now becomes a well-defined operation.</p><pre>func vacateSlot(ticketID string, parking map[string][]*ParkingSlot) float64 {<br>   ticket := tickets[ticketID]<br>   delete(tickets, ticketID)<br>   timeElapsed := math.Ceil(time.Since(ticket.Time).Hours())<br>   price := timeElapsed * priceChart[ticket.VehType]<br>   for _, ps := range parking[ticket.VehType] {<br>      if ps.ID == ticket.SlotNo {<br>         ps.Occupied = false<br>      }<br>   }<br>   return price<br>}</pre><p>This function:</p><ol><li>Resolves the ticket</li><li>Calculates time spent</li><li>Computes the parking fee</li><li>Frees the slot</li></ol><p>Each responsibility is explicit and traceable.</p><h3>Where This Iteration Still Draws the Line</h3><p>Even in Iteration 2, some features remain intentionally out of scope:</p><ul><li>Concurrency handling</li><li>Persistence</li><li>Multiple floors — Although easily extendable for this</li><li>Allocation strategies</li><li>Multiple entry/exit gates</li></ul><p>Those belong to a different level of complexity — and possibly a different interview.</p><p>This exercise was less about building a parking lot system and more about understanding <strong>how design decisions change under constraints</strong>.</p><p>In <strong>Iteration 1</strong>, the focus was speed. I coded whatever came to mind, optimized for getting something functional within a limited time window. That approach helped me cover the core flows quickly, but it also exposed several design issues — stringly-typed logic, index-based assumptions, and tightly coupled responsibilities.</p><p>In <strong>Iteration 2</strong>, I slowed down and addressed those shortcomings. By introducing clearer domain abstractions like Ticket and ParkingSlot, modeling parking using maps instead of indices, and separating availability, allocation, and pricing concerns, the system became far easier to extend and reason about.</p><p>A few important lessons stood out:</p><ul><li><strong>Working code is not the same as good design</strong><br>A solution can function correctly and still be hard to evolve.</li><li><strong>Constraints shape architecture</strong><br>Time pressure pushes you toward shortcuts; recognizing and fixing them later is a valuable skill.</li><li><strong>Domain modeling matters in LLD</strong><br>Clear entities and responsibilities reduce complexity more than clever logic.</li><li><strong>Trade-offs should be intentional</strong><br>Skipping features is fine — as long as you know why you’re skipping them.</li></ul><p>Most importantly, this exercise reinforced that <strong>LLD interviews are not about finishing every feature</strong>, but about demonstrating how you think, prioritize, and improve your design.</p><p>If you’re preparing for system design interviews, I highly recommend practicing this way:</p><blockquote>build fast, reflect honestly, and then refactor with intent.</blockquote><p>That process mirrors real-world engineering far better than chasing a “perfect” first solution.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c7e5edb09fa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/debugging-diaries/unpacking-system-x-2-designing-a-parking-lot-4c7e5edb09fa">Unpacking System X #2: Designing a Parking Lot</a> was originally published in <a href="https://medium.com/debugging-diaries">Debugging Diaries</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unpacking System X #1: Designing a Rate Limiter]]></title>
            <link>https://medium.com/debugging-diaries/unpacking-system-x-1-designing-a-rate-limiter-213f5b29fc78?source=rss----8e1ee92b126e---4</link>
            <guid isPermaLink="false">https://medium.com/p/213f5b29fc78</guid>
            <category><![CDATA[rate-limiting]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <dc:creator><![CDATA[Pradyuman]]></dc:creator>
            <pubDate>Sun, 01 Feb 2026 05:10:58 GMT</pubDate>
            <atom:updated>2026-02-01T05:10:57.666Z</atom:updated>
            <content:encoded><![CDATA[<h3>Problem Statement</h3><blockquote>I have launched a backend service to serve my customers over the internet. However, the service is receiving a large number of unwanted and automated requests that are not generated by genuine users. These requests consume system resources such as CPU, memory, and network bandwidth, causing increased latency and occasional unavailability for legitimate users. The goal is to design a mechanism that protects the service from excessive or abusive traffic while ensuring that genuine users continue to receive reliable and low-latency responses.</blockquote><p>Like most backend systems, this service has a hard limit on how much traffic it can process concurrently. When that limit is exceeded, the system starts failing the very users it was built for. This makes it essential to control incoming traffic and prevent unwanted requests from consuming critical resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H_qKYE1JjgpP2ylI6Gka-A.png" /><figcaption>Rate Limiter</figcaption></figure><h3>Requirements</h3><p>To reason about a concrete solution, we need to move from vague requirements to explicit numbers. Defining realistic constraints helps us understand the scale of the system and guides our design decisions.</p><p>For this system, we’ll assume the following:</p><ul><li><strong>Maximum requests the service can handle:</strong> 1 million requests per second</li><li><strong>Maximum requests a genuine user can generate:</strong> 100 requests per second</li><li><strong>Target latency:</strong> 100 ms per request</li></ul><p>These numbers are representative of a real-world, internet-facing backend service and provide a clear picture of the traffic volume and performance expectations we are designing for. While these numbers represent peak traffic, we’ll start with a simpler design and gradually evolve it to handle this scale.</p><p>With these constraints in mind, we can now start exploring mechanisms to control incoming traffic and protect the system from overload.</p><h3>Constraints</h3><p>Before jumping into the solution, it’s important to draw clear boundaries around the problem we are trying to solve. Without these boundaries, the design can quickly expand into areas that are interesting — but not immediately relevant.</p><p>For this first iteration, I’ll assume that all users are operating within a single geographic region. This allows us to focus on request control without worrying about cross-region coordination or consistency issues. The backend service itself is not a latency-critical system like a heavily contended database or a high-frequency trading exchange, which gives us some flexibility in how we enforce limits.</p><p>Another important assumption is that rejecting requests which exceed the allowed rate does not affect the correctness or internal state of the service. In other words, dropping or delaying excess requests is safe and does not require compensating actions or rollbacks.</p><p>The rate limiting mechanism itself will operate with best-effort accuracy. Occasional minor deviations are acceptable as long as the system remains highly available and fast. Each incoming request carries reliable client-identifying information, allowing limits to be enforced on a per-user basis rather than globally.</p><p>Finally, it’s worth clarifying what this system is not trying to do. This design focuses purely on controlling request rates. It does not attempt to detect malicious behavior, block IP addresses, or perform advanced abuse prevention. Those concerns are important, but they fall outside the scope of this problem.</p><p>With the problem clearly defined and its boundaries in place, we can now start thinking about how to design a system that enforces these limits effectively.</p><h3>Naive Approach: Global Request Capping</h3><p>The most straightforward way to protect a backend service from overload is to cap the total number of requests it processes. Since our service can handle up to 1 million requests per second, we could simply drop any requests that arrive after this threshold is reached within a given second.</p><p>This can be implemented directly inside the backend using a simple middleware. The middleware maintains a global request counter and rejects any request once the configured limit is exceeded. From an implementation perspective, this approach is fast, easy to reason about, and requires no additional infrastructure.</p><p>However, this simplicity comes at a cost.</p><p>Because the limit is global, the system has no notion of <em>who</em> is sending the requests. All traffic is treated equally. If a large portion of incoming requests originates from unwanted or abusive clients, they can consume most — or even all — of the available capacity. Legitimate user requests may then arrive after the global limit has already been reached and get dropped, despite being the users the system is intended to serve.</p><p>In effect, the backend remains busy processing unwanted traffic while genuine users experience failures or degraded service. While this approach prevents the system from crashing under load, it fails to achieve the more important goal of fairness.</p><h3>Moving Beyond a Global Limit</h3><p>To address this problem, the next logical step is to move away from a single global cap and start tracking request rates on a per-user basis. This ensures that no individual user can monopolize system capacity at the expense of others.</p><p>Although this logic could still be implemented as middleware within the backend service, doing so would add overhead to the critical request path and further couple rate limiting with business logic. A cleaner approach is to move this responsibility into a dedicated rate-limiting component.</p><p>At its core, this component performs a simple task: it tracks how many requests each user makes over time and decides whether a new request should be allowed or rejected. The key difference lies in <em>how</em> this tracking is done and <em>how</em> limits are enforced.</p><p>This is where different rate limiting algorithms come into play.</p><h3>Algorithms</h3><p>As I started looking into existing rate limiting algorithms, I realized how far first-principles thinking can take you — even without knowing the formal terminology upfront. The ideas we arrived at earlier were not new; they were simply informal versions of well-known approaches.</p><p>In fact, the naive solution discussed earlier closely resembles what is commonly known as the <strong>Token Bucket algorithm</strong>. While it was initially framed in terms of simple counters and limits, the underlying idea is the same: requests consume capacity, and that capacity is replenished over time.</p><p>In the next sections, we’ll take a closer look at the Token Bucket algorithm, understand how it works in practice, and explore why it is such a common choice for rate limiting systems.</p><ol><li><strong>Token Bucket Algorithm</strong></li></ol><p>The Token Bucket algorithm limits request rates using a simple capacity-based model. Each bucket holds a fixed number of tokens, which are added at a constant rate up to a maximum capacity. When a request arrives, it consumes a token if one is available; otherwise, the request is rejected. This approach limits the average request rate while still allowing short bursts when tokens have accumulated. For fairness, the same mechanism is typically applied per user by maintaining an independent bucket for each client.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dfd0Ef8gp4i5UtKhJgfrZw.png" /><figcaption>Token Bucket</figcaption></figure><p>Below is pseudocode that demonstrates this approach.</p><pre>class TokenBucket:<br>    def __init__(self, capacity, refill_rate):<br>        self.capacity = capacity            # max tokens<br>        self.tokens = capacity               # current tokens<br>        self.refill_rate = refill_rate       # tokens per second<br>        self.last_refill = time.time()<br><br>    def refill(self):<br>        now = time.time()<br>        elapsed = now - self.last_refill<br><br>        # add tokens based on elapsed time<br>        new_tokens = elapsed * self.refill_rate<br>        self.tokens = min(self.capacity, self.tokens + new_tokens)<br>        self.last_refill = now<br><br>    def allow_request(self):<br>        self.refill()<br><br>        if self.tokens &gt;= 1:<br>            self.tokens -= 1<br>            return True    <br>        return False     <br><br><br>class RateLimiter:<br>    def __init__(self):<br>        self.buckets = {}   # one bucket per user<br><br>    def allow_request(self, user_id):<br>        if user_id not in self.buckets:<br>            self.buckets[user_id] = TokenBucket(<br>                capacity=100,<br>                refill_rate=100<br>            )<br><br>        bucket = self.buckets[user_id]<br>        return bucket.allow_request()</pre><p><strong><em>Pros</em></strong></p><ul><li>Simple to understand and relatively easy to implement.</li><li>Allows short bursts of traffic up to the bucket’s capacity, making it well suited for handling brief spikes without immediately rejecting requests.</li></ul><p><strong><em>Cons</em></strong></p><ul><li>When implemented on a per-user basis, memory usage grows with the number of active users.</li><li>Does not guarantee a perfectly smooth request rate; bursts are allowed as long as tokens are available.</li></ul><p><strong>2. Leaky Bucket Algorithm</strong></p><p>The Leaky Bucket algorithm enforces a constant request rate by smoothing incoming traffic. Incoming requests are added to a conceptual bucket, while requests leave the bucket at a fixed rate that represents the maximum throughput the backend can handle. If requests arrive faster than this rate, the bucket begins to fill. Once it reaches its capacity, any new requests are dropped.</p><p>By allowing requests to drain at a steady pace, the Leaky Bucket algorithm buffers short bursts while ensuring the backend receives traffic at a controlled, predictable rate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I4aQmL7RbP267oCqjXyH2g.png" /></figure><pre>class LeakyBucket:<br>    def __init__(self, capacity, leak_rate):<br>        self.capacity = capacity          # max number of requests in buffer<br>        self.leak_rate = leak_rate        # requests processed per second<br>        self.queue = deque()              # buffered requests<br>        self.last_leak = time.time()<br><br>    def leak(self):<br>        now = time.time()<br>        elapsed = now - self.last_leak<br><br>        # number of requests that can be processed in this time window<br>        allowed = int(elapsed * self.leak_rate)<br><br>        for _ in range(min(allowed, len(self.queue))):<br>            self.queue.popleft()<br><br>        if allowed &gt; 0:<br>            self.last_leak = now<br><br>    def allow_request(self):<br>        self.leak()<br><br>        if len(self.queue) &lt; self.capacity:<br>            self.queue.append(time.time())<br>            return True     # request accepted (buffered)<br>        return False        # bucket full, request dropped</pre><p><strong><em>Pros</em></strong></p><ul><li>Enforces a smooth and constant request rate, protecting the backend from traffic spikes.</li><li>Predictable behavior that makes system load easy to reason about.</li></ul><p><strong><em>Cons</em></strong></p><ul><li>Does not allow traffic bursts, even when the system has spare capacity.</li><li>Requests may experience added latency or be dropped during sustained high load.</li></ul><p><strong>3. Fixed Window Counter Algorithm</strong></p><p>This algorithm divides time into fixed windows, where each window is allowed to process only a limited number of requests. At the start of every window, a counter is reset to zero and incremented for each incoming request. Once the counter exceeds the configured limit, any additional requests within that window are rejected until the next window begins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c15lQRjqhpSH_5aD4XHs4Q.png" /></figure><pre>class FixedWindowRateLimiter:<br>    def __init__(self, limit, window_size):<br>        self.limit = limit                  # max requests per window<br>        self.window_size = window_size      # window duration in seconds<br>        self.counter = {}                   # requests per user<br>        self.window_start = time.time()<br><br>    def allow_request(self, user_id):<br>        now = time.time()<br><br>        # move to next window if current window expired<br>        if now - self.window_start &gt;= self.window_size:<br>            self.counter.clear()<br>            self.window_start = now<br><br>        # initialize counter for user<br>        if user_id not in self.counter:<br>            self.counter[user_id] = 0<br><br>        # check limit<br>        if self.counter[user_id] &lt; self.limit:<br>            self.counter[user_id] += 1<br>            return True     # request allowed<br><br>        return False        # rate limit exceeded</pre><p><strong><em>Pros</em></strong></p><ul><li>Simple to implement and easy to understand.</li><li>Efficient in terms of memory and computation.</li></ul><p><strong><em>Cons</em></strong></p><ul><li>Allows traffic bursts at window boundaries, leading to uneven request rates.</li><li>Can be unfair to users whose requests arrive near the end of a window.</li></ul><p><strong>4. Sliding Window Log Algorithm</strong></p><p>This algorithm uses a sliding time window instead of fixed intervals. It maintains a moving window of a given duration and tracks all requests that occur within that window. When a new request arrives, any requests that fall outside the current window are removed. If the number of remaining requests is below the configured limit, the request is allowed; otherwise, it is rejected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1D_3I90r6_0BPkK7JRa4vQ.png" /></figure><pre>class SlidingWindowLog:<br>    def __init__(self, limit, window_size):<br>        self.limit = limit                  # max requests in window<br>        self.window_size = window_size      # window duration in seconds<br>        self.requests = {}                  # per-user request timestamps<br><br>    def allow_request(self, user_id):<br>        now = time.time()<br><br>        if user_id not in self.requests:<br>            self.requests[user_id] = deque()<br><br>        window = self.requests[user_id]<br><br>        # remove requests outside the sliding window<br>        while window and window[0] &lt;= now - self.window_size:<br>            window.popleft()<br><br>        # check if under limit<br>        if len(window) &lt; self.limit:<br>            window.append(now)<br>            return True     # request allowed<br><br>        return False        # rate limit exceeded</pre><p><strong><em>Pros</em></strong></p><ul><li>Provides accurate rate limiting without boundary spikes.</li><li>Fairly enforces limits by considering only recent requests within the window.</li></ul><p><strong><em>Cons</em></strong></p><ul><li>Memory usage grows with the number of requests stored per user.</li><li>Higher computational overhead due to frequent timestamp cleanup.</li></ul><p><strong>5. Sliding Window Counter Algorithm</strong></p><p>This algorithm combines the Fixed Window Counter and Sliding Window Log approaches to provide better accuracy with lower overhead. Instead of storing timestamps for every request, it tracks only the request counts for the current and previous windows. When a request arrives, a weighted sum is calculated based on how much of the sliding window overlaps with each fixed window. If the weighted sum plus the new request exceeds the configured limit, the request is rejected; otherwise, it is allowed.</p><p>To make this concrete, consider a rate limit of 100 requests per minute. If the current time is 75% into the active window, then 25% of the sliding window overlaps with the previous minute. Suppose the previous window saw 80 requests and the current window has seen 40 so far. The effective request count is calculated as 0.25 × 80 + 40 = 60</p><p>Since adding a new request keeps the total below the limit, the request is allowed. This approximation closely matches a true sliding window while avoiding the cost of tracking individual request timestamps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EnmIvGlSc15S0HirxqDIZA.png" /></figure><pre>class SlidingWindowCounter:<br>    def __init__(self, limit, window_size):<br>        self.limit = limit                  # max requests per window<br>        self.window_size = window_size      # window duration in seconds<br>        self.current_window = {}            # current window request count per user<br>        self.previous_window = {}           # previous window request count per user<br>        self.window_start = time.time()<br><br>    def allow_request(self, user_id):<br>        now = time.time()<br>        elapsed = now - self.window_start<br><br>        # move to next window if needed<br>        if elapsed &gt;= self.window_size:<br>            self.previous_window = self.current_window<br>            self.current_window = {}<br>            self.window_start = now<br>            elapsed = 0<br><br>        # progress in current window (0.0 to 1.0)<br>        progress = elapsed / self.window_size<br><br>        prev_count = self.previous_window.get(user_id, 0)<br>        curr_count = self.current_window.get(user_id, 0)<br><br>        # weighted request count<br>        effective_count = (1 - progress) * prev_count + curr_count<br><br>        # check limit<br>        if effective_count + 1 &gt; self.limit:<br>            return False    # rate limit exceeded<br><br>        # allow request<br>        self.current_window[user_id] = curr_count + 1<br>        return True</pre><p><strong><em>Pros</em></strong></p><ul><li>Approximates a true sliding window without storing individual request timestamps.</li><li>More memory- and compute-efficient than the Sliding Window Log approach.</li></ul><p><strong><em>Cons</em></strong></p><ul><li>Less accurate than a true sliding window under highly bursty traffic.</li><li>Slightly more complex to implement and reason about compared to fixed windows.</li></ul><p>With that, we’ve covered most of the commonly used rate limiting algorithms, and the article has already grown longer than intended — so I’ll stop here rather than overload you. In the next article, <strong>Unpacking System X #2: Designing a Parking Lot</strong>, I’ll switch gears and walk through a low-level design (LLD) of a Parking Lot system.</p><p>If you found this useful, feel free to leave a clap. I’ll be sharing more write-ups like this as part of <em>Debug Diaries</em>, where I break down system design topics through first-principles thinking.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=213f5b29fc78" width="1" height="1" alt=""><hr><p><a href="https://medium.com/debugging-diaries/unpacking-system-x-1-designing-a-rate-limiter-213f5b29fc78">Unpacking System X #1: Designing a Rate Limiter</a> was originally published in <a href="https://medium.com/debugging-diaries">Debugging Diaries</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing ‘Unpacking System X’: A New System Design Journey]]></title>
            <link>https://medium.com/debugging-diaries/introducing-unpacking-system-x-a-new-system-design-journey-68a7c29dd7e9?source=rss----8e1ee92b126e---4</link>
            <guid isPermaLink="false">https://medium.com/p/68a7c29dd7e9</guid>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[high-level-design]]></category>
            <category><![CDATA[first-principles-thinking]]></category>
            <dc:creator><![CDATA[Pradyuman]]></dc:creator>
            <pubDate>Mon, 26 Jan 2026 16:59:45 GMT</pubDate>
            <atom:updated>2026-01-26T16:59:44.579Z</atom:updated>
            <content:encoded><![CDATA[<p>System design is one of those skills that only really improves when you think out loud, make mistakes, and revisit your assumptions. While I regularly solve design problems, I’ve realized I rarely document <em>how</em> my thinking evolves over time. This series is an attempt to change that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*awmOb9IIOXdnp_JWf-SnpA.png" /></figure><p><strong>Unpacking System X</strong> is a system design series where I take one problem at a time and break it down from first principles. Each post focuses on a single “System X” — for example, a rate limiter, notification service, logging pipeline, or URL shortener — and explores the trade-offs, constraints, and decisions involved in designing it.</p><p>These designs won’t be perfect or “final.” That’s intentional.</p><p>I plan to treat each system as a <strong>living document</strong>. As my understanding deepens, as I come across better patterns, or as I receive feedback from others, I’ll revisit older designs and evolve them. When that happens, I’ll explicitly call out what changed, why the new approach is better, and what I misunderstood or overlooked earlier. The goal isn’t to present a polished or “final” design, but to capture the journey of reasoning that leads there.</p><p>This series is meant for engineers preparing for system design interviews, backend developers who want to sharpen their design thinking, and for me — as a way to build depth through writing and reflection. If you enjoy reasoning about trade-offs, constraints, and architectural choices, you’ll probably enjoy following along.</p><h3>What’s first?</h3><p><strong>Unpacking System X #1: Designing a Rate Limiter</strong></p><p>I’ll start simple and build it up step by step.</p><p>If you have suggestions for future “System X” topics, I’d love to hear them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68a7c29dd7e9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/debugging-diaries/introducing-unpacking-system-x-a-new-system-design-journey-68a7c29dd7e9">Introducing ‘Unpacking System X’: A New System Design Journey</a> was originally published in <a href="https://medium.com/debugging-diaries">Debugging Diaries</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Under the Hood: What Powers a Never-Fail Checkout?]]></title>
            <link>https://medium.com/debugging-diaries/under-the-hood-what-powers-a-never-fail-checkout-eb660a08b060?source=rss----8e1ee92b126e---4</link>
            <guid isPermaLink="false">https://medium.com/p/eb660a08b060</guid>
            <category><![CDATA[payment-gateway-failover]]></category>
            <category><![CDATA[payment-orchestration]]></category>
            <category><![CDATA[optimize-payment-costs]]></category>
            <category><![CDATA[prevent-checkout-errors]]></category>
            <category><![CDATA[dynamic-payment-routing]]></category>
            <dc:creator><![CDATA[Pradyuman]]></dc:creator>
            <pubDate>Mon, 21 Jul 2025 12:30:37 GMT</pubDate>
            <atom:updated>2025-07-20T17:01:06.109Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever noticed how your Zomato payments rarely fail? For example, I usually pay via PayU. Still, the other day, my UPI transaction was routed through Razorpay , and yet I never saw a hitch. Naturally, I wondered: has Zomato switched gateways? It turns out there’s no single “<em>official</em>” move from PayU to Razorpay. Instead, Zomato (like other high-frequency platforms such as Swiggy) sits behind a <strong>payment orchestration layer</strong> that intelligently balances multiple gateway integrations to maximize success rates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pTuHeG4b_qkWErUNSTQLTw.png" /><figcaption>Payment Orchestration</figcaption></figure><h3>What Is Payment Orchestration?</h3><p>Payment orchestration is a middleware layer that sits between your frontend checkout and various payment providers. Rather than hard-coding a single gateway, you:</p><ol><li><strong>Integrate once</strong> with the orchestration platform</li><li><strong>Configure</strong> which gateways you want to use (e.g. <em>PayU</em>, <em>Razorpay</em>, <em>JusPay</em>, etc.)</li><li><strong>Define routing rules</strong> and fallbacks at a business level</li></ol><p>The orchestration engine then dynamically decides where to send each transaction, based on real-time metrics and your own policies.</p><h3>Key Capabilities</h3><ul><li><strong>Dynamic Routing</strong><br>Every transaction is steered to the gateway with the best real-time success rate. If PayU starts lagging, it smoothly switches to Razorpay — no extra clicks, no failed orders.</li><li><strong>24/7 Health Checks &amp; Failover</strong><br>The system continuously “<em>pings</em>” each provider. The moment one chokes or goes offline, all traffic instantly reroutes elsewhere.</li><li><strong>Method-Specific Rules</strong><br>You decide the playbook: UPI via Razorpay, Visa cards via PayU, or even “<em>all Bank A debit cards</em>” through Gateway C if they perform better there.</li><li><strong>Live Analytics &amp; Tuning</strong><br>Dashboards monitor approval rates, response times, and fees. Based on that data, you can rebalance traffic or onboard a new gateway in minutes.</li></ul><p>So when you tap “Pay,” you’re actually tapping into a mini control tower that keeps your order’s payment journey smooth and silent. That’s payment orchestration — and that’s why Zomato’s checkout barely ever falters. 😉</p><p>So what’s in it for the business? Let’s break it down:</p><ul><li><strong>Gateway Independence</strong><br>No more vendor lock-in means you keep negotiating power. You can add, remove, or swap gateways at will , so you’re never stuck paying high fees or losing out on new features.</li><li><strong>Uninterrupted Revenue</strong><br>By killing the single point of failure, you ensure 100% uptime on payments. Every order that reaches checkout can get paid, protecting your top line even when one provider hiccups.</li><li><strong>Automated Cost Optimization</strong><br>Route each transaction through the lowest-fee gateway in real time. Those savings on processing fees stack up fast, directly boosting your margins without any extra work.</li></ul><p>That’s the secret behind Zomato’s silky-smooth checkout: a smart, invisible control tower that never sleeps. The next time you hit “Pay,” know that you’re powering through a finely tuned network of payment engines — so you can focus on the food, not the fine print. 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb660a08b060" width="1" height="1" alt=""><hr><p><a href="https://medium.com/debugging-diaries/under-the-hood-what-powers-a-never-fail-checkout-eb660a08b060">Under the Hood: What Powers a Never-Fail Checkout?</a> was originally published in <a href="https://medium.com/debugging-diaries">Debugging Diaries</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Road to GitOps: Transforming Continuous Delivery for Modern Infrastructure]]></title>
            <link>https://medium.com/debugging-diaries/the-road-to-gitops-transforming-continuous-delivery-for-modern-infrastructure-63527a13c41d?source=rss----8e1ee92b126e---4</link>
            <guid isPermaLink="false">https://medium.com/p/63527a13c41d</guid>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[gitops]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[argo-cd]]></category>
            <dc:creator><![CDATA[Pradyuman]]></dc:creator>
            <pubDate>Sun, 09 Mar 2025 07:33:58 GMT</pubDate>
            <atom:updated>2025-03-09T07:33:43.947Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, I was assigned the task of setting up my company’s CI/CD pipelines. While researching modern approaches to streamline this process, I came across the concept of GitOps. Having worked with traditional CI/CD methods, I was familiar with Jenkins pipelines for building and testing code, storing artifacts in repositories like Artifactory, and deploying them to environments — either manually or via deployment scripts.</p><p>However, GitOps introduced a fundamentally different approach. Instead of relying on imperative scripts and manual interventions, GitOps treats Git as the single source of truth, ensuring that infrastructure and application deployments are automated, declarative, and continuously reconciled. This shift in methodology not only simplifies deployments but also enhances reliability, auditability, and collaboration across teams.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rLzBZCKnXQvEg1L76rpT_Q.jpeg" /></figure><p>Since our infrastructure was set up on Google Cloud, which offers excellent support for Kubernetes CRDs, I got to work implementing GitOps. I started by creating a central repository to store all configuration files, then deployed ArgoCD into our Kubernetes cluster using HELM and set up our project within ArgoCD. And just like that — our GitOps pipeline was up and running.</p><p>Now, whenever a new container image is pushed to the registry, our CI pipeline updates the configuration in GitHub, triggering ArgoCD to automatically deploy the changes without any manual intervention. It’s a seamless and efficient process that eliminates the need for manual deployments.</p><p>However, while GitOps might seem like a garden full of flowers, it does come with its own set of challenges. As the number of deployments and projects grows, managing configurations can become increasingly complex. Additionally, manual modifications to the configuration repository can introduce inconsistencies or lead to broken deployments. Despite these challenges, GitOps offers far more than the occasional hiccups.</p><p>GitOps is still an evolving concept, and as it matures, we can expect new features, faster deployments, and more efficient management strategies. With strong adoption from cloud-native projects and continuous improvements in GitOps tooling, its potential is only growing. Personally, I’m quite optimistic about its future and believe it will become a standard for managing modern infrastructure.</p><p>While no system is perfect, the benefits of GitOps — automation, consistency, and reliability — far outweigh its challenges. As more organizations embrace this approach, best practices will continue to emerge, making GitOps even more powerful and accessible. If you haven’t explored it yet, now might be the perfect time to dive in!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63527a13c41d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/debugging-diaries/the-road-to-gitops-transforming-continuous-delivery-for-modern-infrastructure-63527a13c41d">The Road to GitOps: Transforming Continuous Delivery for Modern Infrastructure</a> was originally published in <a href="https://medium.com/debugging-diaries">Debugging Diaries</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Transformer]]></title>
            <link>https://medium.com/debugging-diaries/introduction-to-transformer-c98757b2fea8?source=rss----8e1ee92b126e---4</link>
            <guid isPermaLink="false">https://medium.com/p/c98757b2fea8</guid>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Pradyuman]]></dc:creator>
            <pubDate>Sat, 16 Nov 2024 10:47:44 GMT</pubDate>
            <atom:updated>2024-11-16T10:48:01.522Z</atom:updated>
            <content:encoded><![CDATA[<h3>Unpacking the Transformer: The AI Breakthrough That Changed Everything</h3><p>Originally Article Published at: <a href="https://legendary-acp.github.io/papershelf/2024/09/08/introduction-to-transformers.html">https://legendary-acp.github.io/papershelf/2024/09/08/introduction-to-transformers.html</a></p><p>Alright, so I’ve had this paper, “<strong><em>Attention is All You Need</em></strong>” sitting in my reading list for a solid six months now. Finally decided to check it out today. It’s not super hard to understand, but I did have to ask ChatGPT for a little help. Funny enough, ChatGPT is actually built on the transformer architecture the paper talks about. Pretty cool, right?</p><p>So, here’s the deal: this paper introduces the Transformer model, and it totally flips the script on how we process data. Instead of relying on traditional recurrence like older models, it goes all-in on self-attention. This is a game-changer because self-attention means the model can process input sequences in parallel. Translation? It’s faster, it scales way better, and it just outperforms the older models in pretty much every way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*FAIkt2cdgjDwCesZHuvkNw.png" /><figcaption>Transformer Architecture</figcaption></figure><p>Now let’s talk about the Transformer’s core setup. It’s based on an encoder-decoder architecture. The encoder handles the input sequence, while the decoder generates the output based on the encoder’s work and its own past outputs. But the real magic is in the <strong>Multi-Head Attention Mechanism</strong> — this is what lets the model focus on different parts of the input data at the same time. So, rather than just processing one piece at a time like traditional recurrent models, the Transformer can look at everything all at once, making it lightning-fast.</p><p>And here’s the real mic-drop moment: the introduction of **attention** completely changes the game. With the multi-headed self-attention mechanism, the Transformer model doesn’t just speed up training — it takes the whole performance bar and smashes it. We’re talking state-of-the-art results on tasks like the WMT 2014 English-to-German and English-to-French translation benchmarks. On the English-to-German task, it hit a BLEU score of 28.4, blowing the previous record out of the water. That’s not just progress — it’s a huge leap forward.</p><p>So yeah, this paper isn’t just a technical blueprint — it’s the foundation of some of the most powerful AI systems we’re using today. And next time you’re chatting with ChatGPT or using an AI model, just know: you’re interacting with the magic of the Transformer. Pretty wild, huh?</p><p>Catch you in the next one — where we break down more game-changing tech!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c98757b2fea8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/debugging-diaries/introduction-to-transformer-c98757b2fea8">Introduction to Transformer</a> was originally published in <a href="https://medium.com/debugging-diaries">Debugging Diaries</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>