<?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 Venugopal Gopalakrishnapillai on Medium]]></title>
        <description><![CDATA[Stories by Venugopal Gopalakrishnapillai on Medium]]></description>
        <link>https://medium.com/@venugopal.gkp?source=rss-632643c5a5db------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5nfzAR6v1nmops__wCo5MA.jpeg</url>
            <title>Stories by Venugopal Gopalakrishnapillai on Medium</title>
            <link>https://medium.com/@venugopal.gkp?source=rss-632643c5a5db------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 12:18:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@venugopal.gkp/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[Architecture as Code: What CALM Is and Why It Exists]]></title>
            <link>https://medium.com/@venugopal.gkp/architecture-as-code-what-calm-is-and-why-it-exists-c32c2dcd2737?source=rss-632643c5a5db------2</link>
            <guid isPermaLink="false">https://medium.com/p/c32c2dcd2737</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[architecture-as-code]]></category>
            <category><![CDATA[calm]]></category>
            <dc:creator><![CDATA[Venugopal Gopalakrishnapillai]]></dc:creator>
            <pubDate>Tue, 06 Oct 2026 02:15:20 GMT</pubDate>
            <atom:updated>2026-10-06T02:15:20.222Z</atom:updated>
            <content:encoded><![CDATA[<p>Every architecture review I’ve ever sat in has the same quiet problem running underneath it: the diagram on the screen and the system actually running in production are two different things, and nobody in the room can say with confidence how different. The diagram was accurate the week it was drawn. Six months and forty pull requests later, it’s a snapshot of a system that no longer exists, kept alive in a wiki page because redrawing it is nobody’s job and nobody’s priority.</p><p>That gap is what CALM — the Common Architecture Language Model — exists to close. It’s an open-source specification out of FINOS, the financial services open-source foundation, originally developed and open-sourced by Morgan Stanley, and it’s built around one idea stated plainly on its own homepage: architecture should be standardized, automated, and governed the same way code already is. This post is the first in a series working through CALM from first principles to a full governed architecture — starting here, with what the idea actually means before any of the tooling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GQP2Iq_cXQ3KxE-ReKsmsg.png" /></figure><h3>The same shift, one layer up</h3><p>If you’ve worked with Terraform or Bicep, the pitch for CALM will feel immediately familiar, because it’s the same argument Infrastructure as Code made a decade ago, applied one layer higher up the stack. Before IaC, infrastructure lived in whatever state a person had last clicked it into through a console — undocumented, unreviewable, and impossible to meaningfully diff between two points in time. IaC fixed that by making infrastructure a text file: version-controlled, reviewable in a pull request, validated before it’s ever applied.</p><p>Architecture diagrams, even now, mostly still live in the pre-IaC world. A .drawio file or a PowerPoint slide is a picture of a decision, not the decision itself in any form a machine can check. Nothing validates that the diagram matches reality. Nothing in a CI pipeline can look at it and flag that a newly added service skipped a required security control. Nothing gives you a real diff between this quarter&#39;s architecture and last quarter&#39;s — just two static images and a human trying to spot what changed by eye. CALM&#39;s actual claim is that this doesn&#39;t have to be true anymore: architecture can be a structured, machine-readable file sitting in the same repository as the code it describes, checked the same way the code is checked.</p><h3>What the file actually looks like</h3><p>CALM architectures are JSON documents, and the entire model is built from three primitives.</p><p><strong>Nodes</strong> are the building blocks — a microservice, a database, a web client, a person interacting with the system. Each one carries a unique-id, a node-type, and whatever descriptive properties matter for that element.</p><p><strong>Relationships</strong> describe how nodes connect — connects for a straightforward interface connection, interacts for a more general interaction, deployed-in for placement within infrastructure, composed-of for hierarchical structure, where one node is actually made up of others. The vocabulary is deliberately small to start with, extensible when an organization needs more.</p><p><strong>Metadata</strong> is where context and compliance information actually live — tags, custom attributes, operational data, anything an organization needs captured that isn’t core to the structural model itself. This is also where the series is eventually headed: metadata is the hook controls and governance checks attach to.</p><p>Here’s the minimal example from CALM’s own documentation — a trading UI talking to an orders API, expressed as nodes and a relationship between them:</p><pre>{<br>  &quot;nodes&quot;: [<br>    { &quot;unique-id&quot;: &quot;trading-ui&quot;, &quot;node-type&quot;: &quot;webclient&quot; },<br>    { &quot;unique-id&quot;: &quot;orders-api&quot;, &quot;node-type&quot;: &quot;service&quot; }<br>  ],<br>  &quot;relationships&quot;: [<br>    { &quot;connects&quot;: {<br>        &quot;source&quot;: &quot;trading-ui&quot;,<br>        &quot;destination&quot;: &quot;orders-api&quot; } }<br>  ]<br>}</pre><p>That’s a complete, valid, if minimal, CALM architecture. It’s also already more useful than most hand-drawn diagrams in one specific way: it’s checkable. A schema can validate that every relationship references a node that actually exists. A CI pipeline can diff this file against last week’s version and surface exactly what changed, structurally, not just visually.</p><h3>Why this matters more in a regulated environment, not less</h3><p>The instinct might be that this is nice-to-have tooling hygiene — cleaner than a wiki page, but not obviously worth adopting deliberately. That undersells it specifically for organizations where architecture reviews already have real teeth: banking, financial services, anywhere a new system has to clear a security or compliance review before it ships. CALM’s own origin at Morgan Stanley isn’t incidental — a regulated environment is exactly where “the diagram the reviewer looked at” and “the system that actually got built” silently diverging is a real, recurring risk, not just an annoyance.</p><p>Expressing architecture as code means a compliance requirement — every service handling customer data must connect through an approved gateway, every external-facing node must have a documented owner — can be expressed as a control checked automatically against the model, the same way a linter checks code style. That turns an architecture review from a meeting where someone reads a diagram and hopes it’s current into a validation step that runs on every pull request, the same way a test suite does. Later posts in this series go deep on exactly that — this one is just establishing why the foundation matters before building on it.</p><h3>Where this series goes from here</h3><p>This post covered the concept: what architecture as code means, why CALM exists, and the three primitives — nodes, relationships, metadata — that every later post builds on. The next post gets hands-on: installing the CALM CLI, writing a first real architecture file from scratch, and validating it, which is where the abstract idea in this post turns into something you can actually run and see work.</p><p>The rest of the series follows CALM’s own shape fairly closely, because it’s a sensible progression: relationship types in depth, interfaces and richer metadata, controls and compliance, reusable patterns, CI/CD integration, and a capstone post modeling a complete system end-to-end. None of it requires taking the pitch in this post on faith for long — the next post is where it starts proving itself.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c32c2dcd2737" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deployment & Release Patterns: Shipping Safer Than “Push and Hope”]]></title>
            <link>https://medium.com/@venugopal.gkp/deployment-release-patterns-shipping-safer-than-push-and-hope-8625561fe8c7?source=rss-632643c5a5db------2</link>
            <guid isPermaLink="false">https://medium.com/p/8625561fe8c7</guid>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[continuous-deployment]]></category>
            <dc:creator><![CDATA[Venugopal Gopalakrishnapillai]]></dc:creator>
            <pubDate>Wed, 16 Sep 2026 06:37:16 GMT</pubDate>
            <atom:updated>2026-09-16T06:37:16.250Z</atom:updated>
            <content:encoded><![CDATA[<p>Every pattern so far in this series has dealt with a system already running in production — how it survives failure, handles load, manages data, communicates internally, and organizes its services. This final category deals with the moment a system changes: the instant a new version of the code actually reaches real users. That moment is where a surprising share of production incidents originate, not because deployments are inherently dangerous, but because “deploy the new version” and “expose every user to the new version” are so often treated as the same event when they don’t have to be.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z026g3cchTFaIvksi1RHag.png" /></figure><p>Same format as the rest of the series: each pattern gets a diagram, a plain explanation of the problem, and a Terraform sample deploying a small, real version of it in Azure. These three patterns aren’t competitors — they solve overlapping but genuinely different problems, and the closing section is worth reading carefully if you’re deciding which one actually fits a given release.</p><h3>Blue-Green Deployment</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eSpu59mAvCwpIEjsgUbWNQ.png" /></figure><p>Upgrading a running system in place carries a specific risk: for some window of time, the system is neither fully on the old version nor fully on the new one, and if something goes wrong mid-upgrade, getting back to a known-good state means redeploying the old version under pressure, with the incident actively ongoing. Blue-Green Deployment sidesteps that entirely by never upgrading anything in place. Two full, independent environments exist side by side — one live, one staged — and releasing a new version means fully deploying it to the staged environment, validating it while it carries zero production traffic, and then cutting every bit of traffic over at once with a router or load-balancer change.</p><p>The property that makes this pattern worth its overhead is what rollback actually looks like when it’s needed. It isn’t a redeploy of the previous version, hoping the deployment process itself doesn’t fail during an active incident — it’s the same router flip in reverse, back to an environment that was already running and already known to work seconds earlier. That speed and certainty is exactly why this pattern shows up most often for changes where testing in isolation, then cutting over instantly, matters more than a gradual rollout — database migrations, infrastructure-level changes, major version upgrades where a partial rollout would leave the system in an ambiguous mixed state.</p><pre># blue-green-deployment-pattern/main.tf — see terraform-blue-green-pattern.tf for the full file<br>resource &quot;azurerm_linux_web_app&quot; &quot;production&quot; {<br>  name                = &quot;app-blue-green-sample&quot;<br>  # ...<br>}</pre><pre>resource &quot;azurerm_linux_web_app_slot&quot; &quot;green&quot; {<br>  name           = &quot;green&quot;<br>  app_service_id = azurerm_linux_web_app.production.id<br>  # ...<br>}</pre><p><strong>About this sample:</strong> an App Service with a deployment slot, which is Azure’s native mechanism for exactly this pattern — two full app instances, one production, one staged, with a slot swap operation that moves 100% of traffic between them near-instantly. A production version of this would layer on a warm-up check before completing the swap, so traffic never lands on an instance that’s still cold-starting.</p><h3>Canary Release</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yS10OV_b8HtKijnF0W7FBQ.png" /></figure><p>Blue-Green’s all-or-nothing cutover is exactly right for some changes and exactly wrong for others — specifically, changes where the actual risk is something subtle in the application code that testing didn’t catch, and where exposing 100% of users to that risk simultaneously turns a small bug into a full incident. Canary Release — named after the miners’ canary, an early warning before a larger problem becomes obvious — takes a gradual approach instead: the new version receives a small slice of real production traffic, typically starting around 5%, while the stable version continues serving everyone else.</p><p>What makes this pattern genuinely different from just “a smaller Blue-Green” is that the expansion from that small slice to full rollout is driven by real signal, not a fixed schedule. Error rates, latency, and business metrics on the canary slice get watched closely, and the exposure widens — 5% to 25% to 50% to 100% — only as long as those signals stay healthy. The moment something looks wrong, rolling back means routing traffic away from the canary entirely, and only the small fraction of users who happened to land on it during the window were ever affected. That contained blast radius is the entire value proposition, and it’s why this pattern is the standard choice for application-level changes specifically, where Blue-Green’s instant, complete cutover would expose everyone to a subtle bug at once.</p><pre># canary-release-pattern/main.tf — see terraform-canary-pattern.tf for the full file<br>resource &quot;azurerm_linux_web_app_slot&quot; &quot;canary&quot; {<br>  name           = &quot;canary&quot;<br>  app_service_id = azurerm_linux_web_app.stable.id<br>  # ...<br>}</pre><p><strong>About this sample:</strong> the same App Service slot mechanism as Blue-Green, used differently — routing a percentage of traffic to the canary slot rather than swapping wholesale. Worth flagging honestly: percentage-based traffic routing on App Service slots is configured through the Azure CLI’s traffic-routing commands rather than a fully mature Terraform resource as of this writing, which is a good reminder to check current provider documentation rather than assume Terraform coverage matches the Azure platform’s full feature set.</p><h3>Feature Flags / Toggles</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u1van5bDbNzQVtVNFUmWRA.png" /></figure><p>Blue-Green and Canary both operate at the infrastructure level — they control which version of a deployed artifact receives traffic. Feature Flags operate one level up, inside a single running version of the code: a feature ships already deployed, wrapped in a runtime check against a flag, and the flag — not a deployment — decides whether any given user actually sees it. The code for a new checkout flow can be sitting live in production, fully deployed, completely inert for every user until the flag controlling it gets flipped on.</p><p>This decoupling is the whole point, and it solves a problem neither Blue-Green nor Canary actually addresses: separating the act of shipping code from the act of exposing a feature to users. A feature can be deployed on a Tuesday and enabled for internal staff only, then beta users, then a percentage rollout, then everyone — all without a single additional deployment, because every one of those transitions is a flag change, not a code change. And when something does look wrong after a flag goes live, turning it back off is instantaneous — no rollback deployment, no redeploying a previous artifact, just a flag flip that takes effect on the very next request.</p><pre># feature-flags-pattern/main.tf — see terraform-feature-flags-pattern.tf for the full file<br>resource &quot;azurerm_app_configuration_feature&quot; &quot;new_checkout_flow&quot; {<br>  configuration_store_id = azurerm_app_configuration.flags_sample.id<br>  name                    = &quot;new-checkout-flow&quot;<br>  label                   = &quot;production&quot;<br>  enabled                 = false<br>}</pre><p><strong>About this sample:</strong> Azure App Configuration’s native feature management, which stores flags centrally and exposes them to an application through its SDK at runtime. The flag ships disabled by default — a deliberate choice, since a feature flag defaulting to “on” defeats most of the safety this pattern is meant to provide. Real deployments commonly layer per-user or percentage-based targeting on top of a simple boolean, which App Configuration’s feature filters support directly.</p><h3>Choosing between the three</h3><p>These patterns solve different shaped problems, and the honest answer to “which one should I use” is usually “possibly more than one, for different parts of the same release.” Blue-Green is the right tool when a change needs to be validated in full isolation and then cut over completely and instantly — infrastructure changes, database migrations, anything where a mixed state mid-rollout would be actively harmful. Canary is the right tool when the risk is genuinely in the application code itself and containing the blast radius of an undiscovered bug matters more than an instant cutover. Feature Flags solve a problem the other two don’t touch at all: controlling exposure to a specific feature independent of the deployment process entirely, which matters most for product-level rollouts, kill switches, and experiments where the code needs to exist in production well before every user should see it.</p><p>In practice, a mature release process often layers these: code ships behind a feature flag (decoupling deploy from release), the deployment itself happens through a canary or blue-green process (decoupling infrastructure risk from user exposure), and the flag provides a second, independent kill switch even after the canary has fully rolled out. None of these three replace careful testing — they exist because testing, however thorough, never eliminates the gap between “this worked in staging” and “this works for every real user at real production scale,” and that gap is exactly what this entire category of patterns is built to manage.</p><h3>Closing out the series</h3><p>This is the sixth and final category in this walkthrough of cloud architectural patterns — reliability, scalability, data management, messaging, design and structure, and now deployment. Taken together, they’re really one continuous argument: production systems fail, get overloaded, drift out of sync, and change over time, and every pattern in this series is a specific, well-understood answer to one piece of that reality. None of them are mandatory, and applying all of them reflexively to a system that doesn’t need them is its own kind of mistake. But knowing the full catalog means the choice, when it actually matters, is a deliberate one — not a gap in the map you didn’t know was there.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8625561fe8c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design & Structural Patterns: Shaping How Services Are Organized]]></title>
            <link>https://medium.com/@venugopal.gkp/design-structural-patterns-shaping-how-services-are-organized-3e01c36a3f5a?source=rss-632643c5a5db------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e01c36a3f5a</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[cloud-architecture]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Venugopal Gopalakrishnapillai]]></dc:creator>
            <pubDate>Mon, 07 Sep 2026 13:49:06 GMT</pubDate>
            <atom:updated>2026-09-07T13:49:06.314Z</atom:updated>
            <content:encoded><![CDATA[<p>The previous four categories in this series dealt with a system’s behavior under failure, load, data consistency, and inter-service communication. This one deals with something more structural: how services get organized, how cross-cutting concerns get attached to them without polluting their core logic, and how a client-facing edge gets shaped for the clients actually consuming it. These are less about a single runtime problem and more about the shape of a codebase and its service boundaries — decisions that are cheap to make deliberately up front and expensive to unwind once a dozen services have grown around the wrong one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ZNvTdWEJwATXDYZHnS-AA.png" /></figure><p>Same format as the last four posts: each pattern gets a diagram, a plain explanation of the problem, and a Terraform sample deploying a small, real version of it in Azure. Two of these patterns — Sidecar and Ambassador — are close enough relatives that they’re worth reading back to back rather than in isolation.</p><h3>Sidecar</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hk_Za8YsxcRbrq4LX8QPRg.png" /></figure><p>A service almost always needs more than its core business logic to run well in production — logging, metrics collection, configuration syncing, security agents. Bundling all of that directly into the application means every service reimplements the same cross-cutting concerns, and updating how logging works means redeploying every single service that logs anything. The Sidecar pattern separates this cleanly: a second container, deployed alongside the main application in the same unit (the same pod, in Kubernetes terms), handles the cross-cutting concern, communicating with the main application over localhost.</p><p>The property that makes this genuinely useful rather than just an organizational preference is the shared lifecycle. A sidecar deploys with its application, scales with it, and terminates with it — there’s no separate deployment to coordinate, no version-skew risk between an application and a cross-cutting service running independently. And because the sidecar is a generic, reusable container image, the same logging or config-sync sidecar attaches to a dozen unrelated services without any of them needing to know it exists beyond a shared container spec.</p><pre># sidecar-pattern/main.tf — see terraform-sidecar-pattern.tf for the full file<br>resource &quot;azurerm_container_app&quot; &quot;app_with_sidecar&quot; {<br>  name                         = &quot;ca-sidecar-sample&quot;<br>  resource_group_name          = azurerm_resource_group.sidecar_sample.name<br>  container_app_environment_id = azurerm_container_app_environment.sidecar_sample.id<br>  revision_mode                = &quot;Single&quot;</pre><pre>  template {<br>    container {<br>      name  = &quot;main-application&quot;<br>      image = &quot;mcr.microsoft.com/azuredocs/containerapps-helloworld:latest&quot;<br>    }<br>    container {<br>      name  = &quot;logging-sidecar&quot;<br>      image = &quot;mcr.microsoft.com/azuredocs/containerapps-helloworld:latest&quot;<br>    }<br>  }<br>}</pre><p><strong>About this sample:</strong> Azure Container Apps supports multiple containers in a single container app resource natively, which is exactly the shared-lifecycle shape this pattern needs. The sidecar image here is a placeholder — a real deployment would run something genuinely doing log shipping, metrics scraping, or service mesh duties (Dapr is a common choice on Azure specifically because it’s designed to run as a sidecar).</p><h3>Ambassador</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dd4eLzCGaWJGaK3bqEK0pQ.png" /></figure><p>Ambassador is worth presenting immediately after Sidecar because it’s structurally the same pattern, narrowed to one specific job: networking. Instead of a general cross-cutting concern, the second container handles everything about talking to a remote dependency — retries, TLS termination, circuit breaking, service discovery — so the main application’s code can call localhost and never know or care that the real destination is flaky, moved, or requires a specific auth handshake.</p><p>The value shows up clearest when a networking concern needs to change. Rolling out a new retry policy or switching which discovery mechanism a fleet of services uses becomes a change to the ambassador image, redeployed everywhere it’s used, rather than a code change threaded through every service that makes an outbound call. It’s the same principle behind the Circuit Breaker pattern from the reliability post, but implemented as reusable infrastructure instead of a library every team has to import and configure correctly on their own.</p><pre># ambassador-pattern/main.tf — see terraform-ambassador-pattern.tf for the full file<br>container {<br>  name  = &quot;main-application&quot;<br>  env {<br>    name  = &quot;DOWNSTREAM_URL&quot;<br>    value = &quot;http://localhost:8080&quot; # the app calls the ambassador, never the remote service directly<br>  }<br>}<br>container {<br>  name  = &quot;networking-ambassador&quot;<br>  image = &quot;mcr.microsoft.com/azuredocs/containerapps-helloworld:latest&quot; # placeholder for a real proxy<br>}</pre><p><strong>About this sample:</strong> identical infrastructure shape to the Sidecar sample — two containers, one Container App — with the main application configured to call the ambassador on localhost rather than the remote dependency’s real address. A production ambassador is commonly an Envoy proxy or similar, configured with genuine retry and circuit-breaking policy, which is the part actually worth spending design time on.</p><h3>Anti-Corruption Layer</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D_76ur87YFeL7pXHnH17wA.png" /></figure><p>Integrating a new, cleanly designed service with an old system — a decades-old mainframe, a vendor system with an awkward data model, anything whose internal representation you don’t control and wouldn’t choose — creates a real risk: the old system’s quirks start leaking into the new one’s domain model. A field named STATUS_CD with values like &quot;A&quot;, &quot;P&quot;, and &quot;X9&quot; is exactly the kind of thing that, left unchecked, ends up copied verbatim into a brand new service&#39;s code, dragging decades of legacy assumptions into a system that was supposed to be a clean start.</p><p>An Anti-Corruption Layer is a dedicated translation boundary sitting between the two: the new service speaks its own clean domain language — Customer, Order, LineItem — and the layer handles converting that into whatever shape the legacy system actually needs, and translating its responses back. Nothing on the new service&#39;s side ever needs to know the legacy system&#39;s internal representation exists. The layer absorbs that complexity once, in one well-understood place, instead of letting it spread.</p><pre># anti-corruption-layer-pattern/main.tf — see terraform-anti-corruption-layer-pattern.tf for the full file<br>resource &quot;azurerm_linux_web_app&quot; &quot;acl_sample&quot; {<br>  name                = &quot;app-anti-corruption-layer-sample&quot;<br>  # ...<br>  app_settings = {<br>    &quot;LEGACY_SYSTEM_ENDPOINT&quot; = &quot;https://legacy-mainframe.internal.example.com&quot;<br>  }<br>}</pre><p><strong>About this sample:</strong> a standalone App Service whose entire job is translation. The interesting part of a real implementation is entirely in application code — the actual field-by-field, code-by-code mapping between the two domain models — which Terraform obviously can’t express; what’s provisioned here is just the isolated service boundary that mapping logic lives inside.</p><h3>Backends for Frontends (BFF)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UPevRi5Xm8aP2oktu56_7w.png" /></figure><p>A single generic API trying to serve a mobile app, a full web application, and a partner integration all at once tends to end up compromising for all three: too much payload for mobile’s bandwidth and battery constraints, not quite enough for the web client’s richer UI, and too loosely versioned for a partner integration that needs strict stability guarantees. Backends for Frontends resolves that by refusing to force one API to satisfy every client — each client type gets its own thin backend, shaped specifically for what that client actually needs, all calling into the same underlying shared services.</p><p>The tradeoff worth naming plainly: this means more services to deploy and monitor, and some duplicated logic across the BFFs unless that duplication is deliberately extracted into a shared library. That cost is worth paying specifically once client needs have genuinely diverged enough that a one-size-fits-all API is causing real friction — an unnecessary complication for a system with a single client type, and a meaningful simplification for one straining to serve several very different ones through the same generic surface.</p><pre># backends-for-frontends-pattern/main.tf — see terraform-bff-pattern.tf for the full file<br>resource &quot;azurerm_linux_web_app&quot; &quot;mobile_bff&quot; { name = &quot;app-bff-mobile-sample&quot; }<br>resource &quot;azurerm_linux_web_app&quot; &quot;web_bff&quot;    { name = &quot;app-bff-web-sample&quot; }<br>resource &quot;azurerm_linux_web_app&quot; &quot;partner_bff&quot; {<br>  name = &quot;app-bff-partner-sample&quot;<br>  app_settings = {<br>    &quot;API_VERSION_LOCK&quot; = &quot;v1&quot;<br>  }<br>}</pre><p><strong>About this sample:</strong> three independent App Services, each free to evolve its own response shapes, caching strategy, and versioning policy without coordinating with the other two. The partner BFF’s explicit version lock is a small but real example of divergence in practice — internal clients can tolerate a faster-moving API in a way an external partner integration usually can’t.</p><h3>API Gateway</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FDGp579F7FliWDvVWDdbCg.png" /></figure><p>Without a shared entry point, every backend service ends up independently implementing the same cross-cutting concerns — authentication, rate limiting, TLS termination, request logging — and independently getting some of them slightly wrong. An API Gateway centralizes this: a single entry point in front of every backend service, handling routing (sending each request to the right downstream service), aggregation (combining multiple backend calls into one client-facing response), and offloading (auth, rate limiting, and TLS handled once, at the edge, rather than duplicated per service).</p><p>This is where the earlier Throttling pattern from the reliability post and the API Management resource actually live in a real architecture — a gateway is usually the layer that pattern’s rate-limit policy gets applied at, since it’s the one place that sees every request regardless of which backend it’s ultimately headed for. The tradeoff worth being honest about: a gateway this central becomes a single point of failure for everything behind it if it isn’t itself built resilient, which is exactly why production API Management deployments commonly run across multiple regions rather than as a single instance.</p><pre># api-gateway-pattern/main.tf — see terraform-api-gateway-pattern.tf for the full file<br>resource &quot;azurerm_api_management_api&quot; &quot;orders_api&quot; {<br>  name         = &quot;orders-api&quot;<br>  path         = &quot;orders&quot;<br>  service_url  = &quot;https://${azurerm_linux_web_app.orders.default_hostname}&quot;<br>}</pre><pre>resource &quot;azurerm_api_management_api&quot; &quot;inventory_api&quot; {<br>  name         = &quot;inventory-api&quot;<br>  path         = &quot;inventory&quot;<br>  service_url  = &quot;https://${azurerm_linux_web_app.inventory.default_hostname}&quot;<br>}</pre><p><strong>About this sample:</strong> one API Management instance routing two path prefixes to two separate backend App Services. Each API can carry its own policies — the same rate-limit XML policy from the reliability post’s Throttling sample applies just as naturally here, scoped per-API rather than globally, if different backends need different limits.</p><h3>Strangler Fig</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VPzDKtQnFZ5g6Gj3nRXkRw.png" /></figure><p>Rewriting a legacy system in one large cutover is one of the highest-risk moves available in software architecture — a single deployment where everything has to work, with a legacy system that’s usually undocumented enough that nobody’s entirely sure what it actually does until something it did silently stops happening. Strangler Fig, named for the vine that gradually envelops and eventually replaces a host tree, takes the opposite approach: a routing facade sits in front of both the legacy system and the new one, and traffic gets moved from old to new one route, one feature, at a time, with both systems running side by side for as long as the migration takes.</p><p>The genuine advantage over a rewrite isn’t just risk reduction, though that matters — it’s that every migrated route is immediately validated against real production traffic rather than a staging environment’s best guess at real usage. A route that turns out to have been more complicated than it looked can stay on the legacy system a while longer without blocking progress on everything else. Eventually the legacy system handles nothing at all and gets decommissioned outright, and the facade itself — no longer routing between two systems — can be simplified or removed.</p><pre># strangler-fig-pattern/main.tf — see terraform-strangler-fig-pattern.tf for the full file<br>resource &quot;azurerm_cdn_frontdoor_profile&quot; &quot;strangler_sample&quot; {<br>  name                = &quot;fd-strangler-fig-sample&quot;<br>  resource_group_name = azurerm_resource_group.strangler_sample.name<br>  sku_name            = &quot;Standard_AzureFrontDoor&quot;<br>}</pre><pre># Route rules (not shown) map /api/orders/* to the new service and<br># everything else to the legacy monolith — the routing table itself<br># is the migration plan.</pre><p><strong>About this sample:</strong> an Azure Front Door profile fronting both a legacy App Service and a new one. The full file’s comment describes the routing rules that would actually implement the migration — Front Door’s path-based routing is what makes “just this one path prefix” migratable independently of everything else, which is the entire mechanism this pattern depends on.</p><h3>Where this category sits relative to the rest of the series</h3><p>A few connections worth drawing explicitly. Ambassador is Circuit Breaker (reliability post) implemented as reusable infrastructure rather than an in-process library. API Gateway is frequently where Throttling (also reliability) actually gets enforced in a real system, since the gateway is the one place that sees all traffic. And Strangler Fig is worth contrasting with the Saga and Choreography/Orchestration patterns from the last two posts — those solve coordination between services that are meant to coexist long-term, while Strangler Fig solves coordination between an old service and its intended replacement, where the goal is for one side to eventually disappear entirely. Structural patterns tend to have a longer shelf life in a codebase than any single request’s lifecycle — which is exactly why getting the boundaries right early costs so much less than fixing them after a dozen services have grown up around the wrong ones.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e01c36a3f5a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Messaging & Integration Patterns: Letting Independent Services Actually Talk]]></title>
            <link>https://medium.com/@venugopal.gkp/messaging-integration-patterns-letting-independent-services-actually-talk-5655bb1d300d?source=rss-632643c5a5db------2</link>
            <guid isPermaLink="false">https://medium.com/p/5655bb1d300d</guid>
            <category><![CDATA[cloud-architecture]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Venugopal Gopalakrishnapillai]]></dc:creator>
            <pubDate>Sun, 23 Aug 2026 03:51:57 GMT</pubDate>
            <atom:updated>2026-08-23T03:51:57.321Z</atom:updated>
            <content:encoded><![CDATA[<p>The first three posts in this series dealt with a system’s relationship to failure, load, and its own data. This one deals with something different: how do independently deployed services communicate with each other at all, once a direct function call across a network boundary stops being a reasonable default? A synchronous call between two services means both have to be up, both have to be fast, and a failure on either end propagates immediately to the other. Messaging patterns exist because that tight coupling is exactly what a distributed system usually can’t afford.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Pd7unhVOY4nkSR88Qr1uQ.png" /></figure><p>Same format as the previous three posts: each pattern gets a diagram, a plain explanation of the problem, and a Terraform sample deploying a small, real version of it in Azure. This category connects back to earlier posts more than most, since messaging is the connective tissue a lot of the other patterns in this series actually run on top of.</p><h3>Publish-Subscribe</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gGMiE9xi96nzAf24igVpOQ.png" /></figure><p>A service that needs to notify other parts of a system about something that happened — an order was placed, a user signed up, a payment cleared — faces a choice: call every interested party directly, or announce the event once and let interested parties decide for themselves whether they care. The first approach means the publishing service has to maintain a list of every consumer and update that list every time a new one shows up. Publish-Subscribe removes that coupling entirely: the publisher sends to a topic, and any number of independent subscribers each receive their own copy, without the publisher ever needing to know how many subscribers exist or what they do with the message.</p><p>The property worth noticing is what happens when a new consumer needs to be added later — a fourth service that wants to react to orders being placed, six months after the system shipped. Under Publish-Subscribe, that’s a new subscription, created without touching the Order Service’s code at all. Under direct calls, it’s a code change to the publisher, a deployment, and a coordination point between two teams that shouldn’t need to coordinate at all for something this routine.</p><pre># publish-subscribe-pattern/main.tf — see terraform-pubsub-pattern.tf for the full file<br>resource &quot;azurerm_servicebus_topic&quot; &quot;order_events&quot; {<br>  name         = &quot;order-events&quot;<br>  namespace_id = azurerm_servicebus_namespace.pubsub_sample.id<br>}</pre><pre>resource &quot;azurerm_servicebus_subscription&quot; &quot;inventory&quot; {<br>  name               = &quot;inventory-service&quot;<br>  topic_id           = azurerm_servicebus_topic.order_events.id<br>  max_delivery_count = 10<br>}</pre><p><strong>About this sample:</strong> one Service Bus topic with three separate subscriptions, one per subscriber. Each subscription gets its own independent copy of every message published to the topic — a message consumed by the Inventory subscription is still there, untouched, for Billing and Analytics to consume on their own schedule.</p><h3>Message Queue</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NyP4VsTuMumPnvYFwHpnkQ.png" /></figure><p>Publish-Subscribe broadcasts an event to every interested party. Sometimes that’s the wrong shape entirely — a piece of work that should be done exactly once, by exactly one worker, isn’t an event multiple parties should react to independently. A Message Queue is the point-to-point counterpart: a sender places a message on the queue and moves on immediately, and the message sits there until some receiver claims and processes it, with the guarantee that only one receiver ever gets a given message.</p><p>What this actually buys is decoupling in two dimensions most direct calls can’t offer at once: time and availability. The sender doesn’t need the receiver running at the same moment the message is sent — the receiver can be offline, scaling up, or mid-deployment, and the message simply waits. That’s the same underlying mechanism behind Queue-Based Load Leveling and Competing Consumers from earlier posts in this series; this pattern is really the foundational primitive those two build on top of.</p><pre># message-queue-pattern/main.tf — see terraform-message-queue-pattern.tf for the full file<br>resource &quot;azurerm_servicebus_queue&quot; &quot;requests&quot; {<br>  name                                  = &quot;processing-requests&quot;<br>  namespace_id                          = azurerm_servicebus_namespace.mq_sample.id<br>  max_delivery_count                    = 10<br>  default_message_ttl                   = &quot;P14D&quot;<br>  dead_lettering_on_message_expiration  = true<br>}</pre><p><strong>About this sample:</strong> a single Service Bus queue, deliberately simple. dead_lettering_on_message_expiration matters more than it looks like it should — without it, a message nobody claims within its TTL just silently disappears rather than landing somewhere you&#39;d actually notice and investigate.</p><h3>Claim Check</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j9T8t1L2aFf0U0WiU4wnhg.png" /></figure><p>Message brokers are built and priced around small, frequent messages, and most of them enforce a maximum message size well below what a video file, a large document, or a bulk data export would need. Routing a 40MB payload through a broker built for kilobyte-sized messages either fails outright or works against the broker’s design in a way that degrades performance for every other message sharing that infrastructure.</p><p>Claim Check solves this the same way an actual coat check does: hand the large item to storage built for large items, and carry only a small ticket referencing where it’s being held. The sender uploads the large payload to blob storage first, then sends a small message containing nothing but a reference — a URL — to where it landed. The receiver reads that reference and fetches the actual payload directly from storage, completely bypassing the message broker for the expensive part of the transfer.</p><pre># claim-check-pattern/main.tf — see terraform-claim-check-pattern.tf for the full file<br>resource &quot;azurerm_storage_container&quot; &quot;large_payloads&quot; {<br>  name                  = &quot;large-payloads&quot;<br>  storage_account_name  = azurerm_storage_account.payloads.name<br>  container_access_type = &quot;private&quot;<br>}</pre><pre>resource &quot;azurerm_servicebus_queue&quot; &quot;claim_checks&quot; {<br>  name         = &quot;claim-check-references&quot;<br>  namespace_id = azurerm_servicebus_namespace.cc_sample.id<br>}</pre><p><strong>About this sample:</strong> a private Blob Storage container holds the actual payloads, and a Service Bus queue carries only references to them. Worth building in from the start rather than retrofitting later: a short-lived SAS token or managed-identity-scoped access on the blob reference, so the “claim check” itself doesn’t grant open-ended access to anyone who happens to intercept the message.</p><h3>Choreography vs. Orchestration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xwscWdd0cVOapQMcuGwPLg.png" /></figure><p>Every multi-step process that spans more than one service needs an answer to a structural question: who’s actually in charge of the sequence? Orchestration answers that with a central coordinator — an orchestrator that calls each step, decides what happens next based on the result, and handles retries or branching from one place. Choreography answers it the opposite way — there is no central coordinator at all; each service reacts to events on its own, publishing its own completion event when it’s done, and the next service in line reacts to that in turn.</p><p>This is the same decision the Saga pattern from the data management post is built around, just framed at the general level rather than specifically for distributed transactions — Sagas are what this choice looks like when the “multi-step process” in question is a transaction that needs compensating actions if it fails partway through. Orchestration tends to win when the process is genuinely complex enough that having one place to see and reason about the whole sequence is worth the coupling it introduces. Choreography tends to win when the steps are simpler and keeping services fully independent — no shared coordinator, no single dependency the whole process relies on — matters more than having a single readable view of the flow.</p><pre># choreography-orchestration-pattern/main.tf — see terraform-choreography-orchestration-pattern.tf for the full file<br># Orchestration option<br>resource &quot;azurerm_linux_function_app&quot; &quot;orchestrator&quot; {<br>  name                = &quot;func-orchestrator-sample&quot;<br>  # Durable Functions app — coordinates each step centrally<br>}</pre><pre># Choreography option<br>resource &quot;azurerm_servicebus_topic&quot; &quot;process_events&quot; {<br>  name         = &quot;order-fulfillment-events&quot;<br>  namespace_id = azurerm_servicebus_namespace.choreography_sample.id<br>}</pre><p><strong>About this sample:</strong> both styles are provisioned side by side specifically to make the contrast concrete rather than abstract. The orchestration option is a Durable Functions app — infrastructurally close to the Compensating Transaction sample from the reliability post, since orchestration is the coordination shape Sagas commonly use. The choreography option is a Service Bus topic every participating service publishes to and subscribes from — which is really Publish-Subscribe, applied to a business process instead of a single event type. A real deployment picks one style for a given process rather than running both.</p><h3>Scatter-Gather</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ik7YTrEbkm0r13r48DVbmA.png" /></figure><p>Some requests genuinely need input from multiple independent sources before a useful response exists at all — a travel search comparing quotes from several airlines, a pricing engine checking multiple suppliers, a search aggregator querying several backends. Scatter-Gather sends the same request out to every relevant source in parallel, then waits for responses up to a bounded timeout and assembles whatever came back into a single answer, rather than either blocking indefinitely on the slowest source or calling each one sequentially and paying for their combined latency.</p><p>The detail that makes this pattern work in practice rather than just in theory is the explicit timeout and the willingness to return a partial result. A naive fan-out that waits for all N sources to respond is exactly as fast as the slowest one, and a single slow or dead provider degrades the entire request. A well-built scatter-gather returns the best answer it can assemble from whoever responded within the deadline, and treats a non-responder as simply excluded from that particular result rather than a reason to fail the whole request.</p><pre># scatter-gather-pattern/main.tf — see terraform-scatter-gather-pattern.tf for the full file<br>resource &quot;azurerm_linux_function_app&quot; &quot;aggregator&quot; {<br>  name = &quot;func-scatter-gather-sample&quot;<br>  # ...<br>  app_settings = {<br>    &quot;GATHER_TIMEOUT_MS&quot;        = &quot;2000&quot;<br>    &quot;MIN_RESPONSES_TO_PROCEED&quot; = &quot;2&quot;<br>  }<br>}</pre><p><strong>About this sample:</strong> a single aggregator Function App, with the downstream providers represented as app settings rather than provisioned resources — in this pattern’s classic use case, those providers are usually third-party services entirely outside your own infrastructure. The actual scatter-and-gather logic — issuing parallel calls, applying the timeout, assembling whatever arrived — is application code; Terraform’s role here is just standing up the one service responsible for running it.</p><h3>Where this category sits relative to the rest of the series</h3><p>More than any other category so far, these five patterns are building blocks other patterns in this series are made of. Publish-Subscribe underlies choreography-style Sagas. Message Queue underlies both Queue-Based Load Leveling and Competing Consumers from the scalability post. Choreography and Orchestration are the general shape of the specific choice the Saga pattern makes for distributed transactions. That layering is worth keeping in mind going forward: a lot of what looks like a new pattern in the categories still ahead — design and structural patterns, deployment patterns — turns out to be one of these five messaging primitives, applied to a more specific problem.</p><p><em>PF: The samples used in this post is available at </em><a href="https://github.com/NerdyThinker/cloud-architecture-samples/tree/main/Messaging"><em>cloud-architecture-samples/Messaging at main · NerdyThinker/cloud-architecture-samples</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5655bb1d300d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Management Patterns: Keeping Data Trustworthy Once One Database Isn’t the Whole Story]]></title>
            <link>https://medium.com/@venugopal.gkp/data-management-patterns-keeping-data-trustworthy-once-one-database-isnt-the-whole-story-f2bd1dcb18ee?source=rss-632643c5a5db------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2bd1dcb18ee</guid>
            <category><![CDATA[cloud-architecture]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Venugopal Gopalakrishnapillai]]></dc:creator>
            <pubDate>Thu, 20 Aug 2026 05:11:43 GMT</pubDate>
            <atom:updated>2026-08-20T05:11:43.639Z</atom:updated>
            <content:encoded><![CDATA[<p>The first two posts in this series dealt with surviving failure and handling scale. This one deals with something quieter but just as consequential: once a system stops being one application talking to one database, what actually keeps its data correct? A single service with a single database gets consistency for free — it’s one transaction, one schema, one source of truth. The moment that splits into multiple services, multiple stores, or a history that needs to be more than “whatever the current row says,” consistency stops being automatic and becomes something the architecture has to deliberately provide.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-udKPx68uLgD5ffL8KIirQ.png" /></figure><p>Same format as the last two posts: each pattern gets a diagram, a plain explanation of the problem, and a Terraform sample deploying a small, real version of it in Azure. A couple of these patterns connect directly back to ones already covered — worth flagging those connections as they come up, since this category has more overlap with the earlier two than any other in the series.</p><h3>Event Sourcing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8AT9NBIskP2FnZbzAdVQ0Q.png" /></figure><p>Most systems store only the current state of a thing — an order’s status is “shipped,” and whatever it was before that got overwritten the moment it changed. Event Sourcing rejects that trade: instead of storing current state, it stores every change as an immutable event, appended to a log that’s never updated or deleted. Current state isn’t stored directly at all — it’s derived by replaying the full sequence of events for a given entity, or by combining a periodic snapshot with whatever events have happened since.</p><p>The capability this buys that a current-state-only model genuinely can’t offer: a complete, queryable history of exactly how something got to where it is, not just where it ended up. “What did this order look like before the last change” isn’t a question a status column can answer, but it’s a question an event log answers by construction. The cost is real, too — replaying events (or maintaining snapshots to avoid replaying from the beginning every time) is more architectural machinery than a simple UPDATE statement, and it&#39;s a commitment worth making specifically when that history has genuine business value — audit requirements, dispute resolution, debugging production issues after the fact — rather than adopting it as a default for every entity in a system.</p><pre># event-sourcing-pattern/main.tf — see terraform-event-sourcing-pattern.tf for the full file<br>resource &quot;azurerm_cosmosdb_sql_container&quot; &quot;events&quot; {<br>  name                = &quot;order-events&quot;<br>  resource_group_name = azurerm_resource_group.es_sample.name<br>  account_name        = azurerm_cosmosdb_account.es_sample.name<br>  database_name       = azurerm_cosmosdb_sql_database.es_sample.name<br>  partition_key_paths = [&quot;/orderId&quot;]<br>}</pre><p><strong>About this sample:</strong> a Cosmos DB container holds events partitioned by the aggregate id (orderId), so every event belonging to one order lands in the same logical partition and can be read back in sequence cheaply. A Function App stands in for the projection worker that would replay these events into a queryable view. Cosmos doesn&#39;t enforce append-only behavior on its own — that discipline has to be maintained in application code or through access scoped to insert-only operations.</p><h3>Saga</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sn23Mv8l6RkFO0uTh8gOjA.png" /></figure><p>The Compensating Transaction pattern from the reliability post covered the mechanics of undoing partial work when a multi-step process fails midway. Saga is the broader pattern that mechanic belongs to, and it comes in two distinct shapes worth telling apart. Orchestration — what the earlier Durable Functions example showed — has one central coordinator directing every step and knowing the whole process end to end. Choreography, shown here, has no coordinator at all: each service reacts to events published by the others, and the overall saga emerges from those independent reactions rather than being directed by anything.</p><p>Neither shape is strictly better, and the choice is worth making deliberately rather than defaulting to whichever one you learned about first. Orchestration gives you one place to read the whole process and reason about its state, at the cost of a central component every step now depends on. Choreography removes that central dependency and keeps services genuinely decoupled from each other, at the cost of the saga’s overall logic being scattered across every participating service — debugging means tracing events across multiple places rather than reading one orchestrator’s history.</p><pre># saga-pattern/main.tf — see terraform-saga-pattern.tf for the full file<br>resource &quot;azurerm_servicebus_topic&quot; &quot;order_events&quot; {<br>  name         = &quot;order-events&quot;<br>  namespace_id = azurerm_servicebus_namespace.saga_choreo_sample.id<br>}</pre><pre>resource &quot;azurerm_servicebus_subscription&quot; &quot;inventory_sub&quot; {<br>  name               = &quot;inventory-service&quot;<br>  topic_id           = azurerm_servicebus_topic.order_events.id<br>  max_delivery_count = 5<br>}</pre><p><strong>About this sample:</strong> one shared Service Bus topic with a separate subscription per participating service — Inventory, Payment, Shipping — each filtering for the specific event types it cares about. Compare this directly against the Compensating Transaction sample from the reliability post: that one provisioned a single Durable Functions orchestrator; this one provisions no coordinator at all, just a shared communication channel and independent listeners.</p><h3>Outbox</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HpPj0JsJrBwJkc5P31AOZQ.png" /></figure><p>A service that writes to its database and then separately publishes a message about that write has a timing problem baked into the design: those are two different operations against two different systems, and there’s no way to guarantee both succeed or both fail together. The database write can succeed while the message publish fails — a crash, a network blip — and now other services never hear about a change that genuinely happened. Or the reverse: the message goes out before the database commit completes, and a subscriber reacts to a change that hasn’t actually been persisted yet.</p><p>The Outbox pattern closes that gap by keeping both operations inside a single transaction against a single database. Instead of publishing the message directly, the service writes a row describing the event into an “outbox” table, in the very same transaction as the business data change. A separate relay process — polling the table, or reading a change feed — picks up unprocessed outbox rows and publishes them, marking each one done once it succeeds. If the relay crashes mid-publish, the row is still sitting there unprocessed, and the next pass picks it up. Nothing about the pattern depends on the relay being perfectly reliable, because the outbox table is the durable record it’s working from.</p><pre># outbox-pattern/main.tf — see terraform-outbox-pattern.tf for the full file<br>resource &quot;azurerm_mssql_database&quot; &quot;outbox_sample&quot; {<br>  name      = &quot;outbox-sample-db&quot;<br>  server_id = azurerm_mssql_server.outbox_sample.id<br>  sku_name  = &quot;S0&quot;<br>  # The `orders` table and the `outbox` table both live in this single<br>  # database — that&#39;s what makes the atomic write possible.<br>}</pre><p><strong>About this sample:</strong> the orders table and the outbox table share one Azure SQL database specifically so a single local transaction can cover both. A timer-triggered Function App represents the relay, polling for unprocessed rows and publishing them to a Service Bus topic. Polling on a schedule is the simplest version of this to demonstrate; a production relay more often reads a change feed or uses Change Data Capture to reduce the latency between the write and the publish.</p><h3>Database per Service</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SiJJ23-DTA_bhw459JmeAg.png" /></figure><p>A shared database across multiple services is a tempting shortcut early on — one schema, no duplication, everyone can just query what they need. It also quietly recreates a monolith at the data layer even after the application code has been split into separate services: a schema change one team needs can break another team’s queries, and any service can technically read or write data that’s conceptually owned by another service, because the database itself enforces no such boundary.</p><p>Database per Service draws that boundary explicitly: every service gets its own database, accessible only through that service’s own API, never queried or written to directly by anyone else. This is what actually makes independent deployment mean something — a service can change its internal schema freely as long as its API contract stays stable, because nothing outside that service could have been depending on the schema’s internal shape to begin with. It’s also what allows each service to pick the storage engine that actually fits its access pattern, rather than every service being stuck with whatever the shared database happens to be.</p><pre># database-per-service-pattern/main.tf — see terraform-database-per-service-pattern.tf for the full file<br>resource &quot;azurerm_mssql_database&quot; &quot;orders&quot; {<br>  name      = &quot;orders-db&quot;<br>  server_id = azurerm_mssql_server.orders.id<br>  sku_name  = &quot;S0&quot;<br>}</pre><pre>resource &quot;azurerm_cosmosdb_account&quot; &quot;inventory&quot; {<br>  name                = &quot;cosmos-inventory-service-sample&quot;<br>  resource_group_name = azurerm_resource_group.dbps_sample.name<br>  location            = azurerm_resource_group.dbps_sample.location<br>  offer_type          = &quot;Standard&quot;<br>}</pre><p><strong>About this sample:</strong> three services, three different storage engines, each picked for what that specific service actually needs — SQL for Orders’ transactional needs, Cosmos DB for Inventory’s flexible schema and write throughput, Table Storage for Shipping’s simple key-based lookups. The boundary that actually enforces “no cross-service database access” in a real deployment is identity and access management — each service’s managed identity granted access to only its own database — which connects directly back to the Managed Identities post from earlier in this newsletter.</p><h3>Index Table</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j-EyBOUgacK7PoSGFFq5Vw.png" /></figure><p>A data store’s primary key or partition key is usually chosen to make the most common query fast — order lookups by order id, for instance. That choice inevitably makes some other, less common query slow: finding every order placed by a given customer’s email address means either scanning across every partition or maintaining a completely separate structure built specifically for that lookup. Most mature relational databases solve this invisibly with secondary indexes. Plenty of NoSQL and distributed stores don’t offer that for free, which is exactly the gap the Index Table pattern fills by hand.</p><p>The pattern is straightforward once named: maintain a second table or container, keyed by whatever alternate field you need fast lookups on, holding just enough information to point back to the full record in the primary store — not a full duplicate of the data, just the key needed to fetch it. Every write to the primary store updates the index table alongside it, the same synchronization discipline Materialized View relies on. In fact, an index table is really just the leanest possible materialized view: instead of precomputing an entire denormalized document, it precomputes nothing but a pointer.</p><pre># index-table-pattern/main.tf — see terraform-index-table-pattern.tf for the full file<br>resource &quot;azurerm_cosmosdb_sql_container&quot; &quot;primary&quot; {<br>  name                = &quot;orders-primary&quot;<br>  partition_key_paths = [&quot;/orderId&quot;]<br>}</pre><pre>resource &quot;azurerm_cosmosdb_sql_container&quot; &quot;email_index&quot; {<br>  name                = &quot;orders-by-email-index&quot;<br>  partition_key_paths = [&quot;/customerEmail&quot;]<br>}</pre><p><strong>About this sample:</strong> two Cosmos containers over the same conceptual dataset, partitioned differently on purpose — the primary container by orderId for fast single-order lookups, the index container by customerEmail for the &quot;find this customer&#39;s orders&quot; query the primary container&#39;s partitioning makes expensive. Keeping the two in sync is application code&#39;s job, typically the same change-feed-triggered Function pattern used to maintain a materialized view, just writing a lightweight pointer instead of a full denormalized copy.</p><h3>How this category ties back to the first two</h3><p>More than any other category in this series so far, these five patterns lean on each other and on patterns already covered. Saga is the general pattern Compensating Transaction specialized. Outbox often feeds the event stream a Saga’s choreography depends on — a service publishing “OrderPlaced” reliably is exactly the problem Outbox solves. Index Table is Materialized View’s simplest possible form. Database per Service is what makes Saga and Outbox necessary in the first place — the moment data isn’t shared, keeping it consistent across services stops being free and starts requiring exactly the kind of deliberate design this whole category is about. None of these five patterns exist in a vacuum, and recognizing how they connect is usually more useful than knowing any one of them in isolation.</p><p><em>PS: The terraform scripts used in this post is available at </em><a href="https://github.com/NerdyThinker/cloud-architecture-samples/tree/main/Data%20Management%20Patterns"><em>cloud-architecture-samples/Data Management Patterns at main · NerdyThinker/cloud-architecture-samples</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2bd1dcb18ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scalability & Performance Patterns: Handling More Without Costing More]]></title>
            <link>https://medium.com/@venugopal.gkp/scalability-performance-patterns-handling-more-without-costing-more-bf326508600f?source=rss-632643c5a5db------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf326508600f</guid>
            <category><![CDATA[cloud-architecture]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <dc:creator><![CDATA[Venugopal Gopalakrishnapillai]]></dc:creator>
            <pubDate>Tue, 18 Aug 2026 03:45:44 GMT</pubDate>
            <atom:updated>2026-08-18T03:45:44.333Z</atom:updated>
            <content:encoded><![CDATA[<p>Reliability patterns, covered in the last post, are mostly about surviving failure gracefully. This category asks a different question: what happens when nothing is actually broken, but there’s simply more load than the system was originally shaped to handle? A launch goes better than planned. A read-heavy dashboard gets popular. A dataset outgrows what a single database node can serve fast. None of these are failures in the traditional sense — they’re success creating pressure the original design never accounted for, and the patterns below are the standard responses once that pressure shows up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wko7fIVisTkveKcw7esgrg.png" /></figure><p>Same structure as the last post: each pattern gets an architecture diagram, a plain explanation of the problem it addresses, and a Terraform sample deploying a small, real version of it in Azure. The code is intentionally minimal — a skeleton worth extending, not something to point straight at production traffic.</p><h3>Cache-Aside</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D8On2pNr11F_dAMd5mpSLQ.png" /></figure><p>Most systems have a small set of reads that get requested constantly and change relatively rarely — a product catalog, a user’s profile, a pricing table. Hitting the database for every single one of those reads wastes capacity on work that’s fundamentally repetitive. Cache-Aside puts a fast, in-memory store in front of the database: the application checks the cache first, and only queries the database on a miss, populating the cache with the result before returning it so the next request for the same data is served from memory instead.</p><p>The name matters here — “aside” because the cache sits beside the application’s data-access logic rather than being transparently baked into the database layer. The application is explicitly responsible for checking it, populating it, and — this is the part that trips people up — deciding when cached data has gone stale enough that it needs a shorter time-to-live or an explicit invalidation on write. A cache with no expiration policy at all isn’t a performance optimization anymore; it’s a second source of truth quietly drifting away from the first.</p><pre># cache-aside-pattern/main.tf — see terraform-cache-aside-pattern.tf for the full file<br>resource &quot;azurerm_redis_cache&quot; &quot;cache_sample&quot; {<br>  name                  = &quot;redis-cache-aside-sample&quot;<br>  resource_group_name   = azurerm_resource_group.cache_sample.name<br>  location              = azurerm_resource_group.cache_sample.location<br>  capacity              = 0<br>  family                = &quot;C&quot;<br>  sku_name              = &quot;Basic&quot;<br>  non_ssl_port_enabled  = false<br>  minimum_tls_version   = &quot;1.2&quot;<br>}</pre><p><strong>About this sample:</strong> an Azure Cache for Redis instance sits alongside a plain App Service. The cache-aside logic — check, fall back, populate with a TTL — lives entirely in application code; nothing about this infrastructure enforces it. The Basic SKU here has no SLA and no persistence, which is fine for a demo and wrong for anything real — Standard or Premium tiers exist specifically for workloads that need either.</p><h3>CQRS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AAwXDGKTuJxhAUW8VU9E1Q.png" /></figure><p>A single data model serving both writes and reads eventually has to compromise between two different sets of needs: a write-optimized schema wants normalization and strict consistency, while a read-optimized schema often wants the opposite — denormalized, pre-joined data shaped exactly for the queries hitting it. CQRS (Command Query Responsibility Segregation) resolves that tension by refusing to force one schema to serve both jobs. Commands go through a write model with its own store; queries go through a completely separate read model, kept in sync through an asynchronous propagation mechanism rather than sharing a database with the write side.</p><p>This is one of the heavier patterns in this list, and it’s worth being direct about that rather than presenting it as a free upgrade. Splitting the model means the read side is only ever eventually consistent with the write side — there’s a real, if usually small, window where a just-written change hasn’t yet appeared in the read store. That’s an acceptable tradeoff for a lot of systems and a genuine problem for a few (anything needing to read its own write immediately). CQRS earns its complexity specifically when read and write load are large enough, or shaped differently enough, that forcing them through one schema was already causing real pain — not as a default architecture applied out of habit.</p><pre># cqrs-pattern/main.tf — see terraform-cqrs-pattern.tf for the full file<br>resource &quot;azurerm_mssql_database&quot; &quot;write_store&quot; {<br>  name      = &quot;cqrs-write-db&quot;<br>  server_id = azurerm_mssql_server.write_store.id<br>  sku_name  = &quot;S0&quot;<br>}</pre><pre>resource &quot;azurerm_cosmosdb_account&quot; &quot;read_store&quot; {<br>  name                = &quot;cosmos-cqrs-read-sample&quot;<br>  resource_group_name = azurerm_resource_group.cqrs_sample.name<br>  location            = azurerm_resource_group.cqrs_sample.location<br>  offer_type          = &quot;Standard&quot;</pre><pre>  consistency_policy {<br>    consistency_level = &quot;Session&quot;<br>  }<br>}</pre><p><strong>About this sample:</strong> Azure SQL handles the normalized write side, Cosmos DB handles the denormalized read side, and a Service Bus topic stands in for the sync mechanism between them. The projection logic that turns a write event into an updated read document is application code, usually a small Function subscribed to the topic — Terraform’s job here is just standing up the three pieces that logic runs on top of.</p><h3>Sharding / Partitioning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5OZOjtUQvIPaI45Y132qWQ.png" /></figure><p>Every single database node has a ceiling on throughput and storage, no matter how large the underlying hardware gets. Sharding gets past that ceiling by splitting data across multiple nodes based on a partition key, so a request for a specific piece of data gets routed to the one node that actually holds it, and the total capacity of the system becomes the sum of every shard’s capacity rather than one node’s limit.</p><p>The partition key choice is, without much competition, the single highest-stakes decision in this entire pattern. A key that distributes evenly across the shard space spreads load the way the pattern intends. A poorly chosen key — one where a large share of traffic concentrates on one value, like partitioning by a status field that’s overwhelmingly “active” — creates a hot shard that ends up carrying most of the load anyway, which defeats the purpose while still paying the operational cost of running a sharded system. Getting this decision right requires understanding the actual query and access patterns before committing to a key, not picking whatever column looks convenient.</p><pre># sharding-pattern/main.tf — see terraform-sharding-pattern.tf for the full file<br>resource &quot;azurerm_cosmosdb_sql_container&quot; &quot;shard_sample&quot; {<br>  name                  = &quot;orders-container&quot;<br>  resource_group_name   = azurerm_resource_group.shard_sample.name<br>  account_name          = azurerm_cosmosdb_account.shard_sample.name<br>  database_name         = azurerm_cosmosdb_sql_database.shard_sample.name<br>  partition_key_paths   = [&quot;/customerId&quot;]<br>  partition_key_version = 2<br>  throughput            = 4000<br>}</pre><p><strong>About this sample:</strong> Cosmos DB’s native partitioning does the actual sharding work here — set a partition key, and Cosmos automatically distributes data and throughput across physical partitions behind the scenes, without provisioning separate “shard” resources by hand the way a self-managed sharded SQL setup would require. customerId is used as the example key specifically because it tends to distribute evenly and lines up with how this kind of data usually gets queried; a different dataset might need a different key entirely.</p><h3>Competing Consumers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1rY2VAqnU5g6Zrw0cUC1rg.png" /></figure><p>Queue-Based Load Leveling, from the reliability post, decouples arrival rate from processing rate using one consumer. Competing Consumers takes that same queue and adds horizontal scale on the processing side: multiple consumer instances all pull from the same queue simultaneously, with the queue’s own delivery guarantee ensuring each message goes to exactly one of them. Need more throughput? Add another consumer instance — no coordination code required between instances, because the queue itself is the coordination.</p><p>What makes this pattern genuinely simple compared to most horizontal-scaling approaches is that the consumers don’t need to know about each other at all. There’s no leader election, no partitioning of work ahead of time, no shared state between instances beyond the queue itself. That simplicity is exactly why it pairs so naturally with serverless compute — a Function App on a Consumption plan will scale its own instance count based on queue depth automatically, which means the “add another consumer” step in this pattern often isn’t a manual decision at all.</p><pre># competing-consumers-pattern/main.tf — see terraform-competing-consumers-pattern.tf for the full file<br>resource &quot;azurerm_servicebus_queue&quot; &quot;work_queue&quot; {<br>  name         = &quot;work-items&quot;<br>  namespace_id = azurerm_servicebus_namespace.cc_sample.id<br>}</pre><pre>resource &quot;azurerm_linux_function_app&quot; &quot;consumers&quot; {<br>  name                       = &quot;func-competing-consumers-sample&quot;<br>  resource_group_name        = azurerm_resource_group.cc_sample.name<br>  location                   = azurerm_resource_group.cc_sample.location<br>  service_plan_id            = azurerm_service_plan.cc_sample.id<br>  storage_account_name       = azurerm_storage_account.cc_sample.name<br>  storage_account_access_key = azurerm_storage_account.cc_sample.primary_access_key<br>}</pre><p><strong>About this sample:</strong> a Service Bus queue feeds a Function App running on a Consumption plan, and Azure Functions handles scaling the instance count that pulls from the queue automatically. Max concurrent calls per instance and the overall scale-out ceiling are set through host.json and the plan&#39;s own settings, not shown here — worth tuning deliberately rather than trusting the defaults once real load shows up.</p><h3>Priority Queue</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PVw3lFk4NxfDsLTeNHEyYg.png" /></figure><p>Not all work waiting in a queue deserves equal treatment. A password-reset email and a weekly digest email might both flow through the same notification system, but one of them has a user actively waiting on it and the other doesn’t. Feed both into a single first-in-first-out queue, and a burst of digest emails can genuinely delay a time-sensitive password reset sitting behind them — a real problem for the user waiting, even though the system is technically working exactly as designed.</p><p>The fix that actually holds up under load is two physically separate queues rather than one queue with a priority field attached to each message. A single mixed queue depends on every consumer correctly sorting by that field, which is easy to get subtly wrong under concurrent access. Two queues make the guarantee structural: a consumer configured to always drain the high-priority queue first, completely, before touching the standard queue, can’t accidentally process things out of order — there’s no sorting logic to get wrong, just a polling order to follow.</p><pre># priority-queue-pattern/main.tf — see terraform-priority-queue-pattern.tf for the full file<br>resource &quot;azurerm_servicebus_queue&quot; &quot;high_priority&quot; {<br>  name         = &quot;high-priority&quot;<br>  namespace_id = azurerm_servicebus_namespace.pq_sample.id<br>}</pre><pre>resource &quot;azurerm_servicebus_queue&quot; &quot;standard_priority&quot; {<br>  name         = &quot;standard-priority&quot;<br>  namespace_id = azurerm_servicebus_namespace.pq_sample.id<br>}</pre><p><strong>About this sample:</strong> two independent Service Bus queues, fed by the same producers but drained by one consumer configured to always check the high-priority queue first. A common refinement worth knowing about: polling the high-priority queue with a short timeout before falling back to the standard queue, rather than blocking on it exclusively, so the standard queue still makes steady progress during quiet periods on the high-priority side.</p><h3>Materialized View</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NQnryF6Jbmsl4KYeXVOeog.png" /></figure><p>Some queries are expensive not because the system is under load, but because the data needed to answer them is spread across multiple tables or containers, and assembling the answer means joining or aggregating all of it on every single request. A dashboard summarizing a customer’s order history might need to touch orders, line items, shipping records, and payment status — expensive to compute live, especially at any real request volume, even though none of the underlying data changes very often.</p><p>A Materialized View precomputes that expensive assembly once, ahead of time, and stores the result in a shape built specifically for the query that needs it. Every write to the source data triggers a recalculation of the affected part of the view — through a change feed, a trigger, or an event — so the view stays synchronized with its source without needing to be recomputed on every read. The tradeoff is the same eventual-consistency lag CQRS accepts, and for good reason: this pattern is really CQRS’s read side, isolated and applied on its own even in systems that haven’t adopted full command/query separation elsewhere.</p><pre># materialized-view-pattern/main.tf — see terraform-materialized-view-pattern.tf for the full file<br>resource &quot;azurerm_cosmosdb_sql_container&quot; &quot;source&quot; {<br>  name                = &quot;orders-source&quot;<br>  partition_key_paths = [&quot;/orderId&quot;]<br>  # ...<br>}</pre><pre>resource &quot;azurerm_cosmosdb_sql_container&quot; &quot;materialized_view&quot; {<br>  name                = &quot;customer-order-summary-view&quot;<br>  partition_key_paths = [&quot;/customerId&quot;]<br>  # ...<br>}</pre><p><strong>About this sample:</strong> two Cosmos containers — a source container with change feed enabled (on by default for Cosmos SQL API containers) and a second container holding the precomputed view — connected by a Function App wired to the change feed trigger. Notice the two containers use different partition keys entirely: the source is partitioned for write patterns, the view is partitioned for how it actually gets read, which is the whole point of separating them in the first place.</p><h3>Auto-scaling / Elastic Scaling</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gARCCdJfvXXHpqnJSDoAGg.png" /></figure><p>Provisioning fixed capacity for peak load means paying for that capacity around the clock, even during the long stretches when actual demand sits well below it. Auto-scaling closes that gap by tying instance count to a live metric — CPU, memory, queue depth, request latency — and letting infrastructure add or remove capacity automatically as that metric crosses defined thresholds, rather than a human deciding in advance how much compute the system will need on a given day.</p><p>This is the one pattern in this entire post where the scaling logic genuinely lives in infrastructure configuration rather than application code — there’s no library to import, no code path to write. That also means the two thresholds (scale out, scale in) and the cooldown period between actions are worth tuning carefully: react too aggressively and the system thrashes, adding and removing instances repeatedly in response to normal metric noise; react too slowly and a genuine spike in demand outruns the system’s ability to respond to it.</p><pre># autoscaling-pattern/main.tf — see terraform-autoscaling-pattern.tf for the full file<br>resource &quot;azurerm_monitor_autoscale_setting&quot; &quot;autoscale_sample&quot; {<br>  name                = &quot;autoscale-app-plan&quot;<br>  resource_group_name = azurerm_resource_group.autoscale_sample.name<br>  location            = azurerm_resource_group.autoscale_sample.location<br>  target_resource_id  = azurerm_service_plan.autoscale_sample.id</pre><pre>  profile {<br>    name = &quot;default&quot;<br>    capacity {<br>      default = 2<br>      minimum = 2<br>      maximum = 10<br>    }<br>    # scale-out and scale-in rules — see full file<br>  }<br>}</pre><p><strong>About this sample:</strong> an azurerm_monitor_autoscale_setting resource attached to an App Service Plan, scaling out when average CPU crosses 70% and back in below 25%, bounded between 2 and 10 instances. CPU is used here purely because it&#39;s the simplest metric to demonstrate — production systems often scale against something closer to actual user-facing pressure, like queue depth or request latency, since CPU doesn&#39;t always track what users actually experience.</p><h3>Where this category tends to combine</h3><p>A few of these patterns show up together often enough that it’s worth naming the pairing directly. Materialized View is close enough to CQRS’s read side that adopting one frequently leads to the other. Competing Consumers usually sits downstream of Queue-Based Load Leveling from the reliability category — the queue absorbs the burst, the consumers scale to drain it. And Sharding often shows up alongside Auto-scaling, since a well-sharded system scales each shard’s compute independently rather than needing to scale one enormous node. As with the reliability patterns, the value here isn’t in applying all seven reflexively — it’s recognizing which specific pressure a system is actually under, and reaching for the pattern shaped to relieve that exact pressure rather than the one that sounds most impressive in an architecture review.</p><p><em>PS: The sample code used in this post is available at </em><a href="https://github.com/NerdyThinker/cloud-architecture-samples"><em>NerdyThinker/cloud-architecture-samples: Simple Terraform script to demonstrate a few cloud patterns</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf326508600f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reliability & Resilience Patterns: Eight Ways to Keep a System Standing]]></title>
            <link>https://medium.com/@venugopal.gkp/reliability-resilience-patterns-eight-ways-to-keep-a-system-standing-196e675ecf4d?source=rss-632643c5a5db------2</link>
            <guid isPermaLink="false">https://medium.com/p/196e675ecf4d</guid>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[sre]]></category>
            <category><![CDATA[cloud-architecture]]></category>
            <dc:creator><![CDATA[Venugopal Gopalakrishnapillai]]></dc:creator>
            <pubDate>Mon, 17 Aug 2026 01:28:26 GMT</pubDate>
            <atom:updated>2026-08-17T01:43:13.303Z</atom:updated>
            <content:encoded><![CDATA[<p>Every pattern in this category answers some version of the same question: what happens the moment something else in your system stops cooperating? A downstream API times out. A database connection pool runs dry. A single instance quietly stops responding while the load balancer keeps sending it traffic anyway. None of these are exotic failure modes — they’re the ordinary Tuesday-afternoon reality of running distributed systems at any real scale, and the difference between a system that shrugs them off and one that cascades into an outage usually comes down to whether these eight patterns were designed in from the start or bolted on after the first incident review.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s1rNPQpY8KCHXBPPYf1iig.png" /></figure><p>Each pattern below gets the same three things: an architecture diagram showing how the pieces fit together, a short explanation of the actual problem it solves, and a Terraform sample deploying a minimal version of it in Azure. The Terraform is deliberately small — enough to stand up the real resources involved and see how they relate, not a production-grade module. Treat it as a starting skeleton to extend, not a copy-paste deployment.</p><h3>Retry</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bWAyramNg7nvYPtThL8lIQ.png" /></figure><p>Most failures a distributed system sees aren’t permanent. A network blip, a momentary spike on the other end, a load balancer mid-rotation — these resolve themselves within milliseconds to seconds, and the correct response is usually just to ask again. The Retry pattern formalizes that instinct: wrap a call to a potentially flaky dependency in logic that automatically re-attempts it, typically with an increasing delay between tries (exponential backoff), so a struggling dependency isn’t immediately hit with a second wave of traffic on top of the first.</p><p>The part worth getting right is knowing which failures deserve a retry and which don’t. A timeout or a 503 is a reasonable candidate. A 400 Bad Request is not — the request was wrong, and sending the identical wrong request three more times just wastes time while looking productive. Getting this distinction wrong is the most common way I’ve seen this pattern implemented badly: someone wraps every outbound call in a generic retry policy without checking which error codes actually represent something transient.</p><pre># retry-pattern/main.tf — see terraform-retry-pattern.tf for the full file<br>resource &quot;azurerm_linux_function_app&quot; &quot;retry_sample&quot; {<br>  name                       = &quot;func-retry-pattern-sample&quot;<br>  resource_group_name        = azurerm_resource_group.retry_sample.name<br>  location                   = azurerm_resource_group.retry_sample.location<br>  service_plan_id            = azurerm_service_plan.retry_sample.id<br>  storage_account_name       = azurerm_storage_account.retry_sample.name<br>  storage_account_access_key = azurerm_storage_account.retry_sample.primary_access_key</pre><pre>  site_config {<br>    application_stack {<br>      dotnet_version = &quot;8.0&quot;<br>    }<br>  }</pre><pre>  app_settings = {<br>    &quot;DOWNSTREAM_RETRY_MAX_ATTEMPTS&quot; = &quot;3&quot;<br>    &quot;DOWNSTREAM_RETRY_BACKOFF_MS&quot;   = &quot;500&quot;<br>  }<br>}</pre><p><strong>About this sample:</strong> the retry logic itself lives in the Function’s code — through the SDK’s built-in retry policy or a library like Polly — not in Terraform. What’s provisioned here is just the Function App the retry logic runs inside. The app settings are documentation for anyone reading the portal more than they are enforced configuration; the real retry count and backoff curve get set in host.json or directly in code.</p><h3>Circuit Breaker</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LbbiP5HlA-VrtBYGoz--Fw.png" /></figure><p>Retry handles a dependency that’s occasionally flaky. Circuit Breaker handles a dependency that’s actually down, and it exists because retrying against something that’s fully unavailable doesn’t help — it just adds load to an already-struggling system while the caller waits out timeout after timeout. A circuit breaker tracks the failure rate of calls to a dependency, and once that rate crosses a threshold, it “opens”: every subsequent call fails immediately, without even attempting the network request, until a cooldown period passes and the breaker allows a single trial call through to check whether the dependency has recovered.</p><p>That immediate failure is the entire value. A caller stuck waiting on a 30-second timeout, repeated across every incoming request, ties up threads and connections that could be serving requests that would actually succeed. A caller getting an instant “unavailable” response can fail gracefully — a cached value, a degraded response, a clear error — and keep the rest of the system responsive while the dependency recovers on its own schedule.</p><pre># circuit-breaker-pattern/main.tf — see terraform-circuit-breaker-pattern.tf for the full file<br>resource &quot;azurerm_linux_web_app&quot; &quot;caller&quot; {<br>  name                = &quot;app-cb-caller-sample&quot;<br>  resource_group_name = azurerm_resource_group.cb_sample.name<br>  location            = azurerm_resource_group.cb_sample.location<br>  service_plan_id     = azurerm_service_plan.cb_sample.id</pre><pre>  site_config {<br>    application_stack {<br>      dotnet_version = &quot;8.0&quot;<br>    }<br>  }</pre><pre>  app_settings = {<br>    &quot;APPLICATIONINSIGHTS_CONNECTION_STRING&quot; = azurerm_application_insights.cb_sample.connection_string<br>    &quot;DOWNSTREAM_URL&quot;                        = &quot;https://${azurerm_linux_web_app.downstream.default_hostname}&quot;<br>    &quot;CIRCUIT_BREAKER_FAILURE_THRESHOLD&quot;     = &quot;5&quot;<br>    &quot;CIRCUIT_BREAKER_OPEN_DURATION_SECONDS&quot; = &quot;30&quot;<br>  }<br>}</pre><p><strong>About this sample:</strong> two App Services stand in for a caller and its downstream dependency, sharing one Application Insights instance — which is what the breaker’s failure-rate tracking typically reports into. The open/closed state machine is application logic, commonly implemented with a library rather than hand-rolled, since getting the threshold and cooldown timing right by hand is easy to get subtly wrong.</p><h3>Bulkhead</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0bCenvXl64mAbG2LqSNTAA.png" /></figure><p>Named after the watertight compartments in a ship’s hull, this pattern isolates resource pools so that one workload consuming all its allotted capacity can’t starve a completely unrelated workload of the resources it needs. A single shared connection pool or thread pool serving every kind of request in a system means a spike in one area — a batch job going haywire, one tenant sending a burst of traffic — can exhaust resources that a completely unrelated, well-behaved request also needed.</p><p>Splitting resource pools by workload, tenant, or priority tier fixes this directly: a premium customer’s requests draw from their own reserved capacity, unaffected by a bulk-tier customer’s traffic spike hammering a separate pool. The tradeoff is straightforward and worth saying plainly — you’re trading some efficiency (idle capacity in one pool while another is under pressure) for isolation, and that trade is worth making exactly when the cost of one workload affecting another is higher than the cost of some underutilized capacity sitting around.</p><pre># bulkhead-pattern/main.tf — see terraform-bulkhead-pattern.tf for the full file<br>resource &quot;azurerm_service_plan&quot; &quot;pool_a&quot; {<br>  name                = &quot;asp-bulkhead-pool-a&quot;<br>  resource_group_name = azurerm_resource_group.bulkhead_sample.name<br>  location            = azurerm_resource_group.bulkhead_sample.location<br>  os_type             = &quot;Linux&quot;<br>  sku_name            = &quot;P1v3&quot;<br>}</pre><pre>resource &quot;azurerm_service_plan&quot; &quot;pool_b&quot; {<br>  name                = &quot;asp-bulkhead-pool-b&quot;<br>  resource_group_name = azurerm_resource_group.bulkhead_sample.name<br>  location            = azurerm_resource_group.bulkhead_sample.location<br>  os_type             = &quot;Linux&quot;<br>  sku_name            = &quot;B1&quot;<br>}</pre><p><strong>About this sample:</strong> two entirely separate App Service Plans, each hosting its own app. That separation is the whole pattern at the infrastructure level — Azure physically can’t let Pool B’s load consume Pool A’s compute, because they’re not sharing compute to begin with. A finer-grained bulkhead inside a single service (separate connection pools per downstream call, for instance) is a code-level concern layered on top of this.</p><h3>Health Endpoint Monitoring</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2aolSyT7aQHlPdgL5Sw-eg.png" /></figure><p>Infrastructure can only route around a failure it knows about, and “the process is still running” is a dangerously low bar for what counts as healthy. A service can be up, accepting connections, and completely unable to serve a real request because its database connection pool is exhausted or a critical downstream dependency is unreachable. Health Endpoint Monitoring closes that gap: expose a dedicated endpoint that actually checks the dependencies a request would need, and have load balancers or traffic managers poll it regularly, pulling any instance that fails the check out of rotation before it serves a broken response to a real user.</p><p>The trap worth naming directly: a /health endpoint that just returns 200 OK unconditionally is worse than not having one, because it creates false confidence. It tells your infrastructure everything is fine right up until a user reports it isn&#39;t. A health check earns its keep only when it verifies the specific things that would actually prevent the service from doing its job.</p><pre># health-endpoint-monitoring-pattern/main.tf — see terraform-health-endpoint-pattern.tf for the full file<br>resource &quot;azurerm_linux_web_app&quot; &quot;health_sample&quot; {<br>  name                = &quot;app-health-endpoint-sample&quot;<br>  resource_group_name = azurerm_resource_group.health_sample.name<br>  location            = azurerm_resource_group.health_sample.location<br>  service_plan_id     = azurerm_service_plan.health_sample.id</pre><pre>  site_config {<br>    health_check_path                 = &quot;/health&quot;<br>    health_check_eviction_time_in_min = 5</pre><pre>    application_stack {<br>      dotnet_version = &quot;8.0&quot;<br>    }<br>  }<br>}</pre><p><strong>About this sample:</strong> alongside the App Service’s built-in health check configuration, an Application Insights availability test polls the /health endpoint from outside Azure&#39;s network entirely — the same vantage point a real user&#39;s request would have, which catches failures a purely internal check might miss (DNS issues, regional connectivity problems, and so on).</p><h3>Throttling / Rate Limiting</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xEgHagU_CDiGASgCi_eVJw.png" /></figure><p>A backend service has a capacity it can sustainably serve, and beyond that point, performance for every caller degrades rather than just the caller sending the most traffic. Throttling enforces a limit — calls per minute, per API key, per client — before a request ever reaches the backend, rejecting excess traffic with a clear signal (an HTTP 429) rather than letting the backend degrade silently under load it was never sized for.</p><p>It’s worth framing this pattern accurately: a rate limit isn’t a punishment aimed at any particular caller, it’s a documented promise about what the system can sustain. A well-designed API communicates its limits clearly and returns a Retry-After header so a well-behaved client knows exactly when to try again, rather than hammering the limit repeatedly and wasting both sides&#39; time.</p><pre># throttling-pattern/main.tf — see terraform-throttling-pattern.tf for the full file<br>resource &quot;azurerm_api_management_api_policy&quot; &quot;rate_limit&quot; {<br>  api_name            = azurerm_api_management_api.backend_api.name<br>  api_management_name = azurerm_api_management.throttle_sample.name<br>  resource_group_name = azurerm_resource_group.throttle_sample.name</pre><pre>  xml_content = &lt;&lt;XML<br>&lt;policies&gt;<br>  &lt;inbound&gt;<br>    &lt;base /&gt;<br>    &lt;rate-limit-by-key calls=&quot;100&quot; renewal-period=&quot;60&quot;<br>      counter-key=&quot;@(context.Subscription.Key)&quot; /&gt;<br>  &lt;/inbound&gt;<br>  &lt;backend&gt;&lt;base /&gt;&lt;/backend&gt;<br>  &lt;outbound&gt;&lt;base /&gt;&lt;/outbound&gt;<br>  &lt;on-error&gt;&lt;base /&gt;&lt;/on-error&gt;<br>&lt;/policies&gt;<br>XML<br>}</pre><p><strong>About this sample:</strong> Azure API Management sits in front of a plain backend App Service and enforces the limit through a policy applied at the API level — the backend itself never needs to know throttling exists. The Developer SKU used here keeps the sample cheap to stand up; it carries no SLA and shouldn’t front real production traffic.</p><h3>Queue-Based Load Leveling</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hSTV8xUj9HZdzXCeDJc74g.png" /></figure><p>Demand rarely arrives at a steady, predictable pace, and a system sized for average load gets overwhelmed the moment real-world burstiness shows up — a marketing email goes out, a batch job kicks off, a client retries aggressively during an incident. Queue-Based Load Leveling decouples the rate work arrives from the rate it gets processed: a producer writes to a queue and returns immediately, and a consumer drains that queue at whatever pace it can sustainably handle, buffering the difference between the two instead of forcing them to match.</p><p>This is one of the oldest and most broadly applicable patterns in the category, and it’s worth noticing how often it shows up disguised as something else — a message broker between microservices, a job queue behind a web form submission, an event stream feeding a processing pipeline. The shape is always the same: absorb the burst somewhere that can hold it, and let the processing side move at a pace it actually controls.</p><pre># queue-based-load-leveling-pattern/main.tf — see terraform-queue-load-leveling-pattern.tf for the full file<br>resource &quot;azurerm_storage_queue&quot; &quot;work_queue&quot; {<br>  name                 = &quot;work-items&quot;<br>  storage_account_name = azurerm_storage_account.qbll_sample.name<br>}</pre><pre>resource &quot;azurerm_linux_function_app&quot; &quot;consumer&quot; {<br>  name                       = &quot;func-qbll-consumer-sample&quot;<br>  resource_group_name        = azurerm_resource_group.qbll_sample.name<br>  location                   = azurerm_resource_group.qbll_sample.location<br>  service_plan_id            = azurerm_service_plan.qbll_sample.id<br>  storage_account_name       = azurerm_storage_account.qbll_sample.name<br>  storage_account_access_key = azurerm_storage_account.qbll_sample.primary_access_key</pre><pre>  site_config {<br>    application_stack {<br>      dotnet_version = &quot;8.0&quot;<br>    }<br>  }<br>}</pre><p><strong>About this sample:</strong> a Storage Queue sits between an (unshown) producer and a queue-triggered Function App consumer running on a Consumption plan, which scales its instance count based on queue depth automatically. For higher-throughput or ordering-sensitive workloads, a Service Bus queue — with sessions and dead-lettering — is usually the better production choice; Storage Queues are used here purely because they’re the fastest thing to stand up for a demonstration.</p><h3>Compensating Transaction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xi9bRVexwHu4Lgx-2pNS3A.png" /></figure><p>Once a process spans multiple independent services, there’s no single database transaction that can wrap the whole thing and roll it back atomically if something fails halfway through. Booking a trip might mean reserving a flight, then a hotel, then charging a card — three separate systems, three separate calls, no shared transaction boundary connecting them. If the payment charge fails after the flight and hotel are already booked, something has to actively undo that earlier work, because nothing is going to undo it automatically.</p><p>That’s the entire idea behind a Compensating Transaction: for every step in a multi-step process, define an explicit inverse operation, and if a later step fails, walk back through the completed steps in reverse, running each one’s compensation. It’s not a rollback in the database sense — it’s closer to writing a second, corrective business transaction that cancels the effect of the first one, which means compensations need to be designed as carefully as the original steps, including handling the case where the compensation itself fails.</p><pre># compensating-transaction-pattern/main.tf — see terraform-compensating-transaction-pattern.tf for the full file<br>resource &quot;azurerm_linux_function_app&quot; &quot;orchestrator&quot; {<br>  name                       = &quot;func-saga-orchestrator-sample&quot;<br>  resource_group_name        = azurerm_resource_group.saga_sample.name<br>  location                   = azurerm_resource_group.saga_sample.location<br>  service_plan_id            = azurerm_service_plan.saga_sample.id<br>  storage_account_name       = azurerm_storage_account.saga_sample.name<br>  storage_account_access_key = azurerm_storage_account.saga_sample.primary_access_key</pre><pre>  site_config {<br>    application_stack {<br>      dotnet_version = &quot;8.0&quot;<br>    }<br>  }</pre><pre>  app_settings = {<br>    &quot;AzureFunctionsJobHost__extensions__durableTask__hubName&quot; = &quot;BookingSagaHub&quot;<br>  }<br>}</pre><p><strong>About this sample:</strong> this provisions a Durable Functions app — Azure’s native fit for orchestrating exactly this kind of multi-step process with compensation logic. The orchestrator function and each activity (BookFlight, BookHotel, ChargePayment, and their compensating counterparts) are application code deployed on top of this infrastructure; Terraform’s job here is just the hosting plan and the storage account Durable Functions needs for its task hub state.</p><h3>Deployment Stamps</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5tX61mmmU-onoQV64Li8rg.png" /></figure><p>Scaling a system by adding more servers to a single deployment has a ceiling — eventually the database, the region, or the deployment itself becomes the bottleneck, and no amount of additional compute fixes that. Deployment Stamps takes a different approach: instead of scaling one big deployment, replicate the entire stack — app, database, storage, everything — as an independent, self-contained unit, and add more stamps as demand grows or as new regions or customer segments need to be served.</p><p>The property this buys that a single scaled-up deployment can’t match is failure isolation at the infrastructure level, not just the application level: a full outage in one stamp — a regional Azure incident, a bad deployment, a database going sideways — has no path to affecting any other stamp, because they don’t share anything. It’s a heavier pattern than most of the others in this list, and it’s usually reserved for systems where either massive scale or strict regional isolation (data residency requirements, for instance) makes it worth the operational overhead of running and keeping multiple independent stacks in sync.</p><pre># deployment-stamps-pattern/main.tf — see terraform-deployment-stamps-pattern.tf for the full file<br>locals {<br>  regions = {<br>    eastus     = &quot;East US&quot;<br>    westeurope = &quot;West Europe&quot;<br>  }<br>}</pre><pre>resource &quot;azurerm_linux_web_app&quot; &quot;stamp&quot; {<br>  for_each            = local.regions<br>  name                = &quot;app-stamp-${each.key}-sample&quot;<br>  resource_group_name = azurerm_resource_group.stamp[each.key].name<br>  location            = azurerm_resource_group.stamp[each.key].location<br>  service_plan_id     = azurerm_service_plan.stamp[each.key].id</pre><pre>  site_config {<br>    application_stack {<br>      dotnet_version = &quot;8.0&quot;<br>    }<br>  }<br>}</pre><p><strong>About this sample:</strong> the for_each over a region map is the part worth paying attention to — adding a third stamp for a new region means adding one line to the regions map, and Terraform provisions an entire independent stack for it without anything else in the file changing. A shared Azure Front Door profile sits in front of all the stamps, routing traffic to whichever one is healthy and closest — tying this pattern directly back to Health Endpoint Monitoring, since Front Door&#39;s routing decisions depend on exactly the kind of health probe covered above.</p><h3>Where these patterns actually combine</h3><p>None of these eight exist in isolation in a real system, and it’s worth closing on that rather than treating the list as eight independent choices. A queue-based load leveling setup often sits in front of a consumer that itself uses retry and circuit breaker logic against its own downstream dependencies. A deployment stamp’s health depends entirely on health endpoint monitoring working correctly within it. Bulkheads and throttling frequently get applied together — isolating pools and limiting what each pool can consume are two sides of the same capacity-protection coin. The skill this category actually rewards isn’t memorizing eight names; it’s recognizing which combination of these a specific failure mode in front of you actually calls for, and being honest about which ones would just be unnecessary weight for the problem you have today.</p><p>The samples mentioned in this post are available at <a href="https://github.com/NerdyThinker/cloud-architecture-samples">NerdyThinker/cloud-architecture-samples: Sample Terraform script for some cloud patterns</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=196e675ecf4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloud Architectural Patterns: A Field Guide for Systems That Actually Survive Production]]></title>
            <link>https://medium.com/@venugopal.gkp/cloud-architectural-patterns-a-field-guide-for-systems-that-actually-survive-production-f310a7bd2b14?source=rss-632643c5a5db------2</link>
            <guid isPermaLink="false">https://medium.com/p/f310a7bd2b14</guid>
            <category><![CDATA[cloud-architecture]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[distributed-system-design]]></category>
            <dc:creator><![CDATA[Venugopal Gopalakrishnapillai]]></dc:creator>
            <pubDate>Sun, 16 Aug 2026 01:28:25 GMT</pubDate>
            <atom:updated>2026-08-16T01:28:25.752Z</atom:updated>
            <content:encoded><![CDATA[<p>Almost nobody invents an architectural pattern at a whiteboard. Patterns get discovered the hard way — a downstream service goes down at 2 a.m. and takes the entire upstream system with it because nothing was isolating the failure, or a database gets hammered into the ground because every read and every write were fighting over the same table, or a migration stalls for a year because someone tried to cut a monolith in half in one weekend instead of routing traffic through it gradually. A pattern, at its core, isn’t a clever idea — it’s the accumulated scar tissue of systems that broke, written down so the next architect doesn’t have to relearn the lesson at 2 a.m. themselves.</p><p>This is the first post in a new series on cloud architectural patterns — the reusable, named solutions to problems that show up again and again once a system has to survive real production traffic, real failures, and real scale. Each pattern in this series gets the same treatment: what problem it actually solves, what it costs you in exchange, and when reaching for it is the right call versus when it’s just complexity you didn’t need yet. That last part matters more than people give it credit for — a pattern applied to a problem you don’t actually have is just architecture theater, and knowing when <em>not</em> to reach for one is as much a part of the skill as knowing the pattern itself.</p><h3>What makes something a “pattern” rather than just a technique</h3><p>A pattern earns the name when it has four things: a recurring problem specific enough to recognize on sight, a named solution other engineers will already understand when you say it out loud, real tradeoffs that don’t disappear just because the pattern is well-known, and a context where it’s the right call — which, by implication, means other contexts where it very much isn’t. “Circuit Breaker” means something specific the moment you say it in a design review, the same way “Singleton” or “Observer” does in object-oriented design. That shared vocabulary is most of the value — it lets an architecture conversation skip the re-explanation and go straight to whether this particular pattern fits this particular problem.</p><h3>The pattern catalog this series will work through</h3><p>Rather than a random walk through interesting ideas, this series is organized around the categories of problems patterns actually solve. Here’s the full map — what’s coming, grouped by the kind of failure or pressure each category exists to handle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BwHO2EuppMhm-nRxR1Rz6Q.png" /></figure><h3>Reliability &amp; resilience patterns</h3><p><em>What keeps a system standing when a dependency fails, slows down, or disappears</em></p><ul><li><strong>Retry</strong> — handling transient failures without giving up on the first blip</li><li><strong>Circuit Breaker</strong> — stopping a system from hammering a dependency that’s already down</li><li><strong>Bulkhead</strong> — isolating failures so one overloaded component can’t sink the whole ship</li><li><strong>Health Endpoint Monitoring</strong> — letting infrastructure actually know when something’s unhealthy</li><li><strong>Throttling / Rate Limiting</strong> — protecting a system from being overwhelmed by its own callers</li><li><strong>Queue-Based Load Leveling</strong> — smoothing out bursty demand instead of letting it crash straight into your backend</li><li><strong>Compensating Transaction</strong> — undoing partial work cleanly when a multi-step process fails partway through</li><li><strong>Deployment Stamps / Geodes</strong> — scaling reliability by replicating whole units of infrastructure across regions</li></ul><h3>Scalability &amp; performance patterns</h3><p><em>What lets a system handle more load without a linear increase in cost or complexity</em></p><ul><li><strong>Cache-Aside</strong> — keeping expensive reads out of the hot path</li><li><strong>CQRS (Command Query Responsibility Segregation)</strong> — separating how a system is written to from how it’s read from</li><li><strong>Sharding / Partitioning</strong> — splitting data so no single node has to carry the whole load</li><li><strong>Competing Consumers</strong> — scaling processing horizontally by letting multiple workers pull from one queue</li><li><strong>Priority Queue</strong> — making sure urgent work doesn’t wait behind a backlog of low-priority work</li><li><strong>Materialized View</strong> — precomputing expensive queries instead of recalculating them every time</li><li><strong>Auto-scaling / Elastic Scaling</strong> — matching capacity to demand instead of provisioning for peak, always</li></ul><h3>Data management &amp; consistency patterns</h3><p><em>What keeps data trustworthy once a single database is no longer the whole story</em></p><ul><li><strong>Event Sourcing</strong> — storing every change as an event instead of just the current state</li><li><strong>Saga Pattern</strong> — coordinating a transaction that spans multiple services without a single ACID transaction to lean on</li><li><strong>Outbox Pattern</strong> — making sure a database write and a message publish don’t drift out of sync</li><li><strong>Database per Service</strong> — giving up a shared database in exchange for real service independence</li><li><strong>Index Table</strong> — enabling fast lookups on data that wasn’t modeled for the query you actually need</li></ul><h3>Messaging &amp; integration patterns</h3><p><em>What lets independently deployed services actually talk to each other reliably</em></p><ul><li><strong>Publish-Subscribe</strong> — broadcasting an event to every interested party without the sender needing to know who they are</li><li><strong>Message Queue / Point-to-Point Channel</strong> — decoupling a sender from a receiver in both time and availability</li><li><strong>Claim Check</strong> — keeping large payloads out of the message itself</li><li><strong>Choreography vs. Orchestration</strong> — deciding whether services react to events independently or a central coordinator directs them</li><li><strong>Scatter-Gather</strong> — fanning a request out to multiple services and reassembling the responses</li></ul><h3>Design &amp; structural patterns</h3><p><em>What shapes how services are organized and how they front the systems behind them</em></p><ul><li><strong>Sidecar</strong> — attaching cross-cutting functionality to a service without modifying the service itself</li><li><strong>Ambassador</strong> — offloading networking concerns like retries and monitoring into a proxy</li><li><strong>Anti-Corruption Layer</strong> — protecting a clean domain model from a messy legacy system’s assumptions</li><li><strong>Backends for Frontends (BFF)</strong> — giving each client type its own tailored backend instead of one generic API everyone has to compromise around</li><li><strong>API Gateway (Routing, Aggregation, Offloading)</strong> — centralizing what would otherwise be duplicated at every service’s edge</li><li><strong>Strangler Fig</strong> — migrating off a legacy system gradually, routing traffic slice by slice instead of a single risky cutover</li></ul><h3>Security patterns</h3><p><em>What protects a system without making every service reinvent its own security model</em></p><ul><li><strong>Gatekeeper</strong> — putting a dedicated, hardened component between untrusted input and your actual system</li><li><strong>Federated Identity</strong> — delegating authentication instead of every service managing its own user store</li><li><strong>Valet Key</strong> — handing out limited, scoped access to a resource instead of a broad credential</li><li><strong>Managed Identity</strong> — eliminating credentials between Azure resources entirely</li></ul><h3>Deployment &amp; release patterns</h3><p><em>What makes shipping changes safer than “push to production and hope”</em></p><ul><li><strong>Blue-Green Deployment</strong> — cutting over between two full environments instead of upgrading one in place</li><li><strong>Canary Release</strong> — rolling a change out to a small slice of traffic before trusting it with everyone</li><li><strong>Feature Flags / Toggles</strong> — decoupling deploying code from releasing a feature</li></ul><h3>How this series will run</h3><p>Same format throughout: the problem the pattern solves, a simple diagram, a plain-language walkthrough of how it actually works, and — the part I think matters most and gets skipped most often — a clear-eyed section on when this pattern is overkill. Patterns are easy to over-apply once you know them; half the architectural bloat I’ve seen in real systems wasn’t from ignorance of patterns, it was from reaching for one that solved a problem the system didn’t actually have yet.</p><p>I’ll move roughly category by category, starting with reliability and resilience patterns next, since those tend to be the ones that get skipped until the first real outage makes them non-negotiable — and by then, retrofitting them is a much bigger job than designing with them in mind from the start.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f310a7bd2b14" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Train/Test/Validation Splits and Why Cross-Validation Exists]]></title>
            <link>https://medium.com/@venugopal.gkp/train-test-validation-splits-and-why-cross-validation-exists-6e215a6479d1?source=rss-632643c5a5db------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e215a6479d1</guid>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Venugopal Gopalakrishnapillai]]></dc:creator>
            <pubDate>Sat, 25 Jul 2026 13:16:30 GMT</pubDate>
            <atom:updated>2026-07-25T13:16:30.446Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>In this post:</strong></p><ul><li>Why the last post’s whole lesson depends on a habit, not a formula</li><li>Training, validation, and test sets — three piles with three different jobs</li><li>The one rule that’s easy to state and surprisingly easy to break by accident</li><li>What cross-validation actually adds on top of a simple split</li><li>A couple of ways I’ve seen this go wrong, including my own</li></ul><p>The overfitting post ended with a habit: never trust a number you got from data the model was allowed to study. This post is really just that one sentence, unpacked into an actual workflow — because knowing the rule and actually building your process around it turn out to be two different skills, and I learned that the slightly embarrassing way.</p><p>In one of my earlier projects, I built a model, checked its performance, wasn’t happy with the score, tweaked a setting, checked again, tweaked again, and repeated that loop a good dozen times until the number looked respectable. I felt pretty good about it. What I didn’t clock until much later was that I’d been checking that “final” score against the same batch of data the whole time — which meant every single tweak was, in a small way, quietly fitting itself to that one specific batch. I hadn’t touched the training data directly, but I’d let information about it leak into my decisions anyway, over and over, one adjustment at a time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KRRTW5ZtKO-5vBMVMpLvIg.png" /></figure><h3>Three piles, three different jobs</h3><p>The fix for this is to split your data into three separate piles before you do anything else, and to be strict about which one gets used for what.</p><p>The <strong>training set</strong> — usually the largest chunk, something like 60% of your data — is what the model actually learns its patterns from. This is the equivalent of studying from the textbook itself, over and over, until the material sinks in.</p><p>The <strong>validation set</strong> — often around 20% — is where you check how different settings perform, while you’re still deciding things like how deep a tree should grow or how many neighbors a KNN model should consider. This is your practice test: you can take it as many times as you want, adjust your approach based on how you did, and take it again. Nothing about using it repeatedly during tuning is a problem, because you already know going in that you’re allowed to learn from it and adjust.</p><p>The <strong>test set</strong> — the remaining chunk, roughly 20% — is the one that has to stay completely untouched until the very end. This is exam day. You don’t get to see the questions in advance, you don’t get a second attempt if you don’t like the score, and critically, you don’t get to go back and tweak your model afterward based on how it did and then call that same test set score your final answer. The moment you do that, it’s stopped being a test and quietly turned into another validation set — it’s just one you’re lying to yourself about.</p><p>That’s exactly the mistake I made. I was using what I called my “test set” the same way I should have been using a validation set — checking it, adjusting based on what I saw, checking again. By the time I was done, my reported score wasn’t measuring how the model would perform on data it had never influenced my decisions with. It was measuring how well I’d managed to tune the model to one particular batch of data through a dozen rounds of trial and error, which is a completely different, much less honest number.</p><h3>Why a single validation set isn’t always enough</h3><p>A plain train/validation/test split works well, but it has a specific weakness: your validation score depends on which particular slice of data happened to land in that validation pile. If you got a slightly unusual or unrepresentative slice — by pure chance — your validation score might mislead you about which settings are actually best, the same way one unusually easy practice test might make you overconfident about a topic you haven’t actually mastered.</p><p>Cross-validation fixes this by not settling for just one validation slice. In the most common version — k-fold cross-validation — you split your training data into several equal chunks, called folds (five is a common choice). Then you run the whole training-and-validation process multiple times: each round, one fold takes a turn being the validation set while the rest serve as training data, and you rotate through until every fold has had exactly one turn in the validation seat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NeyoCfNRvokTnwzKwXXDCw.png" /></figure><p>At the end, instead of one validation score that might have gotten lucky or unlucky based on which data happened to land where, you’ve got five separate scores, and you average them. A model that does consistently well across all five folds is a genuinely more trustworthy result than a model that happened to do well on one particular slice. It’s a bit like retaking a practice test using five different versions of it instead of just one, and trusting the average of all five scores over any single attempt — a strong performance on one version tells you less than consistent performance across several.</p><p>The tradeoff is straightforward: cross-validation means training your model multiple times instead of once, which costs more computing time. For small-to-medium datasets, that cost is almost always worth paying, because the reliability you gain is significant. For very large datasets or very expensive models to train, a single validation split is sometimes the practical compromise, and that’s a reasonable call to make deliberately rather than a shortcut to fall into by accident.</p><h3>The actual takeaway</h3><p>The discipline here isn’t complicated, but it’s the kind of thing that’s easy to violate without realizing you’re doing it, exactly the way I did. Training data teaches the model. Validation data — checked as many times as you like, ideally across several folds rather than just one slice — guides your tuning decisions. Test data gets touched exactly once, at the very end, and whatever score comes back is the number you report, whether you like it or not. The system only works if you’re honest with yourself about which pile you’re currently using and why — and the one time I wasn’t, I ended up with a very confident number that had almost nothing to do with how the model would actually perform in the real world.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e215a6479d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Overfitting vs. Underfitting: The Bias-Variance Tradeoff, Illustrated]]></title>
            <link>https://medium.com/@venugopal.gkp/overfitting-vs-underfitting-the-bias-variance-tradeoff-illustrated-24798f766fa1?source=rss-632643c5a5db------2</link>
            <guid isPermaLink="false">https://medium.com/p/24798f766fa1</guid>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Venugopal Gopalakrishnapillai]]></dc:creator>
            <pubDate>Fri, 17 Jul 2026 11:28:24 GMT</pubDate>
            <atom:updated>2026-07-17T11:30:37.500Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>In this post:</strong></p><ul><li>Why a model that aces its own training data can still fail in the real world</li><li>Underfitting vs. overfitting, explained without jargon first</li><li>The classic U-shaped curve, and why it’s the most useful chart in this whole series</li><li>Why “just make the model more complex” is a trap, not a strategy</li><li>A few practical habits that catch this early</li></ul><p>A few months into learning this stuff, I built a model for a class assignment and got genuinely excited when it scored something like 99% accuracy on the data I’d trained it on. I remember actually messaging a classmate about it. Then I ran the same model on a fresh batch of test data it had never seen, and the accuracy fell off a cliff — somewhere in the 60s. I didn’t understand what had happened until my professor used a phrase that’s stuck with me ever since: “your model didn’t learn the pattern. It memorized the answer key.”</p><p>That’s overfitting, and it’s one of those ideas that sounds abstract right up until it happens to you personally, at which point it becomes permanently, uncomfortably obvious.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7f2QPMEBRhQ-VXk65Qvr_g.png" /></figure><p><strong>Underfitting</strong> is what happens when your model is too simple to capture the real shape of the data. Force a straight line through data that’s genuinely curved, and it’ll do a mediocre job everywhere — not terrible on any single point, but never quite right either, because a straight line just doesn’t have the shape needed to follow the actual pattern. The telltale sign of underfitting is that the model performs poorly even on the data it was trained on. It’s not that it’s failing to generalize — it never learned the pattern well enough in the first place, on data it had every opportunity to study closely.</p><p><strong>Overfitting</strong> is the opposite failure, and it’s the one that fools people, because on the surface it looks like success. An overfit model doesn’t just capture the real pattern — it also captures the noise: the random, meaningless wiggle in your specific training data that has nothing to do with the actual underlying relationship. Given enough flexibility, a model can weave a curve that passes almost exactly through every single training point, achieving a training score that looks incredible. The problem is that noise, by definition, doesn’t repeat. The next batch of data will have its own random wiggle, different from the first batch’s, and a model that memorized the first batch’s specific noise has learned something that actively hurts it on the second batch.</p><p><strong>The good fit</strong>, sitting between those two failures, captures the real curve without chasing the noise around it. It won’t score 99% on the training data — it’ll leave some error on the table, because some of what’s in the training data genuinely is unpredictable noise that no honest model should try to explain. But that small, honest gap is exactly what lets it perform consistently on new data it hasn’t seen, which is the only kind of performance that actually matters once a model leaves your notebook.</p><h3>The chart that makes this click</h3><p>Here’s the single most useful diagram in this entire series, and once it clicks, overfitting stops being a scary term and becomes something you can spot on a graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Th1CwaS8xAhhclxyEKnJgA.png" /></figure><p>Plot model complexity along the bottom — think of it as how many parameters or how much flexibility you’re allowing the model to have. Plot error up the side, and draw two separate lines: one for error on the training data, one for error on a held-out test set the model never got to study.</p><p>The training error line does something almost boring: it just keeps going down as complexity increases. More flexibility always lets a model fit its own training data better — that part isn’t surprising. The test error line is the interesting one. It also drops at first, because a model that’s too simple genuinely does improve as you give it more capacity to capture the real pattern. But past a certain point, it turns around and starts climbing back up, even while the training error keeps falling. That turning point is the moment the model stops learning the real pattern and starts memorizing noise instead — the exact moment overfitting begins.</p><p>That U-shape is the whole concept, in one picture. The sweet spot isn’t “as complex as possible” and it isn’t “as simple as possible” — it’s the specific point where the test error line bottoms out, and everything past that point is the model getting better at a test it’s already seen and worse at the one that actually matters.</p><h3>Why “just add more complexity” is such a tempting trap</h3><p>I understand the instinct, because I fell for it myself in that class assignment: if the model’s accuracy isn’t good enough, adding more features, more depth, more flexibility feels like the obvious fix. And it works — right up until you check the training accuracy against a number that means something, rather than treating a 99% training score as the finish line.</p><p>The habit that actually catches this is embarrassingly simple, and it’s the entire reason the “train/test split” idea from a couple of posts back exists: never trust a number you got from data the model was allowed to study. Always check performance on data it never saw during training. If training accuracy is climbing and test accuracy is falling, or even just flattening out while training keeps improving, that gap between the two numbers is the tell. It’s not a subtle signal once you know to look for it — the gap between “how well did it do on data it memorized” and “how well did it do on data it never saw” is one of the most honest diagnostics available in this entire field.</p><h3>The actual takeaway</h3><p>The uncomfortable truth about that class assignment is that my 99% training accuracy wasn’t a win I’d earned — it was a warning sign I misread as a victory lap. The fix wasn’t a better algorithm. It was pulling back on complexity until the training and test numbers stopped disagreeing with each other so dramatically, and accepting a lower, less flattering training score in exchange for a model that actually held up on data it hadn’t already seen.</p><p>Every technique in later posts in this series — regularization, cross-validation, ensemble methods that deliberately average out individual mistakes — is, underneath the specific mechanics, some version of managing this same tradeoff. Learn to recognize the U-shape now, and a surprising amount of what comes later stops feeling like new material and starts feeling like a variation on a theme you already understand.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24798f766fa1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>