<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alok Ranjan Daftuar</title>
    <description>The latest articles on DEV Community by Alok Ranjan Daftuar (@aloknecessary).</description>
    <link>https://dev.to/aloknecessary</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3791551%2F62fbfeb5-1fba-4e79-bc4b-780b7ce52748.jpg</url>
      <title>DEV Community: Alok Ranjan Daftuar</title>
      <link>https://dev.to/aloknecessary</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aloknecessary"/>
    <language>en</language>
    <item>
      <title>Cloud Cost Architecture: Engineering FinOps Into the System, Not Onto It</title>
      <dc:creator>Alok Ranjan Daftuar</dc:creator>
      <pubDate>Mon, 20 Jul 2026 09:30:40 +0000</pubDate>
      <link>https://dev.to/aloknecessary/cloud-cost-architecture-engineering-finops-into-the-system-not-onto-it-5362</link>
      <guid>https://dev.to/aloknecessary/cloud-cost-architecture-engineering-finops-into-the-system-not-onto-it-5362</guid>
      <description>&lt;p&gt;Cost is an architectural concern, not a finance concern. The decisions that determine your cloud bill are made in pull requests touching Terraform files and Kubernetes manifests — weeks before the invoice arrives. By the time finance highlights the line items, the spend has already happened.&lt;/p&gt;

&lt;p&gt;Cloud waste consumes 30–50% of cloud budgets. The bulk is not accidental extravagance — it is the accumulated result of architectural decisions made without cost visibility at the time they were made.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. FinOps Maturity — Where You Actually Are
&lt;/h2&gt;

&lt;p&gt;Most organisations overestimate their maturity by one stage. The diagnostic: can you tell, within five minutes, which team or service generated a specific line item on last month's bill? If not, you're in Crawl regardless of how sophisticated your dashboard looks.&lt;/p&gt;

&lt;p&gt;Most organisations see 15–20% waste reduction from showback alone — just making costs visible changes behaviour.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Commitment Tiers as Architecture Decisions
&lt;/h2&gt;

&lt;p&gt;The commitment model constrains the operational assumptions your workload can make:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;On-Demand&lt;/strong&gt; — unpredictable burst, new workloads not yet baselined&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Savings Plans&lt;/strong&gt; — 20–66% discount, flexible across instance types&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reserved Instances&lt;/strong&gt; — 40–72% discount, locked to specific instance family&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Spot/Preemptible&lt;/strong&gt; — up to 90% discount, two-minute eviction notice&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The rule: baseline on on-demand for 2–4 weeks before committing. Savings Plans before Reserved Instances for flexibility.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Cost Allocation Tagging
&lt;/h2&gt;

&lt;p&gt;Only 22% of companies have allocated 75%+ of their cloud costs. The gap is almost always a tagging gap.&lt;/p&gt;

&lt;p&gt;Four mandatory tags enforced at provisioning time: &lt;code&gt;team&lt;/code&gt;, &lt;code&gt;environment&lt;/code&gt;, &lt;code&gt;service&lt;/code&gt;, &lt;code&gt;cost-centre&lt;/code&gt;. Resources without them are rejected at creation — not documented for later.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Showback Before Chargeback
&lt;/h2&gt;

&lt;p&gt;Chargeback requires teams to trust the attribution model. That trust requires correct tags, understood allocation logic, and fair shared-cost treatment. None of that exists at the Crawl stage.&lt;/p&gt;

&lt;p&gt;Introduce showback first, run it for a full quarter, fix attribution disputes, then move to chargeback.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Kubernetes Cost Attribution
&lt;/h2&gt;

&lt;p&gt;When 50 services share a node pool, standard billing reports are useless. OpenCost (CNCF) and Kubecost provide per-pod and per-namespace cost breakdowns based on actual utilisation relative to node cost.&lt;/p&gt;

&lt;p&gt;ResourceQuotas are the Kubernetes-native cost governance primitive — apply one to every tenant namespace.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Pipeline Cost Gates
&lt;/h2&gt;

&lt;p&gt;The highest-leverage FinOps capability: a cost gate in CI/CD that shows projected cost impact before merge. Infracost analyses Terraform plans and returns a monthly dollar diff in the pull request.&lt;/p&gt;

&lt;p&gt;If the projected increase exceeds a threshold, the check fails and the PR cannot merge without explicit override.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. Guardrails That Block, Not Just Alert
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Instance type restrictions&lt;/strong&gt; — SCPs/Azure Policy restrict GPU and large families in non-production&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Idle resource cleanup&lt;/strong&gt; — unattached volumes, orphaned IPs detected and remediated by policy&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dev environment cost caps&lt;/strong&gt; — CronJobs scale non-production to zero outside business hours&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  8. Structural Wastes to Eliminate First
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Egress cost from co-located-on-prem services now crossing AZs&lt;/li&gt;
&lt;li&gt;Overprovisioned node pools with untuned autoscaler scale-down&lt;/li&gt;
&lt;li&gt;Cross-region data transfer not modelled before architecture decisions&lt;/li&gt;
&lt;li&gt;Unused reserved capacity below 70% utilisation&lt;/li&gt;
&lt;li&gt;Storage in standard tiers that should be in lifecycle-managed cold storage&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Read the Full Article
&lt;/h2&gt;

&lt;p&gt;This is a summary of the fourth post in the Cloud Architecture series. The full article includes Infracost GitHub Actions workflow, Azure Policy JSON for tag enforcement, Kubernetes ResourceQuota and CronJob manifests, commitment tier decision matrix, and a comprehensive cost architecture checklist:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;👉 &lt;a href="https://aloknecessary.github.io/blogs/cloud-cost-architecture/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=blog_syndication&amp;amp;utm_content=cloud-cost-architecture" rel="noopener noreferrer"&gt;Cloud Cost Architecture: Engineering FinOps Into the System, Not Onto It — Full Article&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;FinOps Crawl/Walk/Run maturity assessment with next actions per stage&lt;/li&gt;
&lt;li&gt;Commitment tier decision matrix with discount ranges and risk profiles&lt;/li&gt;
&lt;li&gt;Azure Policy JSON for mandatory tag enforcement at provisioning&lt;/li&gt;
&lt;li&gt;Kubernetes ResourceQuota manifest for namespace cost governance&lt;/li&gt;
&lt;li&gt;Infracost GitHub Actions workflow with threshold-based cost gate&lt;/li&gt;
&lt;li&gt;CronJob manifest for non-production scale-to-zero outside business hours&lt;/li&gt;
&lt;li&gt;Structural waste audit across egress, node pools, data transfer, reservations, and storage&lt;/li&gt;
&lt;li&gt;Complete cloud cost architecture checklist (15 items)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cloud</category>
      <category>architecture</category>
      <category>finops</category>
      <category>devops</category>
    </item>
    <item>
      <title>I Almost Lost an Entire Blog with git reset --hard (And Git Saved Me)</title>
      <dc:creator>Alok Ranjan Daftuar</dc:creator>
      <pubDate>Wed, 15 Jul 2026 11:24:26 +0000</pubDate>
      <link>https://dev.to/aloknecessary/i-almost-lost-an-entire-blog-with-git-reset-hard-and-git-saved-me-do6</link>
      <guid>https://dev.to/aloknecessary/i-almost-lost-an-entire-blog-with-git-reset-hard-and-git-saved-me-do6</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;What started as a routine cleanup became a lesson in Git's resilience — and a reminder that understanding the model matters more than memorizing commands.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The Moment Everything Disappeared
&lt;/h2&gt;

&lt;p&gt;I had a feature branch with a freshly committed blog post. I was tidying up my local repository — something I'd done a hundred times before. Then, almost on autopilot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout blogs/microservices-by-def
git reset &lt;span class="nt"&gt;--hard&lt;/span&gt; 65515962bc35fe08514f0b1dcad58cb89773bd2d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The terminal didn't flinch. No warning. No confirmation prompt.&lt;/p&gt;

&lt;p&gt;My article was gone. Hours of writing — vanished in under a second.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Actually Happened
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Before:   A ── B ── C ── D  ← my blog commit
After:    A ── B ── C  ← pointer moved here (D still exists, orphaned)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Git didn't &lt;em&gt;delete&lt;/em&gt; my commit. It just moved the branch pointer. The commit was still there — floating, unreachable, but alive.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Mental Model That Changes Everything
&lt;/h2&gt;

&lt;p&gt;Git doesn't store files. It stores &lt;strong&gt;snapshots&lt;/strong&gt;. A branch is just a pointer. &lt;code&gt;git reset&lt;/code&gt; relocates that pointer — it doesn't destroy history.&lt;/p&gt;

&lt;p&gt;The commit persists until garbage collection prunes unreachable objects (which doesn't happen immediately).&lt;/p&gt;

&lt;h2&gt;
  
  
  The Recovery: &lt;code&gt;git reflog&lt;/code&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reflog show blogs/microservices-by-def
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;6551596 reset: moving to 65515962bc35...
0434e98 commit: added blog on Microservices by Default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Recovery took one command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset &lt;span class="nt"&gt;--hard&lt;/span&gt; 0434e98
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything came back.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Three Reset Modes
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Working Tree&lt;/th&gt;
&lt;th&gt;Index&lt;/th&gt;
&lt;th&gt;HEAD&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git reset --soft&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✗&lt;/td&gt;
&lt;td&gt;✗&lt;/td&gt;
&lt;td&gt;✓&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git reset --mixed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✗&lt;/td&gt;
&lt;td&gt;✓&lt;/td&gt;
&lt;td&gt;✓&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git reset --hard&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✓&lt;/td&gt;
&lt;td&gt;✓&lt;/td&gt;
&lt;td&gt;✓&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;--hard&lt;/code&gt; rewrites all three areas. That's why my files disappeared.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Decision Matrix
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;I want to...&lt;/th&gt;
&lt;th&gt;Use&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Undo a local commit&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git reset&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Undo a pushed commit&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git revert&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Recover lost work&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git reflog&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Save work temporarily&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git stash&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Restore a single file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git restore&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Clean up commit history&lt;/td&gt;
&lt;td&gt;&lt;code&gt;git rebase -i&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Commit early, commit often.&lt;/strong&gt; Small commits are cheap insurance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Push important milestones.&lt;/strong&gt; Remote refs survive local disasters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Learn &lt;code&gt;reflog&lt;/code&gt; before you need it.&lt;/strong&gt; In a panic, you won't have time to read docs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never panic after a bad Git command.&lt;/strong&gt; Most mistakes are recoverable.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;The full post covers merge vs rebase, interactive rebase, reword, cherry-pick, stash, &lt;code&gt;git fsck&lt;/code&gt;, and why linear history matters for CI/CD.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://aloknecessary.github.io/blogs/i-almost-lost-an-entire-blog-with-git-reset-hard/?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=git-reset-hard" rel="noopener noreferrer"&gt;Read the complete guide on my blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>programming</category>
      <category>productivity</category>
      <category>devops</category>
    </item>
    <item>
      <title>Multi-AZ by Default: When High Availability Costs More Than the Downtime It Prevents</title>
      <dc:creator>Alok Ranjan Daftuar</dc:creator>
      <pubDate>Mon, 13 Jul 2026 06:54:00 +0000</pubDate>
      <link>https://dev.to/aloknecessary/multi-az-by-default-when-high-availability-costs-more-than-the-downtime-it-prevents-1inc</link>
      <guid>https://dev.to/aloknecessary/multi-az-by-default-when-high-availability-costs-more-than-the-downtime-it-prevents-1inc</guid>
      <description>&lt;p&gt;"Enable Multi-AZ for all production databases." It appears in every best-practice guide. Like "make everything private," it sounds unambiguously correct. More availability is better.&lt;/p&gt;

&lt;p&gt;Multi-AZ for RDS doubles your database instance cost. Exactly doubles. A &lt;code&gt;db.r8g.2xlarge&lt;/code&gt; at $700/month becomes $1,401/month. Ten such instances: $84,100/year in availability premium. That number needs a business case before it's treated as a default.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Multi-AZ Actually Provides (and Doesn't)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Provides:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Synchronous standby in a different AZ (same region)&lt;/li&gt;
&lt;li&gt;Automatic failover in 35–60 seconds&lt;/li&gt;
&lt;li&gt;Zero data loss (RPO = 0)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Does NOT provide:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Protection against regional outages (standby is same region)&lt;/li&gt;
&lt;li&gt;Read scalability (standard standby is not readable — sits idle)&lt;/li&gt;
&lt;li&gt;Protection against data corruption or accidental deletion (replicated instantly)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  When Multi-AZ Is Unnecessary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Dev/staging/QA&lt;/strong&gt; — protecting against a problem that doesn't exist. No user impact from staging downtime.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Internal tooling&lt;/strong&gt; — 50 users, business hours only. 30-minute restore is acceptable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Batch processing&lt;/strong&gt; — re-run the job when the database recovers. Retry logic is cheaper than 2x cost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stateless app tiers on Kubernetes&lt;/strong&gt; — topology spread constraints provide multi-AZ resilience at zero cost.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  When Multi-AZ IS Worth It
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Customer-facing, revenue-generating workloads ($50K/hour revenue loss justifies the premium instantly)&lt;/li&gt;
&lt;li&gt;Contractual SLA commitments (99.9%+ uptime)&lt;/li&gt;
&lt;li&gt;Regulated industries (HIPAA, PCI-DSS, SOC 2)&lt;/li&gt;
&lt;li&gt;Large databases with slow restore (5TB snapshot restore exceeds acceptable RTO)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Decision Framework
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Step 1: What is the business cost of 1 hour of downtime?
Step 2: Multi-AZ annual premium vs expected annual downtime cost
Step 3: Can snapshot restore meet your RTO?
Step 4: Environment rule — dev/staging/QA = Single-AZ, always
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the Multi-AZ premium exceeds the expected annual cost of downtime, Single-AZ with a tested restore procedure is the right answer.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Environment Rule (No Exceptions)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Production, customer-facing:   Evaluate with framework
Production, internal tooling:  Single-AZ unless justified
Staging:                       Single-AZ, always
Development:                   Single-AZ, always
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Disabling Multi-AZ on non-production environments alone saves $3,118/year per database.&lt;/p&gt;




&lt;h2&gt;
  
  
  Read the Full Article
&lt;/h2&gt;

&lt;p&gt;This is a summary of the second post in the Cloud Defaults Reconsidered series. The full article includes detailed cost breakdowns, cross-AZ transfer calculations, Aurora comparison, automated restore alternatives, and a complete decision framework:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;👉 &lt;a href="https://aloknecessary.github.io/blogs/multi-az-by-default/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=blog_syndication&amp;amp;utm_content=multi-az-by-default" rel="noopener noreferrer"&gt;Multi-AZ by Default — Full Article&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Exact RDS pricing comparison across instance types (Single-AZ vs Multi-AZ)&lt;/li&gt;
&lt;li&gt;Cross-AZ data transfer cost calculations&lt;/li&gt;
&lt;li&gt;Non-production environment savings breakdown&lt;/li&gt;
&lt;li&gt;Common misconceptions debunked (99.99% uptime, data loss protection, backups)&lt;/li&gt;
&lt;li&gt;Kubernetes topology spread constraint manifest for free multi-AZ resilience&lt;/li&gt;
&lt;li&gt;Aurora vs RDS Multi-AZ cost comparison&lt;/li&gt;
&lt;li&gt;Break-even calculation template&lt;/li&gt;
&lt;li&gt;Practical recommendations table by workload type&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cloud</category>
      <category>aws</category>
      <category>architecture</category>
      <category>devops</category>
    </item>
    <item>
      <title>Modernising the Lifted Workload: The Architectural Decisions That Separate Cloud-Native from Cloud-Hosted</title>
      <dc:creator>Alok Ranjan Daftuar</dc:creator>
      <pubDate>Thu, 09 Jul 2026 09:21:26 +0000</pubDate>
      <link>https://dev.to/aloknecessary/modernising-the-lifted-workload-the-architectural-decisions-that-separate-cloud-native-from-2omp</link>
      <guid>https://dev.to/aloknecessary/modernising-the-lifted-workload-the-architectural-decisions-that-separate-cloud-native-from-2omp</guid>
      <description>&lt;p&gt;Kubernetes does not make your architecture better automatically. Moving a lifted workload into a Deployment manifest without addressing stateful assumptions, chatty patterns, and observability voids is lift-and-shift at the container level.&lt;/p&gt;

&lt;p&gt;This post covers the graduation path from "it's running on VMs" to genuinely cloud-native.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Workload Assessment — Four Categories, Four Paths
&lt;/h2&gt;

&lt;p&gt;Not all lifted workloads have the same modernisation path:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Stateless, well-behaved&lt;/strong&gt; → containerise directly&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stateful, extractable&lt;/strong&gt; → externalise state first, then containerise&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tightly coupled monolith&lt;/strong&gt; → strangler fig pattern&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Low-ROI legacy&lt;/strong&gt; → managed service substitution or decommission&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The key diagnostic: if we modernise this, what specifically becomes easier to operate, scale, or change? If the answer is "nothing in particular," don't containerise it.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Managed Service Substitution
&lt;/h2&gt;

&lt;p&gt;Before containerising anything: does this workload need to run as a custom-deployed service at all?&lt;/p&gt;

&lt;p&gt;A self-hosted RabbitMQ cluster in Kubernetes requires provisioning, PV management, PDB configuration, Helm upgrades, TLS rotation, and on-call coverage. SQS or Azure Service Bus handles all of that for you.&lt;/p&gt;

&lt;p&gt;The rule: managed services transfer operational complexity to the provider in exchange for reduced control. That trade is almost always worth it for infrastructure that is not a source of competitive differentiation.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Stateless Redesign — The Non-Negotiable First Step
&lt;/h2&gt;

&lt;p&gt;Kubernetes's core model depends on pods being disposable. Three standard moves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Externalise session state&lt;/strong&gt; — replace in-process stores with Redis&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Externalise file storage&lt;/strong&gt; — replace local filesystem writes with object storage&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Externalise scheduled jobs&lt;/strong&gt; — replace in-process timers with CronJobs (&lt;code&gt;concurrencyPolicy: Forbid&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An application that holds state in process memory will behave incorrectly in Kubernetes in ways that are hard to reproduce in staging.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. The Strangler Fig Pattern
&lt;/h2&gt;

&lt;p&gt;The only widely proven technique for decomposing a monolith without a big-bang rewrite:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Place a routing layer in front of the monolith&lt;/li&gt;
&lt;li&gt;Extract one bounded context at a time&lt;/li&gt;
&lt;li&gt;Route that context's traffic to the new service&lt;/li&gt;
&lt;li&gt;Validate under production traffic&lt;/li&gt;
&lt;li&gt;Repeat until the monolith handles nothing&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Three rules: start with the least risky extraction (not the most valuable), never share a database between monolith and extracted service, validate under real traffic before decommissioning the old code path.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Kubernetes Readiness Criteria
&lt;/h2&gt;

&lt;p&gt;Before containerising:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Health probes are meaningful&lt;/strong&gt; — readiness checks actual application state, liveness checks only process health (never external dependencies in liveness)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resource requests and limits measured&lt;/strong&gt; — from real profiling, not guesses&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Graceful shutdown implemented&lt;/strong&gt; — SIGTERM handled, in-flight requests complete before pod exits&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  6. Autoscaling That Reflects Real Load
&lt;/h2&gt;

&lt;p&gt;CPU is a poor proxy for load in most lifted workloads:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CPU-based HPA&lt;/strong&gt; — only for compute-bound workloads&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom metrics HPA&lt;/strong&gt; — for request-rate-driven services&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;KEDA&lt;/strong&gt; — for queue consumers and event processors; scales to zero when idle&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;minReplicaCount: 0&lt;/code&gt; in non-production environments means queue consumers cost nothing when idle.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. The Modernisation Sequencing
&lt;/h2&gt;

&lt;p&gt;Never stop shipping. Allocate 20–30% of each sprint to modernisation. The order that works:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Stateless redesign&lt;/li&gt;
&lt;li&gt;Observability pipeline&lt;/li&gt;
&lt;li&gt;Managed service substitutions&lt;/li&gt;
&lt;li&gt;Routing layer&lt;/li&gt;
&lt;li&gt;First bounded context extraction&lt;/li&gt;
&lt;li&gt;Progressive extraction&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Observability comes second, not last — you cannot safely extract services you cannot observe.&lt;/p&gt;




&lt;h2&gt;
  
  
  Read the Full Article
&lt;/h2&gt;

&lt;p&gt;This is a summary of the third post in the Cloud Architecture series. The full article includes workload assessment matrices, managed service substitution tables, strangler fig architecture diagrams, Kubernetes probe configuration, KEDA ScaledObject manifests, and a comprehensive modernisation readiness checklist:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;👉 &lt;a href="https://aloknecessary.github.io/blogs/modernising-the-lifted-workload/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=blog_syndication&amp;amp;utm_content=modernising-the-lifted-workload" rel="noopener noreferrer"&gt;Modernising the Lifted Workload — Full Article&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Four-category workload assessment with recommended paths&lt;/li&gt;
&lt;li&gt;Managed service substitution table (message brokers, caches, search, schedulers, secrets)&lt;/li&gt;
&lt;li&gt;Stateless redesign patterns with CronJob manifest (concurrencyPolicy: Forbid)&lt;/li&gt;
&lt;li&gt;Strangler fig pattern with five-phase ASCII architecture diagram&lt;/li&gt;
&lt;li&gt;Kubernetes readiness/liveness probe configuration with anti-patterns&lt;/li&gt;
&lt;li&gt;KEDA ScaledObject for SQS-driven autoscaling with scale-to-zero&lt;/li&gt;
&lt;li&gt;Modernisation sequencing order with sprint allocation guidance&lt;/li&gt;
&lt;li&gt;Complete modernisation readiness checklist (13 items)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cloud</category>
      <category>devops</category>
      <category>architecture</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>GraphRAG vs. RAG: When Knowledge Graphs Earn Their Complexity</title>
      <dc:creator>Alok Ranjan Daftuar</dc:creator>
      <pubDate>Thu, 02 Jul 2026 04:55:57 +0000</pubDate>
      <link>https://dev.to/aloknecessary/graphrag-vs-rag-when-knowledge-graphs-earn-their-complexity-3j0j</link>
      <guid>https://dev.to/aloknecessary/graphrag-vs-rag-when-knowledge-graphs-earn-their-complexity-3j0j</guid>
      <description>&lt;p&gt;Vector search tells you which chunks are similar to your query. GraphRAG tells you how entities in your corpus relate to each other. Those are different questions — and most teams reach for the graph before confirming they're actually asking the second one.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem Flat Retrieval Can't Solve
&lt;/h2&gt;

&lt;p&gt;"Which suppliers does our highest-risk vendor share ownership with?" "What's the chain of approvals that led to this incident?" These queries aren't well-served by top-K similar chunks — the answer isn't &lt;em&gt;in&lt;/em&gt; any single chunk. It exists in the structure connecting multiple entities across the corpus.&lt;/p&gt;

&lt;p&gt;GraphRAG replaces or augments chunk-based retrieval with a knowledge graph — entities as nodes, relationships as edges — that the system can traverse to answer structural questions similarity search cannot.&lt;/p&gt;




&lt;h2&gt;
  
  
  Benchmark Reality
&lt;/h2&gt;

&lt;p&gt;GraphRAG's advantage is concentrated in multi-hop and relational query classes. On single-fact lookups, it's close to nonexistent — sometimes negative once you account for extraction cost.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before building anything:&lt;/strong&gt; classify 200+ real production queries as "relational" vs "single-fact." If relational queries are under 15% of traffic, GraphRAG's benchmark gains won't materialize at your actual query mix — but extraction cost still applies to 100% of documents.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Cost Problem (and How It Got Solved)
&lt;/h2&gt;

&lt;p&gt;Microsoft's 2024 implementation: $33K indexing cost for large datasets. The fix in 2026:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Selective extraction&lt;/strong&gt; — only documents likely to contain relational content go through the expensive LLM pass&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cheap-model-first&lt;/strong&gt; — lightweight model for bulk extraction, expensive model for ambiguous cases only&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hybrid classical NLP + LLM&lt;/strong&gt; — named-entity recognition handles entity identification, LLM reserved for relationship typing&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relation-free construction&lt;/strong&gt; — build entity co-occurrence structure first, type relationships only when queries need them&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Combined: 10-90% cost reduction depending on corpus characteristics.&lt;/p&gt;




&lt;h2&gt;
  
  
  GraphRAG vs. Agentic Multi-Hop Retrieval
&lt;/h2&gt;

&lt;p&gt;Both solve multi-hop questions. Different trade-offs:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Agentic retrieval&lt;/strong&gt; — pays cost at query time, only for queries that need it. No corpus-wide preprocessing. But reasoning paths are probabilistic — two runs can take different paths.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GraphRAG&lt;/strong&gt; — pays cost at ingestion time, once. Gets deterministic traversal: same query, same path, same answer, every time. Critical for compliance, audit, and risk contexts where "the system gave a different answer last time" is itself a problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Decision rule:&lt;/strong&gt; occasional, varied relational queries → agentic retrieval. Frequent, recurring relational patterns needing consistent answers → graph.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Hybrid Architecture
&lt;/h2&gt;

&lt;p&gt;In production, GraphRAG is a third retrieval tool alongside vector and BM25, not a replacement. Route per query:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Graph-only&lt;/strong&gt;: purely relational ("who is connected to X")&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vector-only&lt;/strong&gt;: content-similarity ("explain concept Y")&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hybrid&lt;/strong&gt;: use graph to narrow the search space to a relevant neighborhood, then vector-search within it&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Key Insight
&lt;/h2&gt;

&lt;p&gt;GraphRAG is not "RAG, but better." It's a different retrieval primitive — applicable when queries are about relationships rather than content. The graph is a cost center until your query distribution proves otherwise.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Audit the query distribution first. If relational share is small, agentic multi-hop gets most of the benefit at a fraction of the commitment.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Read the Full Article
&lt;/h2&gt;

&lt;p&gt;This is a summary of my deep dive into GraphRAG architecture. The full article covers the complete evaluation and implementation guide:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;👉 &lt;a href="https://aloknecessary.github.io/blogs/graph-rag-vs-rag/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=blog_syndication&amp;amp;utm_content=graphrag-vs-rag" rel="noopener noreferrer"&gt;GraphRAG vs. RAG: When Knowledge Graphs Earn Their Complexity — Full Article&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What a knowledge graph actually adds (and what it doesn't)&lt;/li&gt;
&lt;li&gt;Benchmark evidence breakdown — when GraphRAG helps and when it hurts&lt;/li&gt;
&lt;li&gt;Graph construction cost anatomy (extraction + community summarization)&lt;/li&gt;
&lt;li&gt;Four techniques that cut the 2024 cost problem (selective extraction, cheap-model-first, hybrid NLP, relation-free construction)&lt;/li&gt;
&lt;li&gt;Three graph traversal patterns (local, global, multi-hop path)&lt;/li&gt;
&lt;li&gt;GraphRAG vs agentic multi-hop retrieval — direct comparison with decision rule&lt;/li&gt;
&lt;li&gt;Hybrid architecture with routing (graph + vector together)&lt;/li&gt;
&lt;li&gt;Production failure modes specific to graphs (entity resolution drift, stale edges, community cascade)&lt;/li&gt;
&lt;li&gt;Decision checklist for committing to graph infrastructure&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>architecture</category>
      <category>machinelearning</category>
      <category>database</category>
    </item>
    <item>
      <title>Context Engineering: The Discipline That Determines What Your LLM Actually Sees</title>
      <dc:creator>Alok Ranjan Daftuar</dc:creator>
      <pubDate>Mon, 29 Jun 2026 08:11:02 +0000</pubDate>
      <link>https://dev.to/aloknecessary/context-engineering-the-discipline-that-determines-what-your-llm-actually-sees-569g</link>
      <guid>https://dev.to/aloknecessary/context-engineering-the-discipline-that-determines-what-your-llm-actually-sees-569g</guid>
      <description>&lt;p&gt;Prompt engineering asks: how do I phrase this instruction? Context engineering asks: what information does the model need, in what form, in what order, and how much of it — to produce a correct answer?&lt;/p&gt;

&lt;p&gt;For a long time, the implicit mental model was: give the LLM more context and it performs better. This is wrong. A 20,000-token window stuffed with weakly relevant content produces worse answers than a 4,000-token window with precisely curated information. Larger windows do not eliminate context quality problems — they amplify them.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Context Window Is a Budget
&lt;/h2&gt;

&lt;p&gt;Treat it as a budget with competing line items, not a container you fill. Start with the total window, subtract fixed allocations (system prompt, output reserve, safety margin), and what remains is your dynamic budget split across retrieved chunks, conversation history, and memory.&lt;/p&gt;

&lt;p&gt;The first question should always be: "can we get better at selecting less, rather than including more?"&lt;/p&gt;




&lt;h2&gt;
  
  
  Four Memory Types, Four Purposes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Episodic&lt;/strong&gt; — conversation history. Highest priority for continuity. Grows unbounded — needs compression.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Semantic&lt;/strong&gt; — durable facts about the user (role, team, preferences). Compact, injected in system prompt before retrieved content.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Procedural&lt;/strong&gt; — reusable workflows and SOPs. Retrieved selectively when the query type matches.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Working&lt;/strong&gt; — intermediate results within a single request (agentic loop output). Ephemeral, request-scoped.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each type has different durability, update frequency, and token cost. Conflating them into a single undifferentiated store is the most common memory architecture mistake.&lt;/p&gt;




&lt;h2&gt;
  
  
  Structured Injection Patterns
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;XML tags&lt;/strong&gt; for section boundaries (&lt;code&gt;&amp;lt;documents&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;user_context&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;instructions&amp;gt;&lt;/code&gt;) — gives the model clear anchors for where information types begin and end&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Indexed documents&lt;/strong&gt; — label chunks with indices so citations can be traced&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ordering matters&lt;/strong&gt; — most relevant content first (primacy effect), user query last (recency effect)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grounding instruction is not optional&lt;/strong&gt; — explicit instruction to use only provided context and signal when insufficient&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Lost-in-the-Middle
&lt;/h2&gt;

&lt;p&gt;Models attend more strongly to content near the beginning and end of the context window. Information buried in the middle receives less attention. Mitigations:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Relevance-ordered injection (highest score first)&lt;/li&gt;
&lt;li&gt;Sandwich pattern (critical content at both start and end)&lt;/li&gt;
&lt;li&gt;Active relevance filtering (exclude low-scoring chunks even if they fit)&lt;/li&gt;
&lt;li&gt;Smaller, tighter windows (fewer high-quality chunks &amp;gt; more mediocre chunks)&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Conversation Compression
&lt;/h2&gt;

&lt;p&gt;A 100-turn conversation consumes your entire retrieved context budget. Naive truncation loses critical early constraints. Solutions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sliding window with pinned turns&lt;/strong&gt; — critical turns (user constraints, decisions) never truncated&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Progressive summarization&lt;/strong&gt; — compress old segments into 3-5 sentence summaries using Haiku (cheap, mechanical task)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Context Assembly Is Testable
&lt;/h2&gt;

&lt;p&gt;Unit test your assembly layer: budget compliance, ordering preserved, critical turns survive truncation, no mid-chunk truncation. Every assembly failure produces a predictable RAGAS metric signature — context precision drops point to noisy inclusion, faithfulness drops point to contradictions.&lt;/p&gt;




&lt;h2&gt;
  
  
  Read the Full Article
&lt;/h2&gt;

&lt;p&gt;This is a summary of my deep dive into context engineering. The full article covers the complete discipline with production implementations:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;👉 &lt;a href="https://aloknecessary.github.io/blogs/discipline-that-determines-what-your-llm-actually-sees/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=blog_syndication&amp;amp;utm_content=context-engineering" rel="noopener noreferrer"&gt;Context Engineering: The Discipline That Determines What Your LLM Actually Sees — Full Article&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Context window budget accounting with Python dataclasses&lt;/li&gt;
&lt;li&gt;Four memory types with implementation patterns (episodic, semantic, procedural, working)&lt;/li&gt;
&lt;li&gt;Working memory bridge from agentic retrieval loops&lt;/li&gt;
&lt;li&gt;XML-structured injection with document indexing&lt;/li&gt;
&lt;li&gt;Primacy/recency ordering strategy&lt;/li&gt;
&lt;li&gt;Progressive summarization with critical turn pinning&lt;/li&gt;
&lt;li&gt;Lost-in-the-middle mitigation (4 strategies with code)&lt;/li&gt;
&lt;li&gt;Contradiction detection and resolution&lt;/li&gt;
&lt;li&gt;Noise taxonomy (stale, tangential, redundant, over-retrieved)&lt;/li&gt;
&lt;li&gt;Unit testing context assembly&lt;/li&gt;
&lt;li&gt;AssemblyMetadata integration with RAGAS eval pipeline&lt;/li&gt;
&lt;li&gt;RAGAS metric → assembly failure mapping table&lt;/li&gt;
&lt;li&gt;Production checklist (19 items)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>architecture</category>
      <category>machinelearning</category>
      <category>python</category>
    </item>
    <item>
      <title>Agentic RAG: Designing Self-Correcting Retrieval Loops for Production</title>
      <dc:creator>Alok Ranjan Daftuar</dc:creator>
      <pubDate>Mon, 22 Jun 2026 05:59:20 +0000</pubDate>
      <link>https://dev.to/aloknecessary/agentic-rag-designing-self-correcting-retrieval-loops-for-production-2lbg</link>
      <guid>https://dev.to/aloknecessary/agentic-rag-designing-self-correcting-retrieval-loops-for-production-2lbg</guid>
      <description>&lt;p&gt;Standard RAG retrieves once and hopes for the best. Agentic RAG retrieves, reflects, decides it was wrong, and tries again — without being told to.&lt;/p&gt;

&lt;p&gt;Single-pass RAG has a fundamental flaw: it commits to its first retrieval attempt and generates forward regardless. It has no mechanism to check whether the retrieved chunks actually contain the answer. This works for simple factual queries. It breaks on multi-hop questions, ambiguous intent, and analytical queries requiring sequenced lookups.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Architecture
&lt;/h2&gt;

&lt;p&gt;An agentic RAG system treats retrieval as a tool available to a reasoning loop. The LLM decides what to retrieve, evaluates what came back, and determines when to stop.&lt;/p&gt;

&lt;p&gt;The key component: a &lt;strong&gt;reflection agent&lt;/strong&gt; sits between retrieval and generation. It evaluates the quality and sufficiency of accumulated context and either terminates the loop or sends it back with a refined query.&lt;/p&gt;

&lt;p&gt;Three patterns in increasing complexity:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Iterative Query Refinement&lt;/strong&gt; — single tool, query rewritten per pass&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multi-Tool Orchestration&lt;/strong&gt; — agent selects between keyword, semantic, hybrid, and filtered search&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hierarchical Decomposition&lt;/strong&gt; — planner splits multi-hop queries into dependent sub-queries&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Routing: The Most Important Decision
&lt;/h2&gt;

&lt;p&gt;Sending every query through the agentic path is the most common mistake. Agentic retrieval adds 2-8s latency and 4-12x cost. Simple factual queries (60-75% of typical traffic) get no quality improvement from it.&lt;/p&gt;

&lt;p&gt;Use a hybrid router: deterministic rules first (regex patterns, length heuristics, keyword signals), LLM classification only for ambiguous cases. Use Haiku for routing — it's a classification task, not a reasoning task.&lt;/p&gt;




&lt;h2&gt;
  
  
  Reflection Agent: Deciding When to Stop
&lt;/h2&gt;

&lt;p&gt;The reflection agent's judgment quality determines the entire system's utility. Calibrate it against real queries:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Iteration 1:&lt;/strong&gt; 65-75% of queries should terminate (simple queries succeeding on first pass)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Iteration 2:&lt;/strong&gt; 15-20% (needed one refinement)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Iteration 3:&lt;/strong&gt; 5-10% (multi-hop or genuinely ambiguous)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Iteration 4+:&lt;/strong&gt; &amp;lt;5% (forced termination — investigate these)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If significant traffic hits max iterations, either routing is broken or your corpus has coverage gaps.&lt;/p&gt;




&lt;h2&gt;
  
  
  Failure Isolation and Loop Bounding
&lt;/h2&gt;

&lt;p&gt;Without explicit bounding, misbehaving loops drive latency and cost to unacceptable levels. Non-negotiable limits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;max_iterations: 4&lt;/strong&gt; — never exceed&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;timeout: 12s&lt;/strong&gt; — wall-clock for entire loop&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;min_new_chunks_per_iteration: 1&lt;/strong&gt; — if retrieval returns nothing new, break immediately&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;context token budget&lt;/strong&gt; — stop accepting chunks beyond the budget&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On timeout or max iterations: generate with accumulated context + caveat, never return a 500 error.&lt;/p&gt;




&lt;h2&gt;
  
  
  Cost Reality
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Single-pass RAG:     ~$0.003/request
Agentic (2 iter):    ~$0.006/request (2x)
Agentic (4 iter):    ~$0.010/request (3-4x)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If 25% of traffic goes agentic at 2.5x cost → 37% total increase (acceptable). If 75% goes agentic → costs triple (likely unacceptable). The router controls your bill.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Key Insight
&lt;/h2&gt;

&lt;p&gt;An agentic system with no observability is not an improvement over single-pass — it's a more expensive pipeline that's harder to debug. The loop delivers quality improvement only when it is instrumented, bounded, and its behavior is understood at the query level.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Agency without accountability is just unpredictability.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Read the Full Article
&lt;/h2&gt;

&lt;p&gt;This is a summary of my deep dive into agentic RAG architecture. The full article covers the complete system with production implementations:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;👉 &lt;a href="https://aloknecessary.github.io/blogs/designing-self-correcting-retrieval-loops-for-production/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=blog_syndication&amp;amp;utm_content=agentic-rag-self-correcting-retrieval" rel="noopener noreferrer"&gt;Designing Self-Correcting Retrieval Loops for Production — Full Article&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Full agentic RAG architecture diagram (router → planner → loop → generation)&lt;/li&gt;
&lt;li&gt;Query planner implementation with multi-hop decomposition (Python/Anthropic)&lt;/li&gt;
&lt;li&gt;Iterative retrieval loop with async timeout and dedup&lt;/li&gt;
&lt;li&gt;Reflection agent prompt and calibration patterns&lt;/li&gt;
&lt;li&gt;Multi-tool orchestration with Claude tool-use API&lt;/li&gt;
&lt;li&gt;Hybrid router (rules-first + LLM fallback)&lt;/li&gt;
&lt;li&gt;Loop bounding with five hard limits&lt;/li&gt;
&lt;li&gt;Graceful degradation with context caveats&lt;/li&gt;
&lt;li&gt;Per-request cost model (single-pass vs 2-iter vs 4-iter)&lt;/li&gt;
&lt;li&gt;Latency budget breakdown and streaming response pattern&lt;/li&gt;
&lt;li&gt;Structured loop telemetry with structlog&lt;/li&gt;
&lt;li&gt;Alerting metrics for agentic systems&lt;/li&gt;
&lt;li&gt;Production deployment checklist&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>architecture</category>
      <category>machinelearning</category>
      <category>python</category>
    </item>
    <item>
      <title>LLM Evaluation in Production: Building the Eval Pipeline That Runs on Every Deploy</title>
      <dc:creator>Alok Ranjan Daftuar</dc:creator>
      <pubDate>Wed, 17 Jun 2026 13:22:36 +0000</pubDate>
      <link>https://dev.to/aloknecessary/llm-evaluation-in-production-building-the-eval-pipeline-that-runs-on-every-deploy-5eki</link>
      <guid>https://dev.to/aloknecessary/llm-evaluation-in-production-building-the-eval-pipeline-that-runs-on-every-deploy-5eki</guid>
      <description>&lt;p&gt;Everyone ships the RAG system. Almost nobody ships the eval system that tells them when the RAG system starts lying.&lt;/p&gt;

&lt;p&gt;You updated the embedding model. Tweaked the system prompt. Swapped the re-ranker. Metrics look fine. Three weeks later, support tickets arrive — the system is drawing inferences the source documents never made. No alarm fired. No test failed. The system drifted silently.&lt;/p&gt;

&lt;p&gt;This is not a model quality problem. It is an evaluation infrastructure problem.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Four Metrics That Matter
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Faithfulness&lt;/strong&gt; — of the claims in the response, what fraction are directly supported by the retrieved context? Your primary hallucination guard. Does not require ground truth.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer Relevance&lt;/strong&gt; — how directly does the response address the user's question? Catches the "technically correct but useless" failure mode. Does not require ground truth.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Context Precision&lt;/strong&gt; — of the retrieved chunks, what fraction were actually relevant? Requires ground truth. Belongs in offline CI eval.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer Correctness&lt;/strong&gt; — how factually accurate vs the reference answer? Most expensive, requires curated ground truth. Pre-deploy regression suite only.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Operational rule:&lt;/strong&gt; Faithfulness and Answer Relevance run on every deploy and on sampled production traffic. Context Precision and Answer Correctness run in CI against the golden dataset.&lt;/p&gt;




&lt;h2&gt;
  
  
  LLM-as-Judge: The Pattern and Pitfalls
&lt;/h2&gt;

&lt;p&gt;RAGAS uses an LLM to evaluate LLM output — the only practical way to evaluate semantic quality at scale.&lt;/p&gt;

&lt;p&gt;Pitfalls to manage:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Positional bias&lt;/strong&gt; — randomize order in pairwise comparisons&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verbosity bias&lt;/strong&gt; — judge rates longer answers higher even when less accurate&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Self-preference&lt;/strong&gt; — use a different model family as judge than the one generating answers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Calibration drift&lt;/strong&gt; — pin judge model to a specific version; treat upgrades as baseline resets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Calibrate against human labels using Cohen's Kappa on 50-100 examples. Below 0.4 means your judge prompt needs revision.&lt;/p&gt;




&lt;h2&gt;
  
  
  CI/CD Integration
&lt;/h2&gt;

&lt;p&gt;The eval pipeline triggers on every PR touching RAG code, prompts, or model configuration:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run RAG pipeline against golden dataset (100+ curated questions)&lt;/li&gt;
&lt;li&gt;Score with RAGAS (faithfulness, relevance, precision, correctness)&lt;/li&gt;
&lt;li&gt;Compare against baseline — block deploy if regression exceeds threshold&lt;/li&gt;
&lt;li&gt;Post results as PR comment with per-metric scores and pass/fail status&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Cost: ~$0.50-$2.00 per full eval run at Claude Sonnet pricing. On PRs, run only faithfulness + relevance (cheapest). Full suite runs nightly.&lt;/p&gt;




&lt;h2&gt;
  
  
  Production Sampling
&lt;/h2&gt;

&lt;p&gt;CI catches regressions from code changes. Production sampling catches drift from corpus staleness, query distribution shift, and model behavior changes.&lt;/p&gt;

&lt;p&gt;Sample 5% of live traffic for async evaluation. Never evaluate synchronously — judge calls add 2-5s per request. Track 7-day rolling faithfulness and answer relevance. Alert when they drop &amp;gt;0.05 from monthly baseline.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Key Insight
&lt;/h2&gt;

&lt;p&gt;LLM systems do not have stable, deterministic behavior. They drift through corpus changes, model updates, prompt evolution, and query distribution shift. Evaluation is not a checkpoint — it is continuous infrastructure.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Build the eval system before you need it. By the time you need it, it is already too late — you will be debugging a production quality regression with no historical baseline and no automated detection.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Read the Full Article
&lt;/h2&gt;

&lt;p&gt;This is a summary of my deep dive into LLM evaluation infrastructure. The full article covers the complete eval stack with implementation examples:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;👉 &lt;a href="https://aloknecessary.github.io/blogs/llm-evaluation-in-production/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=blog_syndication&amp;amp;utm_content=llm-evaluation-in-production" rel="noopener noreferrer"&gt;LLM Evaluation in Production — Full Article&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Evaluation stack architecture (retrieval layer vs generation layer)&lt;/li&gt;
&lt;li&gt;Four metrics with RAGAS Python implementations&lt;/li&gt;
&lt;li&gt;LLM-as-Judge faithfulness prompt with claim-level scoring&lt;/li&gt;
&lt;li&gt;Judge calibration against human labels (Cohen's Kappa)&lt;/li&gt;
&lt;li&gt;RAGAS configuration with Claude as judge model&lt;/li&gt;
&lt;li&gt;Regression threshold framework (absolute + delta from baseline)&lt;/li&gt;
&lt;li&gt;Golden dataset generation, versioning, and holdout partitions&lt;/li&gt;
&lt;li&gt;Full GitHub Actions eval pipeline (YAML + runner scripts)&lt;/li&gt;
&lt;li&gt;Production sampling with async eval queue worker&lt;/li&gt;
&lt;li&gt;Eval observability dashboard schema (PostgreSQL)&lt;/li&gt;
&lt;li&gt;Eight failure modes in eval systems and mitigations&lt;/li&gt;
&lt;li&gt;Production deployment checklist&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>devops</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Building Reliable RAG Pipelines: From Prototype to Production</title>
      <dc:creator>Alok Ranjan Daftuar</dc:creator>
      <pubDate>Wed, 10 Jun 2026 06:20:00 +0000</pubDate>
      <link>https://dev.to/aloknecessary/building-reliable-rag-pipelines-from-prototype-to-production-2mcp</link>
      <guid>https://dev.to/aloknecessary/building-reliable-rag-pipelines-from-prototype-to-production-2mcp</guid>
      <description>&lt;p&gt;Most teams get RAG working in a notebook over a weekend. Very few get it working reliably in production. The gap is not model quality — it is engineering discipline.&lt;/p&gt;

&lt;p&gt;The RAG prototype is fifty lines of Python. It works. Then production happens — users ask unexpected questions, retrieval degrades as the corpus grows, and the model confidently synthesizes wrong answers from bad context. Nobody knows, because there is no instrumentation to catch it.&lt;/p&gt;




&lt;h2&gt;
  
  
  Chunking: The Foundation
&lt;/h2&gt;

&lt;p&gt;A poor chunking strategy cannot be compensated for downstream. If relevant information is split across chunks or diluted into one too large, no retrieval algorithm will recover it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hierarchical chunking&lt;/strong&gt; is the production-grade pattern: maintain parent chunks (full sections) and child chunks (sentences/short paragraphs). Retrieve at child granularity for precision. Return parent text as LLM context for completeness.&lt;/p&gt;

&lt;p&gt;Every chunk must carry metadata — source document ID, version, content hash, embedding model version. &lt;code&gt;content_hash&lt;/code&gt; tells you when a chunk needs re-embedding because the source changed.&lt;/p&gt;




&lt;h2&gt;
  
  
  Retrieval: Hybrid Is the Default
&lt;/h2&gt;

&lt;p&gt;Neither BM25 nor vector search alone is sufficient. Hybrid retrieval with Reciprocal Rank Fusion (RRF) is the baseline for production RAG.&lt;/p&gt;

&lt;p&gt;The pipeline:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Dense retrieval&lt;/strong&gt; (vector similarity) + &lt;strong&gt;Sparse retrieval&lt;/strong&gt; (BM25 keywords) in parallel&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RRF merge&lt;/strong&gt; — rank-based fusion without score normalization&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cross-encoder re-ranker&lt;/strong&gt; — precision pass on top candidates&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Skipping the re-ranker is the most common mistake. Initial retrieval optimizes for recall. The re-ranker optimizes for precision — critical when your context window only fits top-5 chunks.&lt;/p&gt;




&lt;h2&gt;
  
  
  Context Assembly: Where Pipelines Quietly Break
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Token budget management&lt;/strong&gt; — hard ceiling, never rely on hope that chunks fit&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deduplication&lt;/strong&gt; — hierarchical chunking and hybrid retrieval can surface the same content via multiple paths&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Source attribution&lt;/strong&gt; — every chunk in context must carry its source ID for citation&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The "I Don't Know" Instruction Is Not Optional
&lt;/h2&gt;

&lt;p&gt;Without explicit grounding instructions, LLMs fill context gaps with plausible hallucinations. Your system prompt must instruct the model to acknowledge when context is insufficient — and to cite sources for every factual claim.&lt;/p&gt;




&lt;h2&gt;
  
  
  Evaluate Retrieval Independently
&lt;/h2&gt;

&lt;p&gt;The most common RAG debugging mistake: assuming a bad answer is a generation failure. Most bad RAG answers are &lt;strong&gt;retrieval failures&lt;/strong&gt; — the right chunk was not in the context.&lt;/p&gt;

&lt;p&gt;Measure &lt;strong&gt;Recall@K&lt;/strong&gt; and &lt;strong&gt;MRR&lt;/strong&gt; against a ground truth dataset of 50-100 queries. Fix retrieval before you blame the model.&lt;/p&gt;




&lt;h2&gt;
  
  
  Production Observability
&lt;/h2&gt;

&lt;p&gt;A RAG pipeline without observability is a black box that silently degrades. Key signals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;"I don't know" rate&lt;/strong&gt; — drops below 80% signals retrieval degradation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Chunks dropped rate&lt;/strong&gt; — rising means context window pressure&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retrieval latency p99&lt;/strong&gt; — vector index performance&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Corpus staleness&lt;/strong&gt; — content hash mismatches between source docs and stored chunks&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Read the Full Article
&lt;/h2&gt;

&lt;p&gt;This is a summary of my deep dive into production RAG engineering. The full article covers every pipeline component with implementation examples:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;👉 &lt;a href="https://aloknecessary.github.io/blogs/rag_prototype_to_production/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=blog_syndication&amp;amp;utm_content=rag-prototype-to-production" rel="noopener noreferrer"&gt;Building Reliable RAG Pipelines — Full Article&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Full pipeline architecture diagram (9 stages)&lt;/li&gt;
&lt;li&gt;Three chunking approaches with Python implementations (fixed, semantic, hierarchical)&lt;/li&gt;
&lt;li&gt;Hybrid retrieval with RRF implementation (Qdrant)&lt;/li&gt;
&lt;li&gt;Cross-encoder re-ranking (self-hosted and Cohere API)&lt;/li&gt;
&lt;li&gt;Context assembly with token budget management and deduplication&lt;/li&gt;
&lt;li&gt;Prompt construction with grounding and guardrails&lt;/li&gt;
&lt;li&gt;Retrieval evaluation framework (Recall@K, MRR, context relevance)&lt;/li&gt;
&lt;li&gt;Per-request tracing schema and aggregate alerting metrics&lt;/li&gt;
&lt;li&gt;Corpus staleness detection implementation&lt;/li&gt;
&lt;li&gt;Graceful degradation with BM25 fallback&lt;/li&gt;
&lt;li&gt;Production deployment checklist&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>architecture</category>
      <category>machinelearning</category>
      <category>python</category>
    </item>
    <item>
      <title>Event-Driven Architecture: The Dual Write Problem and How to Solve It</title>
      <dc:creator>Alok Ranjan Daftuar</dc:creator>
      <pubDate>Thu, 04 Jun 2026 06:32:28 +0000</pubDate>
      <link>https://dev.to/aloknecessary/event-driven-architecture-the-dual-write-problem-and-how-to-solve-it-5266</link>
      <guid>https://dev.to/aloknecessary/event-driven-architecture-the-dual-write-problem-and-how-to-solve-it-5266</guid>
      <description>&lt;p&gt;You have a well-designed order service. It writes to the database and publishes an event to Kafka. Clean, decoupled, event-driven. Then Kafka has a brief network hiccup. The database write succeeds. The event publish fails. The order exists. Fulfillment never hears about it. No alert fires. Just a quietly broken order going nowhere.&lt;/p&gt;

&lt;p&gt;This is the dual write problem — an &lt;strong&gt;architectural correctness problem&lt;/strong&gt; that exists the moment you write to two separate systems without a coordination mechanism.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;A dual write occurs when your application writes to two separate systems as part of a single logical operation without atomicity across both. The dangerous failure modes are silent — the HTTP response returns 200, the client gets a success, and nothing downstream happens.&lt;/p&gt;

&lt;p&gt;The naive fixes don't work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Try/catch with retry&lt;/strong&gt; — introduces duplicate events; consumers must be idempotent&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Publish first, then write DB&lt;/strong&gt; — just reverses which failure mode you're exposed to&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Distributed transactions (2PC)&lt;/strong&gt; — sacrifices availability and introduces distributed locking&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The real solution: &lt;strong&gt;reduce to a single atomic write and derive the event from it&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Solution 1: Transactional Outbox Pattern
&lt;/h2&gt;

&lt;p&gt;Write the event as a row in an &lt;code&gt;outbox&lt;/code&gt; table in the same database transaction as your business data. A separate relay process reads from the outbox and publishes to the broker.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Both writes succeed or fail together (single DB transaction)&lt;/li&gt;
&lt;li&gt;Relay publishes and marks messages as published&lt;/li&gt;
&lt;li&gt;Guarantees at-least-once delivery — consumers must be idempotent&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Best for:&lt;/strong&gt; greenfield services, full control over event schema, teams wanting simplicity.&lt;/p&gt;




&lt;h2&gt;
  
  
  Solution 2: Change Data Capture (Debezium)
&lt;/h2&gt;

&lt;p&gt;Read directly from the database's transaction log (WAL/binlog). Every committed write is captured and streamed to Kafka automatically. No application code changes required.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sub-second publish latency (WAL-based, no polling)&lt;/li&gt;
&lt;li&gt;Captures all state changes including DB migrations and admin tools&lt;/li&gt;
&lt;li&gt;Requires infrastructure for Kafka Connect + Debezium&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Best for:&lt;/strong&gt; legacy systems, high-throughput services, capturing all state changes without code modification.&lt;/p&gt;




&lt;h2&gt;
  
  
  Solution 3: Event Sourcing
&lt;/h2&gt;

&lt;p&gt;The event log is the source of truth. The database is a derived projection. There is no dual write because there is only one write — appending events to the event store.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Eliminates the problem entirely&lt;/li&gt;
&lt;li&gt;Introduces significant complexity (schema versioning, aggregate rehydration, eventual consistency)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Best for:&lt;/strong&gt; domains where history of state changes matters (financial systems, audit-heavy domains).&lt;/p&gt;




&lt;h2&gt;
  
  
  Operational Non-Negotiables
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Consumer idempotency&lt;/strong&gt; — at-least-once delivery means duplicates will arrive. Deduplicate on event ID.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Outbox housekeeping&lt;/strong&gt; — purge published messages; don't let the table grow unbounded.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replication slot monitoring&lt;/strong&gt; — for CDC, a stuck connector causes WAL accumulation and disk exhaustion.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Read the Full Article
&lt;/h2&gt;

&lt;p&gt;This is a summary of my deep dive into the dual write problem. The full article covers all three solutions with production implementation examples:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;👉 &lt;a href="https://aloknecessary.github.io/blogs/dual-write-problem-in-event-driven-architecture/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=blog_syndication&amp;amp;utm_content=dual-write-problem" rel="noopener noreferrer"&gt;The Dual Write Problem and How to Solve It — Full Article&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Four failure scenarios with a dual write matrix&lt;/li&gt;
&lt;li&gt;Transactional Outbox Pattern implementation (.NET with EF Core)&lt;/li&gt;
&lt;li&gt;Polling relay vs log-tailing relay comparison&lt;/li&gt;
&lt;li&gt;Debezium PostgreSQL connector configuration&lt;/li&gt;
&lt;li&gt;Event Sourcing with aggregate pattern (C#)&lt;/li&gt;
&lt;li&gt;Decision matrix for choosing between the three solutions&lt;/li&gt;
&lt;li&gt;Operational concerns: housekeeping, replication slot monitoring, consumer idempotency&lt;/li&gt;
&lt;li&gt;Production deployment checklist&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>microservices</category>
      <category>architecture</category>
      <category>eventdriven</category>
      <category>distributedsystems</category>
    </item>
    <item>
      <title>AI-Assisted Data Reconciliation at Scale: Patterns for Distributed Systems</title>
      <dc:creator>Alok Ranjan Daftuar</dc:creator>
      <pubDate>Mon, 01 Jun 2026 08:41:05 +0000</pubDate>
      <link>https://dev.to/aloknecessary/ai-assisted-data-reconciliation-at-scale-patterns-for-distributed-systems-31l9</link>
      <guid>https://dev.to/aloknecessary/ai-assisted-data-reconciliation-at-scale-patterns-for-distributed-systems-31l9</guid>
      <description>&lt;p&gt;In any sufficiently large distributed system, data reconciliation is the dark matter of engineering — invisible, pervasive, and holding everything together through mechanisms nobody fully understands.&lt;/p&gt;

&lt;p&gt;Rule-based reconciliation works until it doesn't. Rule engines break on ambiguity, cannot handle semantic equivalence across schema versions, and generate false positives at scale that overwhelm operations teams. AI — specifically embedding-based similarity and LLM classification — fills the gap. Not as a replacement, but as a layer that handles what rules cannot.&lt;/p&gt;




&lt;h2&gt;
  
  
  Where Traditional Reconciliation Breaks Down
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Eventual consistency windows&lt;/strong&gt; — a naive reconciliation job that diffs at a point in time generates thousands of false positives that are self-healing within seconds. The rule engine cannot distinguish transient inconsistency from legitimate divergence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cross-service schema drift&lt;/strong&gt; — Service A stores an address as &lt;code&gt;{ street, city, state, zip }&lt;/code&gt;. Service B stores it as &lt;code&gt;{ addressLine1, municipality, postalCode }&lt;/code&gt;. Semantically equivalent. A field-level comparator flags every record as mismatched.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Semantic equivalence in free-text&lt;/strong&gt; — &lt;code&gt;"Acme Corporation"&lt;/code&gt; vs &lt;code&gt;"ACME Corp."&lt;/code&gt; vs &lt;code&gt;"Acme Corp (formerly Roadrunner Supplies)"&lt;/code&gt;. Rule-based systems cannot reason about semantic identity at scale.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Volume-driven false positive fatigue&lt;/strong&gt; — at millions of records per day, even 0.1% false positives generate thousands of alerts. Real issues get buried. The reconciliation system becomes theater.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Architecture: Rules First, AI at the Boundary
&lt;/h2&gt;

&lt;p&gt;The pattern is not AI-first. It is &lt;strong&gt;rules-first, AI at the boundary&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Deterministic mismatch detection&lt;/strong&gt; — checksums, field comparisons, primary key matching&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;High-confidence matches/mismatches&lt;/strong&gt; — auto-resolve or route to correction (no AI needed)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ambiguous cases&lt;/strong&gt; → AI classification layer:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Embedding similarity&lt;/strong&gt; — detect semantic equivalence across schema variations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LLM classification&lt;/strong&gt; — reason about &lt;em&gt;why&lt;/em&gt; a mismatch exists&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Embedding-Based Similarity
&lt;/h2&gt;

&lt;p&gt;Serialize records into schema-agnostic text representations before embedding. Compute cosine similarity. Calibrate thresholds against labeled data:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;≥ 0.95&lt;/strong&gt; → auto-resolve as equivalent&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;0.80 – 0.95&lt;/strong&gt; → route to LLM classification&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&amp;lt; 0.80&lt;/strong&gt; → high-confidence mismatch, route to correction&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The thresholds are not universal — calibrate against 500–1000 manually classified record pairs from your actual data.&lt;/p&gt;




&lt;h2&gt;
  
  
  LLM Classification for the Ambiguous Band
&lt;/h2&gt;

&lt;p&gt;For the 5–15% of mismatches that fall in the ambiguous range, an LLM reasons about context that vector distance cannot capture. Classifications: &lt;code&gt;equivalent&lt;/code&gt;, &lt;code&gt;stale_copy&lt;/code&gt;, &lt;code&gt;legitimate_divergence&lt;/code&gt;, &lt;code&gt;data_corruption&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Cost management: route only the ambiguous band to the LLM. Batch where latency allows. Cache results for record pairs re-evaluated in subsequent cycles.&lt;/p&gt;




&lt;h2&gt;
  
  
  Where AI Should Never Be Trusted
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Financial and compliance records&lt;/strong&gt; — dollar amount disagreements are correctness errors, not semantic questions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Primary key and identity resolution&lt;/strong&gt; — AI suggestions acceptable; auto-resolution without human sign-off is not&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Any decision that must be explainable to a regulator&lt;/strong&gt; — "87% confidence" is not an audit-compliant explanation&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Key Insight
&lt;/h2&gt;

&lt;p&gt;AI in reconciliation is a &lt;strong&gt;judgment layer&lt;/strong&gt;, not a trust layer. It handles ambiguous cases that rules cannot, reduces volume reaching human review, and provides structured reasoning. The deterministic foundation must remain intact.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A reconciliation system you cannot audit is worse than one that generates false positives. Build the observability before you build the AI.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Read the Full Article
&lt;/h2&gt;

&lt;p&gt;This is a summary of my deep dive into AI-assisted data reconciliation. The full article covers the complete architecture with implementation examples:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;👉 &lt;a href="https://aloknecessary.github.io/blogs/ai_assisted_data_reconciliation/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=blog_syndication&amp;amp;utm_content=ai-data-reconciliation" rel="noopener noreferrer"&gt;AI-Assisted Data Reconciliation at Scale — Full Article&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Where traditional reconciliation breaks down (4 failure modes)&lt;/li&gt;
&lt;li&gt;Full architecture diagram with rules-first, AI-at-boundary pattern&lt;/li&gt;
&lt;li&gt;Embedding-based similarity implementation (Python, OpenAI embeddings)&lt;/li&gt;
&lt;li&gt;LLM classification prompt pattern with structured JSON output&lt;/li&gt;
&lt;li&gt;Observation window pattern for filtering eventual consistency false positives&lt;/li&gt;
&lt;li&gt;Hard boundaries where AI should never auto-resolve&lt;/li&gt;
&lt;li&gt;Observability patterns with structured logging&lt;/li&gt;
&lt;li&gt;Production deployment checklist&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>distributedsystems</category>
      <category>architecture</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Why Lift-and-Shift Fails Quietly: Architectural Smells That Appear After Migration</title>
      <dc:creator>Alok Ranjan Daftuar</dc:creator>
      <pubDate>Fri, 29 May 2026 07:34:23 +0000</pubDate>
      <link>https://dev.to/aloknecessary/why-lift-and-shift-fails-quietly-architectural-smells-that-appear-after-migration-bdj</link>
      <guid>https://dev.to/aloknecessary/why-lift-and-shift-fails-quietly-architectural-smells-that-appear-after-migration-bdj</guid>
      <description>&lt;p&gt;Every cloud migration starts with a promise: &lt;em&gt;"We'll get onto cloud first, optimize later."&lt;/em&gt; That sentence is where the trouble begins.&lt;/p&gt;

&lt;p&gt;Lift-and-shift leaves on-premises assumptions baked into a system operating in a fundamentally different environment. The failure doesn't arrive on day one. It arrives three months later, in a Slack alert at 2am, or in an invoice that made a VP ask uncomfortable questions.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Latency Amplification
&lt;/h2&gt;

&lt;p&gt;On a physical LAN, a service call is sub-millisecond. In a cloud VPC, even same-AZ calls incur 1-3ms. A service making 40 synchronous downstream calls goes from ~4ms network overhead to ~160ms — without any code change.&lt;/p&gt;

&lt;p&gt;Same call graph. Same code. 8x more latency — purely from network topology.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; consolidate reads with batch APIs, introduce async messaging for non-critical paths, add caching for hot reference data.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Chatty Services
&lt;/h2&gt;

&lt;p&gt;The N+1 problem at infrastructure scale. A service making 60 per-entity HTTP calls to render a dashboard is annoying on LAN. In cloud, it's a 300-600ms tax on every page load.&lt;/p&gt;

&lt;p&gt;Chatty patterns also exhaust connection pools faster — each call traverses the network and holds an open connection during transit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; batch endpoints on all internal APIs, DataLoader pattern, connection pool profiling under realistic concurrency.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Cost Surprises
&lt;/h2&gt;

&lt;p&gt;The PoC cost $340. The first production month is $8,200. Nobody changed the architecture.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Data egress&lt;/strong&gt; — free on-prem, metered in cloud. Cross-AZ, cross-region, and internet egress all bill.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Over-provisioning&lt;/strong&gt; — on-prem sizing instincts (buy for 3-5 years) don't translate. Cloud charges per idle CPU cycle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Idle infrastructure&lt;/strong&gt; — dev/staging environments left running 24/7.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  4. Stateful Assumptions
&lt;/h2&gt;

&lt;p&gt;In-memory session state works with a single server. The moment you auto-scale, 33% of requests hit instances with no session. Filesystem dependencies break when containers reschedule or pods restart.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; externalize session to Redis. Replace local filesystem writes with object storage at the upload boundary.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. The Observability Void
&lt;/h2&gt;

&lt;p&gt;On-prem monitoring (Nagios, Zabbix) watches hardware metrics that mean nothing in cloud. What you need to observe is different: cold start times, managed service throttling, connection pool utilization, cost-per-request.&lt;/p&gt;

&lt;p&gt;The danger window is immediately after migration when legacy monitoring reports "all green" while user-facing metrics degrade invisibly.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. The Monolith in Microservice Clothing
&lt;/h2&gt;

&lt;p&gt;Containerized and deployed to Kubernetes with separate deployments per service. On the surface: microservices. Underneath: shared database schemas, synchronous HTTP chains, coordinated deployments. A distributed monolith you &lt;em&gt;think&lt;/em&gt; is clean is a production incident waiting to happen.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Realistic Migration Philosophy
&lt;/h2&gt;

&lt;p&gt;Lift-and-shift is not a failure state. It's a phase. The mistake is treating it as a destination. Every migrated workload should have a documented list of known architectural debts, an owner for each, and a timeline to address them — agreed &lt;em&gt;before&lt;/em&gt; the migration.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Moving to cloud does not modernize your architecture. It gives you a new environment in which your existing architectural decisions — good and bad — will be amplified.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Read the Full Article
&lt;/h2&gt;

&lt;p&gt;This is a summary of my deep dive into post-migration architectural smells. The full article covers all six patterns with diagnostics, mitigations, and a pre-migration review checklist:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;👉 &lt;a href="https://aloknecessary.github.io/blogs/lift-and-shift-fails-quietly/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=blog_syndication&amp;amp;utm_content=lift-and-shift-fails-quietly" rel="noopener noreferrer"&gt;Why Lift-and-Shift Fails Quietly — Full Article&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full article includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Latency amplification with SVG architecture diagram (on-prem vs cloud)&lt;/li&gt;
&lt;li&gt;Chatty services with before/after code examples and connection pool diagnostics&lt;/li&gt;
&lt;li&gt;Cost surprise breakdown with egress pricing tables&lt;/li&gt;
&lt;li&gt;Stateful assumptions with session externalization code (Node.js/Redis)&lt;/li&gt;
&lt;li&gt;Observability void with Prometheus recording rules for post-migration signals&lt;/li&gt;
&lt;li&gt;Distributed monolith diagnostic patterns&lt;/li&gt;
&lt;li&gt;Complete pre-migration architecture review checklist&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cloud</category>
      <category>architecture</category>
      <category>devops</category>
      <category>migration</category>
    </item>
  </channel>
</rss>
