<?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 Vishal Jain on Medium]]></title>
        <description><![CDATA[Stories by Vishal Jain on Medium]]></description>
        <link>https://medium.com/@vishal.s.jain?source=rss-15ffefc2a680------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*haRztSshuGdLI12j</url>
            <title>Stories by Vishal Jain on Medium</title>
            <link>https://medium.com/@vishal.s.jain?source=rss-15ffefc2a680------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 20:18:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vishal.s.jain/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[Can You Replay Yesterday’s AI Decision?]]></title>
            <link>https://medium.com/@vishal.s.jain/can-you-replay-yesterdays-ai-decision-f0f61a2aa4d4?source=rss-15ffefc2a680------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0f61a2aa4d4</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[platform-engineering]]></category>
            <dc:creator><![CDATA[Vishal Jain]]></dc:creator>
            <pubDate>Mon, 20 Jul 2026 04:44:05 GMT</pubDate>
            <atom:updated>2026-07-20T04:44:05.934Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Distributed systems taught us how to replay events. AI platforms will need to learn how to replay decisions.</em></p><p>A customer raises a support ticket.</p><p>Yesterday your AI approved their expense report. Today, on what they insist is the exact same request, it rejected them.</p><p>The product team turns to engineering with a simple question: <strong>What changed?</strong></p><p>In a traditional software system, that question is usually answerable. You inspect the deployed version, review configuration changes, compare the state of the database, and replay the request. It takes time, but the trail exists because a traditional system has a small, known set of things that can move: the code, the configuration, and the data.</p><p>An AI-powered decision is different.</p><p>The application code may be unchanged, yet the outcome can still vary. The prompt template may have evolved. The retrieved documents may not be the same ones the system saw yesterday. The embedding model may have been updated. The foundation model itself may have changed. Even the ranking of retrieved context could have shifted.</p><p>Nothing about the release pipeline needed to change for the decision to change.</p><p>So the real question isn’t “What code was running?”</p><p>It’s: <strong>Can we replay yesterday’s decision?</strong></p><h3>We’ve Solved This Problem Before</h3><p>This problem isn’t entirely new.</p><p>Long before generative AI, data platform teams learned that fixing a bug was often easier than recovering from it. A faulty streaming job could corrupt downstream data, but the real challenge was rebuilding the platform exactly as if the bug had never happened.</p><p>That experience shaped modern data platforms. Immutable event logs, versioned transformations, and replayable pipelines were not built because replay was convenient. They were built because replay made recovery possible.</p><p>AI systems are beginning to face the same challenge.</p><p>The only difference is that what needs to be replayed is no longer an event.</p><p>It’s a decision.</p><figure><img alt="Everything you would need to reconstruct yesterday’s AI decision" src="https://cdn-images-1.medium.com/max/1024/1*vJ2kHuUXlm9i7e-oSulUxQ.png" /></figure><h3>Observability Isn’t Replayability</h3><p>Modern AI platforms already collect a remarkable amount of telemetry. They measure latency, token usage, model cost, prompt traces, and error rates. Those capabilities are valuable, but they answer only one class of question: <em>What happened?</em></p><p>Now imagine the CEO asks a week later:</p><blockquote><em>Why did our AI reject this customer’s request?</em></blockquote><p>Observability can usually tell you which model processed the request and roughly what happened during execution.</p><p>Replayability answers something different.</p><p>Could the platform recreate the exact conditions that produced yesterday’s decision?</p><p>Watching a decision happen is not the same thing as being able to reproduce it.</p><h3>A Decision Is More Than a Prompt</h3><p>It is tempting to think replaying an AI decision simply means storing the prompt.</p><p>It doesn’t.</p><p>Every customer-facing decision is assembled from a chain of dependencies: the prompt template, retrieved documents, document ranking, embedding model, vector index, model version, tool responses, routing decisions, guardrails, and policies active at that moment.</p><p>Each of those pieces can evolve independently.</p><p>Unless the platform captures that chain when the decision is made, the context slowly disappears. By the time engineering investigates, the explanation is often an educated reconstruction rather than a reproducible fact.</p><h3>Data Engineering Already Has a Name for This</h3><p>Data engineering solved a similar problem years ago through lineage.</p><p>Where did this dataset come from? Which transformation produced it? Which version of the pipeline created it?</p><p>Once those questions became easy to answer, production incidents became easier to understand.</p><p>AI systems need something similar — not only for compliance or audits, but for engineering.</p><p>When a customer reports a bad AI decision, the engineering team isn’t trying to defend the system. It’s trying to understand it well enough to improve it.</p><p>That requires reconstructing the decision, not simply observing that it happened.</p><h3>The Real Question</h3><p>This article isn’t really about expense reports.</p><p>Or loan approvals.</p><p>Or customer support tickets.</p><p>Those are simply where the gap first becomes visible.</p><p>The deeper question is whether an engineering team can confidently explain yesterday’s AI decision tomorrow.</p><p>We spent years teaching data platforms how to replay yesterday’s events because recovery depends on reconstruction, not memory.</p><p>AI platforms are beginning to face the same challenge.</p><p>The unit of replay is no longer an event.</p><p>It’s a decision.</p><p>Whether that’s a problem worth solving right now, and what solving it would even look like, is a separate conversation — probably not one with a single right answer.</p><p>But it’s worth knowing, plainly, whether your team could reconstruct yesterday’s decision if someone asked tomorrow.</p><p>For most AI-powered systems today, the honest answer is that nobody has checked.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0f61a2aa4d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why SLOs Aren’t Enough for Platform Engineering]]></title>
            <link>https://medium.com/@vishal.s.jain/why-slos-arent-enough-for-platform-engineering-9af9f1e337c1?source=rss-15ffefc2a680------2</link>
            <guid isPermaLink="false">https://medium.com/p/9af9f1e337c1</guid>
            <category><![CDATA[platform-engineering]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[site-reliability-engineer]]></category>
            <dc:creator><![CDATA[Vishal Jain]]></dc:creator>
            <pubDate>Mon, 13 Jul 2026 08:34:04 GMT</pubDate>
            <atom:updated>2026-07-13T08:34:04.820Z</atom:updated>
            <content:encoded><![CDATA[<h4>Threshold-based monitoring still has a place in modern platform engineering, and here’s why.</h4><p>Modern Site Reliability Engineering fundamentally changed how we think about observability. Instead of alerting on CPU utilization, memory consumption, or disk usage, we learned to alert on what customers actually experience: latency, availability, and correctness. Service Level Objectives shifted engineering attention away from noisy infrastructure metrics and toward user outcomes. It was one of the best ideas to come out of modern SRE.</p><p>But platform engineering is trying to answer a different question. It isn’t asking “are customers healthy today?” It’s asking “will this architecture still be healthy tomorrow?” Those are different questions, and treating them as the same one is where a lot of platform teams quietly get into trouble.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6fFJrktfAQfNKD5D1_B32g.png" /></figure><h3>Two kinds of observability</h3><p>There are really two observability systems running side by side, and it helps to name them separately.</p><p>Product observability asks whether customers are healthy, whether SLOs are being met, and whether someone should be paged. Its primary signals are availability, latency, and error rate. The goal is straightforward: protect today’s customers.</p><p>Platform observability asks a different set of questions. Is this architecture approaching its design limits? Where is capacity disappearing? Which parts of the platform are quietly aging? What needs to change before customers ever notice? Its signals look very different too — queue depth, consumer lag, storage growth, partition counts, processing backlog, metadata growth, throughput trends. None of these are customer metrics. They’re architectural signals. The goal isn’t to detect failure. The goal is to prevent tomorrow’s failure.</p><h3>SLOs answer one question extremely well</h3><p>A well-designed SLO tells you whether requests complete successfully, whether latency remains within budget, and whether users are experiencing failures. When an SLO breaches, customers have already started feeling the impact. That’s exactly what an SLO is designed to tell you. It’s doing its job.</p><h3>Capacity signals answer a different question</h3><p>Picture a streaming platform where everything looks green. Latency is healthy, availability is excellent, error rates are flat. Every SLO dashboard says things are fine. Meanwhile, queue depth has been doubling every month, partition counts are approaching their practical limits, storage growth is accelerating, and processing windows keep expanding. Customers don’t notice. Yet. An SLO won’t tell you the architecture is quietly running out of room. Capacity signals will.</p><h3>The mistake is treating capacity signals as customer alerts</h3><p>This is where a lot of discussions become polarized. Capacity signals make poor indicators of customer experience. CPU at 95% might mean background compaction, a scheduled batch job, a temporary burst, or simply a healthy, busy system. Alert every time an infrastructure metric crosses a threshold and you just create noise. Google’s SRE guidance is right to move customer alerting toward SLOs. But that doesn’t mean capacity signals stopped being valuable — it means they’re answering a completely different question.</p><h3>The worst time to design a scaling strategy</h3><p>This is the distinction that actually matters. If capacity problems are first discovered through SLO violations, you’ve handed the on-call engineer an architectural problem to solve in the middle of an incident. By the time customers are affected, the conversation has already shifted from “how should this platform evolve?” to “how do we stop the bleeding?” Those are entirely different conversations, and scaling strategy belongs in the first one — in architecture reviews, not on an incident bridge at three in the morning.</p><p>Autoscaling doesn’t fundamentally solve this problem either. It can buy time, but it cannot create architectural headroom. If queue depth, storage growth, metadata volume, or partition counts keep increasing, scaling merely postpones the limit. It doesn’t remove it.</p><h3>Customer health isn’t architectural health</h3><p>This is the distinction worth remembering. Customer health tells you whether the platform is succeeding today. Architectural health tells you whether it can keep succeeding tomorrow. The two are related, but they are not the same. SLOs optimize for customer reliability. Capacity signals optimize for architectural sustainability. You need both.</p><h3>Closing thought</h3><p>Modern SRE changed how we think about customer reliability, and rightly so. But platform engineering carries a second responsibility: protecting the architecture before customers ever notice it needs protecting. SLOs tell you when today’s architecture has started hurting customers. Capacity signals tell you when tomorrow’s architecture is quietly running out of room. Good platform engineering pays attention to both.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9af9f1e337c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When One Customer’s Telemetry Becomes Another Customer’s Outage]]></title>
            <link>https://medium.com/@vishal.s.jain/when-one-customers-telemetry-becomes-another-customer-s-outage-04e5ddf87471?source=rss-15ffefc2a680------2</link>
            <guid isPermaLink="false">https://medium.com/p/04e5ddf87471</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Vishal Jain]]></dc:creator>
            <pubDate>Tue, 30 Jun 2026 07:30:46 GMT</pubDate>
            <atom:updated>2026-06-30T07:30:46.433Z</atom:updated>
            <content:encoded><![CDATA[<p>Building a telemetry pipeline starts with an unglamorous step: flattening. Your data arrives deeply nested — spans contain attributes, attributes contain maps, everything eventually cascades into a structure that needs to become something a lakehouse can write efficiently. Before you can query, aggregate, or visualize anything, you have to convert that hierarchy into a tabular schema.</p><p>It’s a design decision that quietly determines how failures propagate through a multi-tenant platform — and which customers pay the price when they do. How you flatten decides how your system interprets the data, how schema evolution behaves, and ultimately which customers get affected when something goes wrong. In a multi-tenant pipeline, a seemingly harmless naming decision can create a failure mode where one customer’s telemetry causes another customer to lose data.</p><p>Here’s how that happens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GGqAg0YmCEUZmfEC8Kle4g.png" /></figure><h3>Normalization destroys information</h3><p>OpenTelemetry encourages dotted attribute names such as service.name, http.route, and session.id. These are simply attribute names—not necessarily nested objects—but analytical storage engines generally require flattened column names.</p><p>Spark interprets dots in column names as delimiters for nested fields rather than as part of a literal column name. As telemetry is flattened into a tabular schema, these attribute names are therefore typically normalized before they become columns.</p><p>A common normalization strategy converts different naming conventions into a single representation:</p><pre>session.id<br>session-id<br>session_id<br>↓<br>session_id</pre><p>The normalization is convenient, but it destroys information. Three distinct attribute names become one destination column. Once normalized, the pipeline has lost the ability to distinguish how those attributes were originally named.</p><h3>The collision is a consequence of the design</h3><p>Most telemetry platforms support customer-defined attributes. That’s part of the value proposition — customers can emit the fields that matter to their applications without waiting for the platform to define them.</p><p>That flexibility comes with an architectural consequence. Once arbitrary customer-defined attributes are promoted into first-class columns, it becomes inevitable that two independently valid attribute names will eventually normalize into the same destination column.</p><p>The collision isn’t a bug. It’s the delayed operational consequence of choosing schema flexibility over schema control.</p><h3>When the collision finally happens</h3><p>Imagine two records arriving in the same processing batch.</p><p>One contains session.id.</p><p>Another contains session-id.</p><p>After normalization, both become session_id.</p><p>The pipeline now has two different source attributes <strong>resolving to the same destination column</strong>. It cannot deterministically decide which value should be retained without silently overwriting the other. Rejecting the schema is the only safe outcome.</p><p>The important observation isn’t that the schema failed. It’s where it failed. The unit of failure isn’t the record. It’s the batch.</p><h3>The batch becomes the blast radius</h3><p>Most large telemetry systems process data in batches. A batch is rarely composed of records from a single customer. It is usually a mixture of telemetry from many customers, regions, products, and versions, bundled together for throughput and cost efficiency.</p><p>Once a schema conflict appears, Spark does not provide record-level schema isolation. You cannot quarantine only the two conflicting records and allow the rest of the batch to continue. The pipeline cannot surgically remove the problem and proceed safely.</p><p>That is what turns a schema issue into a multi-tenant reliability problem. A conflict caused by one customer’s telemetry can block or discard records from many customers who did nothing wrong.</p><p>At that point, the platform has only two choices: stop ingestion and preserve correctness, or keep ingestion moving and accept telemetry loss. Neither choice is universally correct. But the decision has to be made deliberately, because the batch is now the blast radius.</p><h3>Why not isolate every tenant?</h3><p>The obvious question is: why not process every tenant independently?</p><p>If each customer had its own pipeline, one customer’s schema conflict couldn’t affect anyone else.</p><p>In practice, few high-throughput telemetry platforms choose that model. Independent pipelines multiply scheduling overhead, reduce batching efficiency, fragment compute resources, and significantly increase operational complexity. Most systems deliberately batch telemetry across many tenants because it is the only economically viable way to sustain high throughput.</p><p>Batching improves throughput and reduces cost, but it also couples failure domains. The batch — not the tenant — becomes the unit of failure.</p><p>That’s an architectural decision, not an implementation detail. The question is no longer whether failures happen. It’s whether you’ve deliberately chosen who shares the blast radius.</p><h3>Why global metrics hide the problem</h3><p>Suppose a platform processes millions of batches per day and encounters only a few dozen schema collisions. At the fleet level, the impact is almost invisible. Ingestion success remains effectively perfect, global SLOs stay green, and leadership sees a healthy platform.</p><p>But telemetry loss isn’t distributed evenly. A discarded batch affects only the tenants whose records happened to be inside it. Across the fleet, the loss might represent just 0.001% of processed telemetry. For one affected tenant during that same period, it could represent most of their observability data.</p><p>The aggregate hides the individual failure. A platform can appear highly reliable while a single tenant experiences a meaningful outage.</p><h3>The fairness problem</h3><p>This is where the issue stops being a Spark problem and becomes a platform problem.</p><p>Customer A emitted perfectly valid telemetry.</p><p>Customer B emitted a different, equally valid schema.</p><p>Independently, neither customer did anything wrong. But once their records were processed together, the platform’s normalization strategy produced a schema collision that could no longer be represented safely. If the batch is discarded, both customers lose telemetry — even though neither violated the platform’s contract.</p><p>Responsibility and impact have become decoupled.</p><p>In a well-isolated system, the customer that experiences a failure is usually the one whose workload triggered it. Here, that relationship breaks down. A platform-level design decision allows one tenant’s data to become part of another tenant’s failure domain.</p><p>From the customer’s perspective, this isn’t a schema conflict. It’s a platform outage. Their telemetry disappeared because the platform couldn’t isolate the consequences of a shared schema.</p><p>If you’re measuring only fleet-wide reliability, you may never notice. The platform looks healthy while a single tenant repeatedly absorbs someone else’s blast radius.</p><p>The aggregate is healthy. The individual is in breach.</p><h3>There is no perfect answer</h3><p>Customer-defined telemetry creates schema risk. Schema normalization creates the possibility of collisions. Shared batches create shared blast radii. Global metrics can conceal tenant-level failures. None of those realities can be eliminated entirely.</p><p>The goal is to make deliberate architectural decisions about them. How large is the failure domain? Which customers share it? How much telemetry loss is acceptable? And how would you know when an individual tenant, rather than the fleet as a whole, has been harmed?</p><p>Those are architectural decisions — not implementation details. If you don’t make them deliberately, arrival order and production traffic will make them for you.</p><p><em>I write about the design problems behind large-scale data platforms — the parts that don’t make it into architecture diagrams. More coming on batch sizing, multi-region blast radius, and capacity headroom economics.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=04e5ddf87471" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What At-Least-Once Delivery Actually Costs You at Scale]]></title>
            <link>https://medium.com/@vishal.s.jain/what-at-least-once-delivery-actually-costs-you-at-scale-de769a93c0b8?source=rss-15ffefc2a680------2</link>
            <guid isPermaLink="false">https://medium.com/p/de769a93c0b8</guid>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[streaming]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[apache-spark]]></category>
            <dc:creator><![CDATA[Vishal Jain]]></dc:creator>
            <pubDate>Thu, 11 Jun 2026 10:10:44 GMT</pubDate>
            <atom:updated>2026-06-11T10:10:44.575Z</atom:updated>
            <content:encoded><![CDATA[<h4>Every streaming architecture blog says the same thing: “exactly-once semantics.” Every delivery system underneath says something different: <em>at-least-once</em>. Both statements are true at the same time — and the distance between them is where your engineering effort, your compute bill, and your 2 AM pages live.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w_0xIBjD71Ly83PMvwK1eQ.png" /><figcaption>Two duplicate classes, two defenses: adjacent producer retries die in-batch; time-separated replays need reconciliation.</figcaption></figure><p>This gap is where many large-scale data platforms end up paying the bill. Databricks’ recent post on <a href="https://www.databricks.com/blog/10-trillion-samples-day-scaling-beyond-traditional-monitoring-infra-databricks">scaling their monitoring infrastructure to 10 trillion samples a day</a> is an excellent read on the ingestion architecture — but like most architecture posts, it stops at the framework promise. This post is about the part underneath: what at-least-once delivery makes you responsible for, and what it costs to meet that responsibility at scale. The examples are from OCI (a platform that deserves more ink than it gets), but the patterns apply unchanged to Kafka, Kinesis, or any partitioned log.</p><h3>The setup</h3><p>Consider a common shape of pipeline. A log file lands in object storage in one tenancy. An eventing rule fires, and an event — carrying metadata about the file, including its URI — is delivered to a stream (think: a Kafka topic) in your tenancy. A Spark Structured Streaming job reads events off that stream in micro-batches, extracts the file URIs, fetches the files from the source object store, processes them, and persists the results to the data lake — the bronze layer, in medallion terms.</p><p>The eventing system’s commitment to you is simple: it will deliver <em>all</em> events. Read that SLA again, from the consumer’s side: <strong>it will deliver all events at least once — so you, the consumer, own the dedupe story.</strong> The delivery guarantee and the duplication problem are the same sentence.</p><p>And note what Structured Streaming’s exactly-once guarantee actually covers: its own path, from checkpoint to sink. It does not — cannot — know that two distinct events on the stream describe the same file. Duplicates that enter upstream of the framework are invisible to it. They are application data, and only the application can resolve them.</p><h3>Two kinds of duplicates</h3><p>Here’s the structural insight that took us an incident or two to articulate: duplicates are not one problem. They are two problems with different shapes, and each shape admits a different — and differently priced — defense.</p><p><strong>Class 1: Producer-side duplicates.</strong> Most duplication happens at production time — a publisher retries on an ambiguous acknowledgment and the same event lands twice. Because both copies are produced within moments of each other, they arrive <em>nearly adjacent in time</em>, even when round-robin scatters them across partitions. Adjacency is a gift: it means the duplicates will, with high probability, land inside the same micro-batch.</p><p><strong>Class 2: Time-separated duplicates.</strong> A consumer restart replaying from a checkpoint, an event re-delivered after a long delay, or simply two copies straddling a batch boundary. These arrive minutes — or hours — apart. No within-batch logic will ever see both copies at once.</p><p>Once you see the two classes, the architecture writes itself: a cheap defense for the common class, a reconciliation layer for the rare one.</p><h3>Layer 1: In-batch dedupe (cheap, catches most of it)</h3><p>The streaming job reads a micro-batch — batch sizing is its own art (too small and you’re paying per-batch overhead for nothing; too large and latency and memory suffer — a topic for another post), but say a few thousand events per trigger. The batch spans all partitions, so producer-side duplicates, being adjacent in time, are almost always present together within it. A single dedupe of the batch DataFrame on the natural key — here, the file URI — eliminates them before any expensive work happens.</p><p>The economics of this layer are relatively cheap: it’s one operation on data already in memory. No state store, no watermark management, no growing checkpoint. The larger the batch, the higher the capture rate. What escapes is only the boundary cases — copies that straddled a batch edge — plus all of Class 2.</p><p>Which raises the real question, and it’s not a technical one.</p><h3>The tolerance question</h3><p>What duplication rate can your <em>consumers of the data</em> live with? This is a product decision wearing an engineering costume. For analytics aggregations, 0.05% duplication may be entirely invisible in any decision anyone makes with the data. For billing or reconciliation-grade data, the answer may be zero.</p><p>You cannot design the second layer until someone has answered this question explicitly. Get the number, write it down, and design to it — not to an unexamined instinct that “duplicates are bad.”</p><h3>Layer 2: Reconciliation (expensive, catches the rest)</h3><p>For pipelines where the tolerance is tight, add a reconciliation pass at a natural boundary — end of day is a common one. The mechanics: persist the processed keys (file URIs) per batch as you go. Before the downstream EOD process runs, dedupe across the full day’s keys and compare the distinct count against the cumulative per-batch count.</p><p>Within threshold? Proceed — the near-real-time data stands. Outside threshold? Reprocess the day as a batch, discard the near-real-time output, and let the corrected data flow forward. The downstream process starts late, and you eat a day’s worth of redundant compute — but the data is right.</p><p>That’s the honest cost accounting of at-least-once delivery: <strong>you pay either in state (maintaining dedupe state continuously in the stream) or in reprocessing (periodically reconciling and redoing work)</strong>. We chose reprocessing-on-breach because, at our volumes, continuously maintained dedupe state across billions of events was a permanent tax on every batch, while reconciliation breaches were rare enough that the occasional batch redo was the cheaper expectation value. Your volumes and your tolerance may point the other way. The point is that it’s a choice, and it should be made with the costs on the table.</p><h3>What I’d tell someone designing this today</h3><p>1. <strong>Read every delivery SLA from the consumer’s side.</strong> “We deliver everything” means “you will receive some things twice.” The dedupe story is yours from day one — design it in, don’t retrofit it after the first data-quality incident.</p><p>2. <strong>Split the duplicate problem by arrival shape before choosing a mechanism.</strong> Adjacent duplicates are cheap to kill in-batch; time-separated ones need state or reconciliation. One mechanism sized for the worst case overpays for the common case.</p><p>3. <strong>Make the tolerance threshold an explicit, owned number.</strong> The most important parameter in this whole design isn’t in any Spark config — it’s the duplication rate your data’s consumers signed off on. Engineering can’t derive it; it has to be asked for.</p><p>4. <strong>Price both defenses honestly.</strong> Continuous dedupe state and periodic reprocessing both work. They fail differently, scale differently, and cost differently. The right answer is arithmetic on your event volume, your breach frequency, and your latency budget — not a default.</p><p>Exactly-once is a wonderful property — inside the boundary where your framework can enforce it. At the system level, it isn’t a feature you enable. It’s a budget you spend, somewhere, every day. Better to choose where.</p><p><em>I write about the design problems behind large-scale data platforms — the parts that don’t make it into architecture diagrams. More coming on batch sizing, multi-region blast radius, and capacity headroom economics.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de769a93c0b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>