<?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 Varun Pathania on Medium]]></title>
        <description><![CDATA[Stories by Varun Pathania on Medium]]></description>
        <link>https://medium.com/@pathaniavarun?source=rss-7dc968b34523------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Varun Pathania on Medium</title>
            <link>https://medium.com/@pathaniavarun?source=rss-7dc968b34523------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 13:46:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pathaniavarun/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[What Is Apache Flink, and How Does It Relate to Dataflow?]]></title>
            <link>https://medium.com/@pathaniavarun/what-is-apache-flink-and-how-does-it-relate-to-dataflow-952f1baa257f?source=rss-7dc968b34523------2</link>
            <guid isPermaLink="false">https://medium.com/p/952f1baa257f</guid>
            <category><![CDATA[apache-beam]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[streaming]]></category>
            <category><![CDATA[apache-flink]]></category>
            <category><![CDATA[big-data]]></category>
            <dc:creator><![CDATA[Varun Pathania]]></dc:creator>
            <pubDate>Wed, 23 Sep 2026 21:44:30 GMT</pubDate>
            <atom:updated>2026-09-23T21:44:30.467Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Part 2 of an ongoing series about a real migration: streaming pipelines moved from Google Cloud Dataflow to Apache Flink, self-hosted on on-prem Kubernetes with the Flink Kubernetes Operator. All pipelines read from Kafka, and the heaviest one runs three ML models inline on CPU. </em><a href="https://medium.com/@pathaniavarun/why-we-left-google-dataflow-c8e93dc1372d"><em>Part 1</em></a><em> covered why we migrated. This post is the primer: the concepts and vocabulary the rest of the series builds on.</em></p><p>You keep hearing “we should look at Flink” in architecture meetings, usually right after someone opens the cloud bill. In part 1, that someone was us. Before we get into operators, benchmarks, and checkpoint tuning, this post answers the prerequisite questions: what Apache Flink actually is, how it relates to Dataflow, and why the two are close enough that a migration between them is realistic at all.</p><p>No Kubernetes, no YAML, no code needed to follow along. Just the mental model.</p><p><strong>Who this is for:</strong> engineers and engineering managers who know roughly what a data pipeline is, but could not confidently explain what Flink does or why it keeps coming up as the Dataflow alternative.</p><h3>First: what problem do both of these tools solve?</h3><p>Software used to process data the way you do laundry. Let it pile up, then run a big load overnight. That is <strong>batch processing</strong>. It is simple and it works, but your answers are always hours old.</p><p>Modern products cannot wait that long. A price changes, a review lands, an image gets uploaded, and something downstream needs to react in seconds. That is <strong>stream processing</strong>: instead of processing a pile, you process an endless conveyor belt of events, one by one, as they arrive.</p><p>Stream processing sounds simple until you meet its four hard problems:</p><ol><li><strong>The belt never stops.</strong> There is no “end of file.” Your program runs 24/7, for months, and must survive crashes without losing or double-counting events.</li><li><strong>You have to remember things.</strong> “How many clicks in the last 5 minutes?” means keeping a running count somewhere. That memory is called <strong>state</strong>, and in real pipelines it can grow to many gigabytes.</li><li><strong>Events arrive late and out of order.</strong> A mobile user’s click from 12:01 might show up at 12:04, after the 12:02 events already did. If you are counting clicks per minute, which minute does it belong to? This only bites if you care about <strong>event time</strong>, when something actually happened. Switch to <strong>processing time</strong> instead, when your system happens to see it, and lateness stops being a problem: whatever arrives now belongs to now. That simplicity has a cost, your counts now depend on network delays and restarts instead of on reality, which is why most serious analytics choose event time and deal with lateness honestly instead of defining it away.</li><li><strong>Steps run at different speeds.</strong> A transform that parses JSON needs a sliver of a core. A transform that calls an ML model needs whole cores and real time. Chain them together and the fast step will pile work up in front of the slow one, forever, unless something pushes back.</li></ol><p>Every serious streaming system is an answer to these four problems. Flink and Dataflow happen to give the same answer, which is the key to this whole story.</p><h3>What is Apache Flink?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*XRWBi4SE6XGcmf-m.png" /></figure><p>Apache Flink is an open-source engine for stream processing. You write a program describing what should happen to each event: parse it, filter it, join it, run a model on it, count it in time windows. Flink runs that program continuously, across many machines, and keeps it correct when those machines fail.</p><p>A running Flink job has two kinds of components, and the names say it all:</p><ul><li><strong>JobManager</strong>: the foreman. It does not touch data. It schedules work, tracks progress, and coordinates recovery when something dies.</li><li><strong>TaskManagers</strong>: the crew. As many as you need. They do the actual work, each holding a slice of the data and a slice of the state.</li></ul><p>Two more words you will meet constantly in this series, so let’s define them here:</p><ul><li><strong>Task slots</strong>: each TaskManager offers a fixed number of slots, and each slot can run one parallel piece of work. A TaskManager with 4 slots runs 4 tasks at once.</li><li><strong>Parallelism</strong>: how many copies of each processing step run at the same time across the whole job. The ceiling is simple arithmetic: TaskManagers times slots per TaskManager gives you total slots, and parallelism cannot exceed that number. Getting the ratio of parallelism to slots to cores right turned out to be one of our biggest tuning levers, and it gets its own post later, since it plays out differently for different pipelines.</li></ul><p>Four ideas make Flink what it is, and they map exactly onto the four hard problems above:</p><p><strong>1. Checkpoints, for surviving crashes.</strong> At a regular interval, Flink snapshots everything: every counter, every window, every “where was I on the conveyor belt” position, and writes the snapshot to durable storage. When a machine dies, Flink rewinds to the last checkpoint and replays from there. Recovery is automatic, no manual intervention needed. A <strong>savepoint</strong> is the same snapshot taken manually, used for upgrades and migrations rather than crash recovery.</p><p><strong>2. Managed state, for remembering at scale.</strong> Flink stores your running counts and joins in an embedded database (RocksDB) on each worker, covered by those checkpoints. Large state, many gigabytes without special effort, is routine. You write “count per user” and Flink handles where that count lives and how it survives failures.</p><p><strong>3. Event time and watermarks, for handling lateness.</strong> Flink can group events by event time, when they actually happened, instead of processing time, when they arrived. A <strong>watermark</strong> is Flink’s running estimate of “I have probably seen everything up to 12:02 by now,” the signal that it is safe to close the 12:01 to 12:02 window. Late stragglers are handled by policy instead of silently corrupting your numbers. Stick to processing time only and this whole mechanism becomes unnecessary, along with the guarantee that your numbers reflect what actually happened rather than when it happened to arrive.</p><p><strong>4. Backpressure, for handling mismatched speeds.</strong> When a downstream step cannot keep up, Flink does not crash it or quietly drop data. It slows the upstream step down to match, propagating that signal backward until the whole job runs at the pace of its slowest link. Watching it happen looks like the pipeline stalling, and monitoring dashboards call it out by name, but it is Flink working as designed: a full buffer is a signal, not a failure. You will see this idea again later in the series.</p><p>Here is the whole machine in one picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Cg1-ZyoIQeY01DOJ60ceg.png" /></figure><p>If checkpoints, state, and watermarks feel familiar, there is a reason. Google described this exact approach to event time and watermarks in its own research, most notably the Dataflow Model paper linked below, and both Google Cloud Dataflow and Apache Flink built their handling of event time around it. Independent research comparing the two systems has found their watermark semantics essentially equivalent. They are the two most faithful implementations of the same idea in existence.</p><h3>So what is Dataflow, and how are they related?</h3><p>Google Cloud Dataflow is a <strong>managed service</strong> that runs streaming and batch pipelines for you. You submit code; Google provisions the workers, scales them, patches them, stores the state, and carries the pager.</p><p>Here is the relationship that makes migration even thinkable. Most pipelines on Dataflow are not written “in Dataflow.” They are written in <strong>Apache Beam</strong>, a framework that describes <em>what</em> your pipeline does, deliberately separate from <em>where it runs</em>. Beam pipelines run on interchangeable engines called <strong>runners</strong>, and:</p><ul><li>Dataflow is one runner, the managed one.</li><li><strong>Flink is another runner, the most complete open-source one.</strong></li></ul><p>A useful analogy: Beam is the recipe. Dataflow is a restaurant that cooks it for you, at restaurant prices. Flink is a professional kitchen you run yourself. Same recipe, same dish. The choice is about who does the cooking and what they charge.</p><p>The same Beam pipeline code runs on the Dataflow runner or the Flink runner</p><p>Comparison: Dataflow is a managed service, Flink is the same model self-hosted, both run the same Beam code</p><p>That last row is why this conversation ever starts.</p><h3>Why do teams move from Dataflow to Flink?</h3><p>Mostly the bill: Dataflow’s premium is structural, baked into the SKU rather than negotiable, and it scales with compute, so ML-heavy, always-on pipelines feel it every month. The technical fit helps too: checkpoints already write your job’s state to durable storage outside any single machine, so Flink treats losing a worker, whether to a crash or a reclaimed spot instance, as a routine event, and that lets it run on cheap, interruptible compute unusually well. Kafka-centric shops have the smoothest path, since Kafka to Flink is the most traveled pairing in streaming, while Dataflow’s home turf is Pub/Sub. Part 1 has the full argument, with our own numbers.</p><h3>Why you might not move</h3><p>Every one of those reasons is paid for in operations: your team now owns what Google’s SREs did invisibly. As rough thresholds, a handful of small, occasional pipelines will not save enough to justify the effort, a team with no Kubernetes experience should not learn it via the streaming platform, and a Pub/Sub-only estate hits the roughest edge of the whole migration. Plenty of 24/7 pipelines, Kafka already in place, and a platform team comfortable with Kubernetes, and the trade starts paying for itself. Part 1 walks through how we weighed this for our own fleet.</p><h3>The mental model to walk away with</h3><ol><li>Streaming means processing an endless conveyor belt, and the hard parts are crashes, memory, late events, and steps that run at different speeds.</li><li>Flink and Dataflow both solve all four, the same way in spirit: durable checkpoints for crashes, managed state for memory (RocksDB in Flink, Streaming Engine in Dataflow), watermarks for lateness, and backpressure for speed mismatches.</li><li>Dataflow and Flink implement the same model, and Beam makes pipeline code portable between them. A migration is a re-platform, not a rewrite.</li><li>The trade is money for operations. Whether it is a good trade depends on the platform and people you already have.</li></ol><p>That is the vocabulary. From here the series gets practical: how we chose the engine, how the POC went, what we tuned, and what it all saved. Look out for more Flink posts in this series.</p><h3>Further reading</h3><ul><li><a href="https://nightlies.apache.org/flink/flink-docs-stable/">Flink documentation</a>, the reference for everything in this post</li><li><a href="https://nightlies.apache.org/flink/flink-docs-stable/docs/concepts/flink-architecture/">Flink architecture</a>, the official version of the JobManager and TaskManager story</li><li><a href="https://nightlies.apache.org/flink/flink-docs-stable/docs/concepts/stateful-stream-processing/">Stateful stream processing concepts</a>, checkpoints and state explained by the people who built them</li><li><a href="https://beam.apache.org/documentation/basics/">Basics of the Beam model</a>, the recipe half of the recipe-and-kitchen analogy</li><li><a href="https://www.vldb.org/pvldb/vol8/p1792-Akidau.pdf">The Dataflow Model paper (VLDB 2015)</a>, the research both engines descend from</li></ul><p><em>Apache Flink, Flink, and the Flink logo are trademarks of The Apache Software Foundation. This series is an independent account and is not affiliated with or endorsed by the ASF.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=952f1baa257f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why We Left Google Dataflow]]></title>
            <link>https://medium.com/@pathaniavarun/why-we-left-google-dataflow-c8e93dc1372d?source=rss-7dc968b34523------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8e93dc1372d</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[apache-flink]]></category>
            <category><![CDATA[streaming]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Varun Pathania]]></dc:creator>
            <pubDate>Sat, 05 Sep 2026 14:13:27 GMT</pubDate>
            <atom:updated>2026-09-05T14:13:27.361Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why We Left Google Dataflow</h3><p><em>Part 1 of an ongoing series about a real migration: streaming pipelines moved from Google Cloud Dataflow to Apache Flink, self-hosted on on-prem Kubernetes with the Flink Kubernetes Operator. All pipelines read from Kafka, and the heaviest one runs three ML models inline on CPU. If Flink is new to you, part 2 of this series is a primer that covers the basics.</em></p><p>Every migration story starts with a bill. Ours is no different, so let’s not pretend otherwise.</p><p>For years we ran our streaming pipelines on Google Cloud Dataflow, and Dataflow did its job well. Pipelines stayed up. They scaled on their own. Nobody carried a pager for them, because Google did. If you had asked us in those years whether we were happy, we would have said yes.</p><p>Then we looked closely at where the money was going.</p><h3>The shape of the problem</h3><p>We had about nine pipelines running on Dataflow, all owned by teams working on content: reviews, images, that kind of data. Most of them follow the same simple pattern. Read events from a message queue, transform them, sometimes run a machine learning model on each event, write the results to BigQuery or MySQL.</p><p>That “sometimes run a machine learning model” part is where the bill lived.</p><p>Here is the thing about running ML inference inside a streaming pipeline: it eats CPU like nothing else in the job. A transform that parses JSON needs a sliver of a core. A model scoring images or text needs whole cores, all day, every day, because the stream never stops. Our heaviest pipeline runs three models inline and our biggest job scaled up to 150 workers, which is 300 vCPUs, just to keep up with the stream.</p><p>And Dataflow does not bill you for VMs. It bills you for Dataflow.</p><p>The workers behind a Dataflow job are ordinary Google Cloud VMs, but you pay for them through Dataflow’s own pricing, which carries a healthy service premium on every vCPU-hour and every gigabyte of memory. That premium is the product. It pays for the autoscaling, the invisible upgrades, the fact that nobody on your team has ever SSH’d into a Dataflow worker. For a small fleet, it is a great deal.</p><p>But the premium scales with your compute, and ML-on-CPU workloads are almost nothing but compute. So the pipelines that needed the most cores paid the most premium, month after month, for years. Nothing was broken. Nothing was wasteful in the usual sense. The bill was simply the price list multiplied by our workload, and our workload was not getting smaller.</p><h3>The question we actually asked</h3><p>The question was never “is Dataflow bad?” It is not. The question was more uncomfortable:</p><p><strong>We already pay for our own hardware and our own people. What is the managed premium still buying us, for these specific pipelines?</strong></p><p>That framing matters, because the honest answer depends entirely on what you already have. Here is what we already had, before anyone said the word Flink:</p><ul><li>On-prem Kubernetes clusters, run by our platform teams, with capacity to spare</li><li>Kafka, both on-prem and in the cloud, already carrying most of the data these pipelines consume</li><li>A GitOps deployment setup (ArgoCD, Helm) that every service already used</li><li>Monitoring, logging, alerting, and an SRE team that runs all of it</li></ul><p>In other words, the expensive part of self-hosting a stream processor, which is the platform underneath it, was already built, already staffed, and already paid for. The marginal cost of putting one more workload on it was small.</p><p>If your checklist looks different, if you would be building Kubernetes fluency from scratch just to host a stream processor, stop here. The Dataflow premium is much cheaper than that project. This is the part most migration blog posts skip, and it is the part that decides whether the whole thing makes sense.</p><h3>Why Flink</h3><p>Once you decide to self-host, you need an engine, and we picked Apache Flink. How we chose it is a story for its own post, but the short version has two parts.</p><p>First, Flink and Dataflow implement the same processing model. Event time, watermarks, windows, stateful processing with checkpoint-based recovery. Flink is the closest open-source relative Dataflow has.</p><p>Second, and this is the practical one: our pipelines were written in Apache Beam, and Beam pipelines are portable across runners. Dataflow is one runner. Flink is another. That meant our Python pipeline code could survive the migration mostly untouched. We were changing where the pipelines run, not rewriting what they do. A migration that requires rewriting nine pipelines is a different, much worse project.</p><h3>Deciding with a POC, not a slide deck</h3><p>We did not migrate nine pipelines. We ran a proof of concept on one, and we wrote down what it had to prove before we started:</p><ol><li><strong>Correctness.</strong> The Flink job must produce exactly the same output as the Dataflow job when fed the same input. Not similar. The same.</li><li><strong>Feasibility.</strong> The existing Beam Python code must run on Flink without a rewrite, using the Flink Kubernetes Operator on our stage cluster.</li><li><strong>Performance we can reason about.</strong> Flink did not need to beat Dataflow on day one, but we needed to understand what performance depends on and see a credible path to parity.</li><li><strong>Ops we can carry.</strong> Deployment through our normal GitOps flow, metrics in our normal dashboards, failures recoverable by our normal on-call.</li></ol><p>We picked the reviews pipeline as the guinea pig, because it contains every shape we cared about in one application: Kafka in, transformations, ML functions inline, BigQuery out, plus a batch variant that reads files from object storage. If that one worked, the rest were simpler cases of the same thing.</p><p>We also wrote down what we expected to lose, because pretending a managed service does nothing is how migrations fail. We expected to lose mature autoscaling, invisible upgrades, and someone else’s pager. We got exactly what we expected to lose, and dealing with each of those is what the rest of this series is about.</p><h3>How it turned out, in one paragraph</h3><p>The POC worked. Same Kafka messages in, identical output in BigQuery, running as Beam code on the Flink runner with the Kubernetes operator. Performance turned out to be a hardware story more than a software story: on our old servers, the Flink job needed 100 cores to do what Dataflow did in 15 minutes, and still took three times longer. On newer servers, 32 cores did the same work in 11 minutes. That result, and the tuning lessons that came with it, is a story for a later post.</p><p>Today, three of the pipelines run in production on self-hosted Flink, including the heavy one with the three ML models. The remaining candidates are queued up behind them.</p><p>Here is the shape of the change in one picture. Compute moved onto hardware we already own. The data services that earn their keep, and would be hard to replace, stayed in the cloud:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SdrmH6is5bORHor39gg_Ow.png" /></figure><p>Before and after: compute moved on-prem, Pub/Sub and BigQuery stayed in Google Cloud</p><h3>What comes next</h3><p>If you only take one thing from this post, take the question. Not “should we leave Dataflow,” but “what is the premium buying us, for these pipelines, given what we already run.” Answer that with your own bill and your own platform, and the rest of the decision mostly makes itself.</p><p>That was the why. The how is where it gets interesting: the engine choice, the POC and its hardware surprise, the configs we tuned per pipeline, the checkpoint story, and what the whole thing actually saved. Those posts are coming. Look out for more Flink in this series.</p><h3>Further reading</h3><ul><li><a href="https://cloud.google.com/dataflow/pricing">Google Cloud Dataflow pricing</a>, the price list behind the math in this post</li><li><a href="https://beam.apache.org/">Apache Beam</a>, the framework our pipelines are written in</li><li><a href="https://flink.apache.org/">Apache Flink</a>, where they run now</li><li><a href="https://beam.apache.org/documentation/runners/flink/">The Beam Flink runner</a>, the bridge that made the migration a re-platform instead of a rewrite</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8e93dc1372d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>