<?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 Mariasaprykina on Medium]]></title>
        <description><![CDATA[Stories by Mariasaprykina on Medium]]></description>
        <link>https://medium.com/@mariasaprykina07?source=rss-435b7771d7e7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*rPM258yJBd2B6oss.jpg</url>
            <title>Stories by Mariasaprykina on Medium</title>
            <link>https://medium.com/@mariasaprykina07?source=rss-435b7771d7e7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 16:14:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mariasaprykina07/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[Batch vs. Streaming: Why We No Longer Need to Treat Them Separately]]></title>
            <link>https://medium.com/@mariasaprykina07/from-lambda-to-delta-lake-1fa9b183e201?source=rss-435b7771d7e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fa9b183e201</guid>
            <category><![CDATA[lambda-architecture]]></category>
            <category><![CDATA[spark-streaming]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-architecture]]></category>
            <category><![CDATA[delta-lake]]></category>
            <dc:creator><![CDATA[Mariasaprykina]]></dc:creator>
            <pubDate>Wed, 04 Nov 2026 14:41:45 GMT</pubDate>
            <atom:updated>2026-11-04T19:57:16.942Z</atom:updated>
            <content:encoded><![CDATA[<h3>It was supposed to be a one-line fix</h3><p>Imagine you’re working on a data platform for an e-commerce company. One morning, someone from the analytics team reports a strange issue: the revenue dashboard has been showing orders from Poland under North America for the past three days.</p><p>You investigate and quickly find the issue. A simple bug in the transformation logic: instead of PL -&gt; North America, the mapping should be PL -&gt; Europe.</p><p>One line to fix. Should be easy, right?</p><p>Except that the same transformation exists in two different pipelines. One periodically processes data in batches, while the other processes only recent orders as a stream, in real time. So now you have to fix the same bug in two places, recalculate the affected data, and make sure both pipelines stay in sync, without counting the same orders twice or missing any of them.</p><p>But why did we need two pipelines implementing the same business logic in the first place?</p><p>To understand that, we need to go back to a time when batch and streaming were treated as completely separate worlds.</p><h3>Lambda Architecture: the best of both worlds</h3><p>In the early 2010s, with the rise of frameworks like Kafka and Apache Storm, the popularity of streaming data exploded. Everyone wanted dashboards with sub-second latency.</p><p>Streaming systems provided fast updates, but at a cost of correctness. Streaming meant dealing with late events, duplicate delivery and partial failures. To handle these issues, engineers had to write complex, fragile state logic. And if something went wrong with the data, it could mean hours of debugging and recovering to a clean state.</p><p>Batch systems, on the other hand, were reliable, predictable and easy to reason about. In a classic batch architecture built on an immutable master dataset, mistakes were remarkably cheap. If a query contained a bug or downstream data was corrupted, all you had to do was fix the logic and recompute everything from scratch. But processing data in batches took time, which was of course not an option for real-time analytics.</p><p>In 2011 Nathan Marz proposed an idea in his <a href="https://nathanmarz.com/blog/how-to-beat-the-cap-theorem.html">article (How to beat the CAP theorem)</a>, describing how batch and streaming systems can work together in tandem.</p><p>His point was that the batch system alone already gives us the whole history of clean and correct data up until the latest batch run. The only thing left is to cover the small window of recent data that has not yet been included. And anything the streaming pipeline computes will eventually be replaced by the next batch result.</p><p>So the idea was to keep recent data as accurate as possible, while batch remains the source of truth and can fix things if something goes wrong.</p><p>This approach became known as Lambda Architecture, consisting of three main components.</p><p>Batch layer</p><ul><li>periodically ingested and transformed new data</li><li>stored raw immutable data in durable, relatively inexpensive storage that could later be used to recover data in case of breaking changes in the upstream or a bug in the code</li></ul><p>Speed layer</p><ul><li>ingested and transformed recent data that had not yet been included into the batch view</li><li>stored data in a low-latency NoSQL database designed for fast reads and frequent incremental updates</li></ul><p>Serving layer</p><ul><li>stitched together data produced by batch and streaming layers.</li><li>the output was used by downstream consumers for analytics.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*b1OXOZ5ref06vNmP" /></figure><h3>It’s easy until it’s not</h3><p>At first, it looks pretty straightforward. Batch takes care of the history, streaming takes care of the latest data, and the serving layer combines the two.</p><p>But here is the catch: we now have two processing pipelines that must agree on which data belongs to each, and how that data should be transformed.</p><p>Let’s go back to our e-commerce dashboard from the beginning. In a Lambda Architecture, the batch pipeline runs every day and calculates revenue by region up to the latest batch run. The streaming pipeline handles the orders that haven’t been included in the batch results yet. The serving layer combines the two to produce the final numbers shown on the dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zWMHKo-QFTdNwfJ6" /></figure><p>First challenge appears already at this point when nothing is wrong with the data yet.</p><p>In order to keep two systems in sync, engineers must implement a robust handoff logic that will let streaming pipeline identify which part of its result has already been included into the latest batch view. This introduces a tight coupling between two systems.</p><p>For example, suppose the current batch view contains events 1–1000, while the streaming view contains events 1001–1100. Once the next batch run finishes and now includes everything up to event 1080, the streaming pipeline must stop showing events 1001–1080 and keep only 1081–1100. Otherwise, the serving layer would count the same events twice.</p><p>Now comes the second challenge: business logic.</p><p>Remember our orders from Poland being classified as North America?</p><p>While the fix itself is one line, the problem is that this logic exists in two places. The team has to fix the mapping in the batch pipeline and then make the same change in the streaming pipeline. This usually happened because the two pipelines were built with different frameworks, APIs, and sometimes even different languages, so the same business rule had to be implemented twice.</p><h3>Kappa Architecture: streaming everywhere</h3><p>Then came the Kappa architecture. It was proposed by Jay Kreps in his <a href="https://www.oreilly.com/radar/questioning-the-lambda-architecture/">2014 article, Questioning the Lambda Architecture</a>, and it was simple: why not just make everything streaming? Instead of maintaining two parallel systems, Kappa kept all historical events in a long-retention log like Kafka. If transformation logic changed, the streaming job started again from an earlier Kafka offset and processed the same events with the new logic.</p><p>Simple as that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*skf1mR2OKbxXhHJe" /></figure><p>This eliminated the need for a batch pipeline, but that meant, a message broker stored the entire history of data, which is quite expensive, compared to a super cheap object storage like S3. Additionally, rebuilding a huge dataset meant replaying every event through a streaming engine, whether it was Apache Samza or Spark Streaming. However, using for this purpose Spark in a batch mode against a columnar object storage was typically much more efficient. Apparently, for these very reasons, Kappa architecture did not stick.</p><h3>Delta Architecture: unified batch and streaming</h3><p>At this point, both Lambda and Kappa were trying to glue together two different systems that were never designed to work as one.</p><p>What was missing is a model where batch and streaming were not separate systems at all, but just two ways of processing data, depending on whether it was bounded or unbounded. Google formalized this idea in the <a href="https://www.vldb.org/pvldb/vol8/p1792-Akidau.pdf%20%28Google">2015 Dataflow Model paper,</a> which later became the foundation for Apache Beam. Spark Structured Streaming followed a similar direction, and in this article I will focus on how this model, together with Delta Lake, changed the way we think about batch and streaming pipelines.</p><h3>Spark Structured Streaming</h3><p>Instead of treating a stream as a sequence of individual messages, it treats it as an unbounded table to which new rows are continuously added.</p><p>Before Structured Streaming, Spark used an abstraction called Discretized Streams, or DStreams. DStreams relied on RDD-based transformations, which looked quite different from standard SQL queries. Developers had to explicitly define transformations and manage stateful logic, making the code harder to reason about and maintain. Structured Streaming replaced this low-level approach with the familiar DataFrame and SQL APIs, treating the data as a clean, continuously updated table.</p><p>Consider an example of counting words from a continous lines of text. And let’s say you woult like not just count them for one particular second of event, but the total number of words at continously growing period of time.</p><p>Using Dstream, you need to apply imperative RDD transformations. So from Spark point of view, the incoming records are a black box of generic data. No schema, no columns, nothing to reason about. Additionally, in order to maintain a continously running word count, you need to manually define how state should be updated with every new micro-batch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Kao4_qsYkAEc_1pW" /></figure><p>In Structured Streaming, the stream is treated as a standard, schema-backed DataFrame table, as if you read a table in a normal batch read. So you can just apply a normal SQL groupBy transformation on it. The only difference is that this table is unbounded, or simply put, infinitely growing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l_IIgffl6sYtdsk-" /></figure><h3>One missing piece</h3><p>This was a significant breakthrough in a data engineering world, because now you could write streaming and batch transformation logic, using the same APIs. But one problem still remained. Structured Streaming unified how code was written, but traditional data lake storage was still fundamentally designed for static, batch operations. Without atomic guarantees, concurrent reads and writes risked producing corrupted, partially written files or duplicated records. To stream data in a reliable way, there was a need for something that traditional RDBMS had been utilizing for decades: a true ACID transactional layer.</p><h3>Delta Lake and the transaction log</h3><p>Delta Lake table is essentially just a collection of Parquet files in a cloud object storage. What made it a game-changer, is that along with those files it stores very important information, so called metadata. This metadata will tell you which files belong to which table, as well as which version of the table is visible to readers. And this exact metadata is what makes ACID transactions work. Because now, the reader only sees a fully committed version of a table, and never a failed or a partial write.</p><h3>What does this leave us with?</h3><p>Let’s go back to our e-commerce dashboard once again. This time, the streaming pipeline continuously reads new orders from a Bronze Delta table, applies the transformations and writes the results to Silver. From there, Gold provides the revenue aggregations used by downstream analytics.</p><p>This is how we typically organize our data as Delta tables, using what is widely known as the <a href="https://www.databricks.com/blog/what-is-medallion-architecture">Medallion Architecture</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DAdqTFv7dWEt-M9N" /></figure><p>Unlike Lambda Architecture, we no longer have two separate views, one produced by batch and another by streaming, that need to be stitched together. Instead, we have a single source-of-truth Delta table that can be continuously updated by streaming jobs and still safely queried or reprocessed as a normal historical table whenever needed.</p><p>There is also no longer a need for the handoff logic we had in Lambda. Streaming simply continues processing new records from its checkpoint, without having to worry about which historical data has already been processed by batch.</p><p>Moreover, even if a streaming job crashes or restarts mid-stream, Delta Lake’s transaction log ensures that uncommitted micro-batches are discarded.</p><p>Together, these mechanisms provide reliable recovery from failures, without requiring engineers to manually track progress, handle retries, or coordinate atomic writes.</p><p>Now let’s look at that same bug with orders from Poland being assigned to North America. The fix becomes much simpler. We update the transformation once, let streaming continue processing new data with the corrected logic, and run a one-time batch backfill over the affected period of time using the same transformation logic.</p><p>Transformation logic:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ymCWzDRQ3_TH3966" /></figure><p>Streaming pipeline applies it to a bronze delta table and writes to a silver:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*URoVhHyJ0Ff08O3e" /></figure><p>Reusing the same transformation logic for the historical backfill:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YKrZFtA9FFj2ME92" /></figure><p>And just like that, the biggest challenge of unifying batch and streaming processes has been solved.</p><h3>Wait, doest it mean we don’t need batch pipelines anymore?</h3><p>No, batch pipelines did not disappear. We still use batch whenever a standalone, scheduled job is the right tool for the job. Rather, it means we no longer maintain a <em>duplicate</em> batch pipeline running alongside streaming just as a safety net. Streaming becomes our default mode of processing, while batch will be used for distinct batch-native workloads or when we need to reprocess a bounded piece of history.</p><h3>Conclusion</h3><p>I wish I could say that Spark Structured Streaming and Delta Lake have solved all data engineering problems related to real-time data processing, but that would be simply not true. We still need to deal with late events, duplicates, failures and state management. Structured Streaming and Delta Lake take care of many things that engineers previously had to handle themselves. However, there are still challenges that require careful design, depending on the specific data and business requirements.</p><p>The key insight is that these technologies do not eliminate complexity, but they allow us to spend less time dealing with the infrastructure and more time solving the actual problems in our data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fa9b183e201" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>