<?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 Raghunandana Krishna Murthy Sanur on Medium]]></title>
        <description><![CDATA[Stories by Raghunandana Krishna Murthy Sanur on Medium]]></description>
        <link>https://medium.com/@skraghunandan11?source=rss-d9f99f7f79e7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*oHIwXm6Fv1VTGxKly0RbCQ.png</url>
            <title>Stories by Raghunandana Krishna Murthy Sanur on Medium</title>
            <link>https://medium.com/@skraghunandan11?source=rss-d9f99f7f79e7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 17:57:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@skraghunandan11/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[Predicate Push Down in Spark Is Not What You Think]]></title>
            <link>https://medium.com/@skraghunandan11/predicate-push-down-in-spark-is-not-what-you-think-8bbfe61c3682?source=rss-d9f99f7f79e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bbfe61c3682</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[spark-streaming]]></category>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Raghunandana Krishna Murthy Sanur]]></dc:creator>
            <pubDate>Sun, 20 Jul 2025 17:58:07 GMT</pubDate>
            <atom:updated>2025-07-20T17:58:07.544Z</atom:updated>
            <content:encoded><![CDATA[<p>Co-authored with <a href="https://www.linkedin.com/in/harish-chander-ramesh/overlay/about-this-profile/">Harish Chander Ramesh</a> / <a href="https://medium.com/u/906dccbad5f9">H DATA</a></p><p>If you’ve worked with Spark for a while, you’ve probably heard about predicate pushdown — a performance optimization technique that filters data as early as possible in the query execution plan. But what if I told you that predicate pushdown in Spark doesn’t always work the way you expect?</p><p>In this blog, we’ll debunk some common misconceptions, explore how predicate pushdown <em>really</em> works, and discuss cases where it might not behave as you’d hope.</p><h3>What Is Predicate Pushdown (Theoretically)?</h3><p>Predicate pushdown is an optimization where filter conditions are applied as close to the data source as possible, reducing the amount of data read and processed. For example:</p><pre>val df = spark.read.parquet(&quot;data.parquet&quot;).filter($&quot;age&quot; &gt; 30)</pre><p>In an ideal world, Spark would push the age &gt; 30 filter down to the Parquet reader, skipping entire row groups that don’t match the condition. This minimizes I/O and speeds up queries.</p><p>Sounds Great, Right? But Here’s the Catch…</p><p>While Spark <em>does</em> support predicate pushdown, it’s not always automatic or guaranteed. Let’s break down some surprising truths.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fULxyuMd5cpZ2pM6bBvcMA.png" /></figure><h3>1. Not All Data Sources Support Predicate Pushdown</h3><p>Spark can push predicates to formats like Parquet, ORC, and JDBC, but others (e.g., CSV, JSON) don’t inherently support it. If you apply a filter on a CSV file, Spark will still read the entire file and filter afterward.</p><pre>// Predicate pushdown works (Parquet)  <br>spark.read.parquet(&quot;data.parquet&quot;).filter($&quot;age&quot; &gt; 30)  // Efficient  <br><br>// Predicate pushdown does NOT work (CSV)  <br>spark.read.csv(&quot;data.csv&quot;).filter($&quot;age&quot; &gt; 30)  // Full scan  </pre><p>Key Takeaway: Always check if your file format supports predicate pushdown.</p><h3>2. Not All Predicates Are Pushable</h3><p>Even with Parquet, some filters can’t be pushed down. For example:</p><ul><li>UDFs (User-Defined Functions): Spark can’t push these into the storage layer.</li><li>Complex expressions: Some operations (like string manipulations) may prevent pushdown.</li></ul><pre>// This filter CAN be pushed down  <br>df.filter($&quot;salary&quot; &gt; 50000)  <br><br>// This filter CANNOT be pushed down (UDF)  <br>val isHighIncome = udf((salary: Int) =&gt; salary &gt; 50000)  <br>df.filter(isHighIncome($&quot;salary&quot;))  </pre><p>Key Takeaway: Stick to built-in Spark SQL functions for optimal pushdown.</p><h3>3. Partition Pruning ≠ Predicate Pushdown</h3><p>Many people confuse partition pruning (skipping entire directories in partitioned datasets) with predicate pushdown (skipping row groups within files).</p><pre>// Partition pruning (skips entire partitions)  <br>spark.read.parquet(&quot;partitioned_data/&quot;).filter($&quot;year&quot; === 2023)  <br><br>// Predicate pushdown (skips row groups within files)  <br>spark.read.parquet(&quot;data.parquet&quot;).filter($&quot;age&quot; &gt; 30)  </pre><p>Both improve performance, but they operate at different levels.</p><h3>4. Spark Doesn’t Always Push Down All Predicates</h3><p>Even with supported formats, Spark’s optimizer may not push down every possible filter. The query plan decides what’s optimal, and sometimes filters stay in memory.</p><p>Check the physical plan to confirm:</p><pre>df.filter($&quot;age&quot; &gt; 30).explain(&quot;extended&quot;)  </pre><p>Look for PushedFilters in the scan details. If it’s empty, the pushdown didn’t happen.</p><h3>What Enables Pushdown Internally?</h3><p>To truly understand predicate pushdown, it helps to know what mechanisms in Spark facilitate it:</p><ul><li><strong>Catalyst Optimizer:</strong> This is Spark’s query optimizer, responsible for converting a logical plan into an optimized physical plan. It identifies opportunities for predicate pushdown and rewrites the query plan accordingly.</li><li><strong>Tungsten Engine:</strong> Spark’s Tungsten engine applies code generation and memory optimizations, which work in conjunction with the optimized physical plan to execute queries efficiently, including filters that have been pushed down.</li><li><strong>Data Source V2 API:</strong> Modern Spark connectors implement the Data Source V2 API, which explicitly includes interfaces like SupportsPushDownFilters and SupportsPushDownAggregates. If your connector uses the older API, pushdown may silently fail or be less effective.</li></ul><h3>Real-World Example: Pushdown Saves Time</h3><p>Suppose you’re querying a 500 million-row Parquet dataset:</p><pre>val df = spark.read.parquet(&quot;events/&quot;).filter($&quot;event_type&quot; === &quot;purchase&quot;)</pre><ul><li><strong>Without pushdown:</strong> A full scan could take approximately 4 minutes.</li><li><strong>With pushdown confirmed in the plan:</strong> The query might complete in less than 30 seconds.</li></ul><p>Predicate pushdown is often the difference between interactive queries and frustrating timeouts, especially with large datasets.</p><h3>When Predicate Pushdown May Not Be Worth It</h3><p>While predicate pushdown is a powerful optimization, there are cases where avoiding it — or not focusing on it — is acceptable:</p><ul><li><strong>Small Datasets:</strong> If your dataset fits easily into memory (e.g., less than 100MB), the overhead saved by pushdown may be negligible. The time spent on optimization might outweigh the I/O savings.</li><li><strong>Heavy Post-Processing:</strong> If you’re performing expensive transformations (like complex joins or aggregations) that dominate the overall query time, predicate pushdown might not be the primary bottleneck.</li><li><strong>Caching:</strong> If you’ve already cached the dataset in memory (e.g., using df.cache()), pushing down filters to the source has no benefit for subsequent queries, as the data is already in RAM.</li><li><strong>Frequent Schema Evolution:</strong> Rigid filtering during ingestion or at the data source might conflict with downstream schema drift handling or late binding requirements, where the exact schema isn’t known until much later in the processing pipeline.</li></ul><h3>How to Ensure Predicate Pushdown Works</h3><ul><li>Use <strong>pushdown-compatible formats</strong> (Parquet, ORC, JDBC).</li><li>Avoid <strong>UDFs in filters</strong> when possible.</li><li>Check the <strong>execution plan (</strong><strong>explain())</strong> to verify pushdown.</li><li>Use <strong>partition pruning</strong> for partitioned datasets.</li></ul><h3>Final Thoughts</h3><p>Predicate pushdown is powerful, but it’s not magic. Understanding its limitations helps you write truly optimized Spark jobs. Next time you write a filter, ask yourself: Is Spark really pushing this down, or is it silently scanning everything?</p><p>Got any surprising predicate pushdown experiences? Share them in the comments! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bbfe61c3682" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Kafka Poison Pill: A Silent Killer in Your Data Streams]]></title>
            <link>https://medium.com/@skraghunandan11/the-kafka-poison-pill-a-silent-killer-in-your-data-streams-147a40db339f?source=rss-d9f99f7f79e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/147a40db339f</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[kafka-streams]]></category>
            <category><![CDATA[real-time-analytics]]></category>
            <category><![CDATA[data-engineer]]></category>
            <dc:creator><![CDATA[Raghunandana Krishna Murthy Sanur]]></dc:creator>
            <pubDate>Fri, 31 Jan 2025 18:42:24 GMT</pubDate>
            <atom:updated>2025-01-31T18:42:24.214Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of distributed systems and real-time data processing, Apache Kafka has emerged as a cornerstone technology. Its ability to handle massive streams of data with low latency has made it a favorite among engineers. However, like any powerful tool, Kafka comes with its own set of challenges. One such challenge is the <strong>“Poison Pill”</strong> — a concept that can wreak havoc on your data pipelines if not handled properly. In this article, we’ll explore what a Poison Pill is, why it’s dangerous, and how you can defend your Kafka ecosystem against it.</p><h3>What is a Poison Pill in Kafka?</h3><p>A Poison Pill is a message or event that, when consumed by a Kafka consumer, causes the consumer to fail or behave unexpectedly. This could be due to malformed data, an unsupported schema, or even a bug in the consumer application. The term “Poison Pill” originates from the idea that this message is toxic to the system — it poisons the consumer, leading to processing failures or even crashes.</p><p>In Kafka, Poison Pills are particularly dangerous because they can disrupt the entire consumer group. If one consumer fails to process a message, it may get stuck retrying the same message repeatedly, causing a backlog of unprocessed data. This can lead to cascading failures, where the entire pipeline grinds to a halt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ocza9RVAGh8WKITFHfILGQ.png" /></figure><h3>Why Are Poison Pills So Dangerous?</h3><p>The danger of Poison Pills lies in their ability to silently disrupt your data streams. Here’s why they’re so problematic:</p><ul><li><strong>Consumer Stalling</strong>: A single Poison Pill can cause a consumer to get stuck, preventing it from processing subsequent messages. This can lead to lag in your data pipeline and impact downstream systems.</li><li><strong>Data Loss</strong>: If a consumer crashes and fails to commit its offset, the Poison Pill may be reprocessed when the consumer restarts, creating a loop of failures.</li><li><strong>Cascading Failures</strong>: In a distributed system, the failure of one component can ripple through the entire system. A Poison Pill in Kafka can trigger such cascading failures, affecting multiple services.</li></ul><h3>3. How to Detect and Handle Poison Pills</h3><p>Detecting and handling Poison Pills requires a combination of proactive monitoring and robust error-handling strategies. Here are some best practices:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zffapuKMKBffKgYG0ylnjA.png" /></figure><h4>a. Schema Validation</h4><p>Use schema validation tools like <strong>Apache Avro</strong> or <strong>Confluent Schema Registry</strong> to ensure that all messages adhere to a predefined schema. This can help catch malformed messages before they reach your consumers.</p><h4>b. Dead Letter Queues (DLQs)</h4><p>Implement a Dead Letter Queue to isolate Poison Pills. When a consumer encounters a problematic message, it can route the message to a DLQ for further inspection instead of retrying it indefinitely.</p><h4>c. Circuit Breakers</h4><p>Use circuit breakers in your consumer applications to detect repeated failures and stop processing messages temporarily. This can prevent cascading failures and give you time to address the root cause.</p><h4>d. Monitoring and Alerts</h4><p>Set up monitoring and alerts to detect consumer lag, repeated failures, and other signs of Poison Pills. Tools like <strong>Prometheus</strong> and <strong>Grafana</strong> can help you visualize these metrics.</p><h3>Conclusion: Defending Against the Silent Killer</h3><p>The Kafka Poison Pill is a silent but potent threat to your data pipelines. By understanding its nature and implementing robust detection and handling mechanisms, you can protect your systems from its disruptive effects. Whether it’s through schema validation, Dead Letter Queues, or circuit breakers, the key is to stay vigilant and proactive. After all, in the world of real-time data, even a single Poison Pill can bring your entire system to its knees.</p><p>So, the next time you’re designing a Kafka-based system, ask yourself: <em>Have I prepared for the Poison Pill?</em> If not, it’s time to start building your defenses.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=147a40db339f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MurmurHash2: The Engine Behind Kafka’s Partitioning Magic]]></title>
            <link>https://medium.com/@skraghunandan11/murmurhash2-the-engine-behind-kafkas-partitioning-magic-a62794c3c4cf?source=rss-d9f99f7f79e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a62794c3c4cf</guid>
            <category><![CDATA[realtime-streaming]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[kafka-streams]]></category>
            <dc:creator><![CDATA[Raghunandana Krishna Murthy Sanur]]></dc:creator>
            <pubDate>Sat, 18 Jan 2025 19:25:51 GMT</pubDate>
            <atom:updated>2025-01-18T19:25:51.060Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is MurmurHash2?</h3><p>MurmurHash2 is a non-cryptographic hash function developed by Austin Appleby. It is designed to provide high performance and an even distribution of hash values. Unlike cryptographic hashes such as SHA or MD5, MurmurHash2 prioritizes speed and uniformity over security.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HFfJs4LjL2zEgcKtpRekLQ.png" /></figure><h3>Key Features of MurmurHash2</h3><ol><li><strong>Speed:</strong> Highly optimized for performance.</li><li><strong>Uniform Distribution:</strong> Ensures that hash values are evenly distributed, minimizing collisions.</li><li><strong>Deterministic:</strong> The same input always produces the same output, ensuring consistency.</li><li><strong>Cross-Platform Compatibility:</strong> Works seamlessly across different architectures.</li></ol><h3>MurmurHash2 in Kafka Partitioning</h3><p>Kafka uses partitions to distribute data across brokers, enabling parallel processing and fault tolerance. To determine which partition a message belongs to, Kafka applies the following steps:</p><ol><li><strong>Message Key Hashing:</strong> If a message has a key, Kafka hashes the key using the MurmurHash2 algorithm.</li><li><strong>Partition Selection:</strong> The hash value is used to calculate the partition index by taking the modulus of the total number of partitions.</li></ol><p>This process ensures that messages with the same key are consistently sent to the same partition, facilitating message ordering and efficient retrieval.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mALLc_ZQBbB-QnEZxPwYXw.png" /></figure><h3>Step-by-Step Breakdown</h3><ol><li><strong>Producer Sends Message:</strong> A producer sends a message with a key to the Kafka cluster.</li><li><strong>Hash Calculation:</strong> The broker hashes the message key using MurmurHash2.</li><li><strong>Partition Assignment:</strong> The broker assigns the message to a partition based on the calculated hash value.</li><li><strong>Message Storage:</strong> The message is stored in the determined partition, ensuring ordering and consistency.</li><li><strong>Acknowledgment:</strong> The broker acknowledges receipt of the message to the producer.</li></ol><h3>Conclusion</h3><p>MurmurHash2 plays a pivotal role in ensuring Kafka’s efficiency and scalability. By providing a fast and reliable mechanism for partitioning, it empowers Kafka to handle massive amounts of data with ease. Understanding the intricacies of MurmurHash2 not only deepens appreciation for Kafka’s architecture but also highlights the importance of choosing the right hashing algorithm in distributed systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a62794c3c4cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pull Requests and Peace Treaties: How to Stop Syntax Squabbles]]></title>
            <link>https://medium.com/@skraghunandan11/pull-requests-and-peace-treaties-how-to-stop-syntax-squabbles-af9a59ef9d46?source=rss-d9f99f7f79e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/af9a59ef9d46</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Raghunandana Krishna Murthy Sanur]]></dc:creator>
            <pubDate>Thu, 17 Oct 2024 16:49:13 GMT</pubDate>
            <atom:updated>2024-10-17T16:49:13.691Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tk7AIuaRDuD4waCM2yo1AA.jpeg" /></figure><p>Ah, the Pull Request (PR) review — the sacred ritual where developers gather to dissect code, offer wisdom, and occasionally wage war over whitespace. We’ve all witnessed a simple review spiral into an epic debate over the placement of a semicolon or the use of tabs versus spaces. So, how can we transform PR reviews from battlegrounds into collaborative, constructive experiences? Let’s dive into some strategies to make PR reviews easier and, dare we say, enjoyable.</p><h3>Focus on What Matters: Logic Over Line Breaks</h3><p>The primary goal of a PR review should be to enhance the code’s quality by focusing on:</p><ul><li><strong>Logic and Functionality</strong>: Does the code do what it’s supposed to do?</li><li><strong>Edge Cases</strong>: Have uncommon scenarios been accounted for?</li><li><strong>Bugs</strong>: Are there any lurking issues that could cause crashes or incorrect behavior?</li><li><strong>Performance</strong>: Is the code efficient and scalable?</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OYUlLyQS2V4ZF6hc1QcTUQ.png" /></figure><p>By zeroing in on these critical areas, reviewers can provide valuable feedback that genuinely improves the codebase, rather than nitpicking over trivialities.</p><h3>Let the Robots Handle the Syntax</h3><p>Why waste human brainpower on issues a machine can catch? Enter automated PR checks:</p><ul><li><strong>Linters</strong>: Tools like ESLint or Pylint can automatically check for syntax errors and enforce style guidelines.</li><li><strong>Formatters</strong>: Programs like Prettier or Black can reformat code to a consistent style with a single command.</li><li><strong>CI/CD Pipelines</strong>: Continuous Integration tools can run tests and checks every time code is pushed.</li></ul><p>Automating these checks reduces the chance for arguments over coding style and frees up reviewers to focus on more substantial issues.</p><h3>Establish Clear Coding Standards</h3><p>Having a well-documented style guide removes ambiguity:</p><ul><li><strong>Consistency</strong>: Everyone knows the rules, so there’s less room for subjective opinions.</li><li><strong>Reference Point</strong>: Disagreements can be settled by pointing to the agreed-upon guidelines.</li><li><strong>Onboarding</strong>: New team members can get up to speed quickly.</li></ul><p>Remember, a style guide is like the pirate’s code — more guidelines than actual rules — but it helps keep everyone sailing in the same direction.</p><h3>Encourage Constructive Communication</h3><p>The way feedback is delivered can make all the difference:</p><ul><li><strong>Be Respectful</strong>: Critique the code, not the coder.</li><li><strong>Be Specific</strong>: Provide clear examples or suggestions.</li><li><strong>Ask Questions</strong>: Sometimes, understanding the author’s perspective can clear up confusion.</li></ul><p>Creating a positive review culture encourages collaboration and continuous learning.</p><h3>Keep PRs Manageable</h3><p>Large PRs can be overwhelming:</p><ul><li><strong>Small Batches</strong>: Break changes into smaller, more digestible PRs.</li><li><strong>Single Purpose</strong>: Each PR should aim to achieve one goal or feature.</li><li><strong>Descriptive Summaries</strong>: Provide context to help reviewers understand the intent.</li></ul><p>Smaller PRs are easier to review thoroughly and reduce the cognitive load on reviewers.</p><h3>Conclusion: Peace, Love, and Code Reviews</h3><p>By focusing on logic, automating the mundane, and fostering respectful communication, PR reviews can become a productive and even enjoyable part of the development process. Let’s stop the battles over semicolons and start building better software together.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af9a59ef9d46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GPUs: The Unofficial Energy Drinks for Machine Learning Models]]></title>
            <link>https://medium.com/@skraghunandan11/gpus-the-unofficial-energy-drinks-for-machine-learning-models-79a544e2ee0d?source=rss-d9f99f7f79e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/79a544e2ee0d</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-engineer]]></category>
            <category><![CDATA[mlops]]></category>
            <dc:creator><![CDATA[Raghunandana Krishna Murthy Sanur]]></dc:creator>
            <pubDate>Mon, 07 Oct 2024 18:10:31 GMT</pubDate>
            <atom:updated>2024-10-07T18:10:31.182Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m4UhzmjiQMYPpO7EUjLCuA.jpeg" /></figure><h3><strong>Context and Confusion: Why Do Data Scientists Ask for GPUs?</strong></h3><p>Data scientists frequently request access to GPUs for their machine learning projects, leading to questions from management and IT departments:</p><ul><li><strong>Why can’t CPUs handle these tasks?</strong></li><li><strong>Are GPUs truly necessary, or are they just a nice-to-have?</strong></li><li><strong>What justifies the additional cost and resource allocation for GPUs?</strong></li></ul><p>The crux of the matter lies in the nature of machine learning workloads:</p><ul><li><strong>Complex Computations:</strong> Training machine learning models, especially deep learning models, involves heavy mathematical computations, primarily matrix and vector operations.</li><li><strong>Large Datasets:</strong> The datasets used are often vast, requiring significant processing power to handle efficiently.</li><li><strong>Time Sensitivity:</strong> Faster training times enable quicker iterations, leading to faster development cycles and time-to-market advantages.</li></ul><p>GPUs are designed to handle these specific challenges effectively, making them a critical component in modern machine learning workflows.</p><h3>CPU vs. GPU: A Comparison</h3><p><strong>Seven Key Differences Between CPUs and GPUs</strong></p><p>To understand why GPUs are preferred, let’s compare them across several crucial aspects:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZJM25AwvnXuEHrmWVRssBg.png" /></figure><h3>The Challenge of GPU Provisioning and Shortages</h3><p><strong>Why GPUs Are Hard to Provision in the Cloud and the Issue of Shortages</strong></p><p>Despite their advantages, GPUs present several challenges:</p><h3>High Demand and Limited Supply</h3><ul><li><strong>Surge in AI Applications:</strong> The explosion of AI and machine learning has led to unprecedented demand for GPUs.</li><li><strong>Manufacturing Constraints:</strong> GPU production involves complex manufacturing processes with long lead times.</li><li><strong>Resulting Shortages:</strong> These factors contribute to shortages, making GPUs a scarce commodity in both consumer and enterprise markets.</li></ul><h3>Cloud Provisioning Difficulties</h3><ul><li><strong>Limited Availability:</strong> Cloud service providers have a finite number of GPU instances, leading to competition among users.</li><li><strong>Higher Costs:</strong> GPU instances are significantly more expensive than their CPU counterparts, increasing operational expenses.</li><li><strong>Provisioning Delays:</strong> Allocating GPU resources can involve wait times, disrupting project timelines.</li></ul><h3>Impact on Organizations</h3><ul><li><strong>Resource Allocation:</strong> Organizations must carefully plan and prioritize GPU usage to avoid bottlenecks.</li><li><strong>Budget Considerations:</strong> The high cost of GPUs necessitates budgeting and cost-benefit analyses to justify investments.</li><li><strong>Strategic Decisions:</strong> Some organizations may need to explore alternative solutions, such as optimizing code for CPUs or using specialized hardware like TPUs (Tensor Processing Units).</li></ul><h3><strong>Final Thoughts</strong></h3><p>As machine learning continues to advance, the role of GPUs is likely to become even more prominent. Organizations that proactively address the challenges of GPU provisioning and explore innovative solutions will be better positioned to harness the full potential of machine learning technologies.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79a544e2ee0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is Your Spark Cluster Underperforming? Here’s How AQE (Adaptive Query Execution) Can Save the Day!]]></title>
            <link>https://medium.com/@skraghunandan11/is-your-spark-cluster-underperforming-heres-how-aqe-adaptive-query-execution-can-save-the-day-2106f837c4af?source=rss-d9f99f7f79e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/2106f837c4af</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[apache-spark]]></category>
            <dc:creator><![CDATA[Raghunandana Krishna Murthy Sanur]]></dc:creator>
            <pubDate>Mon, 30 Sep 2024 06:34:15 GMT</pubDate>
            <atom:updated>2024-09-30T06:34:15.880Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2YqxRw-FiNrJ2ZsN-5ZEjw.jpeg" /></figure><p>Are your Apache Spark jobs taking longer than expected? Do you notice uneven resource utilization across your cluster? If your Spark cluster is underperforming, Adaptive Query Execution (AQE) might be the hero you need. In this article, we’ll explore how AQE can supercharge your Spark jobs by dynamically optimizing query execution plans based on runtime statistics.</p><h3>The Underperformance Dilemma: Before AQE</h3><p>Imagine you’re analyzing customer data to gain insights into purchasing behaviors. You have two massive datasets:</p><ul><li><strong>Transactions</strong>: Records of all customer purchases (hundreds of millions of rows).</li><li><strong>Customers</strong>: Detailed customer profiles (tens of millions of rows).</li></ul><p><strong>The Task</strong>: Join these two datasets on the customer_id field to generate a comprehensive report.</p><h3>The Problem</h3><p>You kick off your Spark job and notice it’s taking forever. The cluster resources are unevenly utilized — some executors are maxed out while others sit idle. What’s going on?</p><ul><li><strong>Data Skew</strong>: Certain customer_ids have a disproportionately high number of transactions, causing data skew.</li><li><strong>Fixed Execution Plan</strong>: Spark’s default execution plan doesn’t account for this skew, leading to inefficient processing.</li><li><strong>Straggling Tasks</strong>: Tasks handling skewed data take much longer, delaying the entire job.</li></ul><h3>Impact on Performance</h3><ul><li><strong>Increased Execution Time</strong>: The job takes hours instead of minutes.</li><li><strong>Resource Underutilization</strong>: Some nodes are idle while others are overloaded.</li><li><strong>Frustration Levels Rising</strong>: Deadlines are missed, and trust in the system dwindles.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*iMmXrzhjPjC_p_kbk6uD0w.png" /></figure><h3>AQE to the Rescue: After Implementation</h3><p>Now, let’s introduce Adaptive Query Execution into the mix.</p><h3>What Changes with AQE?</h3><ul><li><strong>Dynamic Optimization</strong>: AQE adjusts the execution plan based on actual data characteristics at runtime.</li><li><strong>Skew Handling</strong>: Detects data skew and optimizes join operations accordingly.</li><li><strong>Efficient Resource Utilization</strong>: Balances the workload across the cluster.</li></ul><h3>The Transformation</h3><p>With AQE enabled, you rerun the same job.</p><ul><li><strong>Balanced Workload</strong>: Tasks are evenly distributed, and executors are uniformly utilized.</li><li><strong>Faster Execution</strong>: The job is completed in a fraction of the time.</li><li><strong>Optimized Joins</strong>: AQE applies strategies like <strong>salting</strong> and <strong>skew join optimization</strong> to handle uneven data distribution.</li></ul><h3>Putting It All Together</h3><p>Here’s how you might set these configurations in your Spark application:</p><pre>from pyspark.sql import SparkSession<br><br>spark = SparkSession.builder \<br>    .appName(&quot;AQE_Optimized_App&quot;) \<br>    .config(&quot;spark.sql.adaptive.enabled&quot;, &quot;true&quot;) \<br>    .config(&quot;spark.sql.adaptive.coalescePartitions.enabled&quot;, &quot;true&quot;) \<br>    .config(&quot;spark.sql.adaptive.skewJoin.enabled&quot;, &quot;true&quot;) \<br>    .getOrCreate()</pre><h3>Execution Flow with AQE Enabled</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*zlaSO8e2aQsQ4aimVbB5pg.png" /></figure><ul><li><strong>Start Execution</strong>: Spark begins executing the initial physical plan.</li><li><strong>Collect Statistics</strong>: Gathers runtime data after each stage.</li><li><strong>Optimize Plan</strong>: AQE applies optimizations based on collected stats.</li><li><strong>Re-execute</strong>: Runs the optimized plan in subsequent stages.</li><li><strong>Iterate</strong>: Repeats the process until the query completes.</li></ul><h3>Conclusion</h3><p>Adaptive Query Execution is a powerful feature that can significantly enhance the performance of your Spark jobs. By dynamically adjusting execution plans based on real-time statistics, AQE tackles common issues like data skew and inefficient resource utilization.</p><p><strong>Key Takeaways</strong>:</p><ul><li><strong>Enable AQE</strong>: It’s as simple as setting spark.sql.adaptive.enabled to true.</li><li><strong>Customize Features</strong>: Fine-tune AQE with specific configurations for your workload.</li><li><strong>Understand the Internals</strong>: Knowing how AQE works helps in troubleshooting and optimization.</li><li><strong>Monitor Performance</strong>: Use the Spark UI to observe the impact of AQE on your jobs.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2106f837c4af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigating Airflow Upgrades Smoothly: The Role of PythonVenvOperator in Ensuring Compatibility]]></title>
            <link>https://medium.com/@skraghunandan11/navigating-airflow-upgrades-smoothly-the-role-of-pythonvenvoperator-in-ensuring-compatibility-4384b32195ce?source=rss-d9f99f7f79e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/4384b32195ce</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[airflow]]></category>
            <dc:creator><![CDATA[Raghunandana Krishna Murthy Sanur]]></dc:creator>
            <pubDate>Wed, 03 Jan 2024 08:25:32 GMT</pubDate>
            <atom:updated>2024-01-03T08:25:32.527Z</atom:updated>
            <content:encoded><![CDATA[<p>Co-authored with <a href="https://www.linkedin.com/in/mohammedelfarw/overlay/about-this-profile/">Mohammed Hassan</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sKftBYFGdDm8C3aNon80EQ.png" /></figure><p>The dynamic landscape of data engineering often requires frequent updates and upgrades to tools and technologies. Apache Airflow, a cornerstone in this domain, is no exception. However, with each upgrade, there’s a looming challenge of maintaining compatibility and ensuring uninterrupted workflows. This is where the PythonVenvOperator in Airflow comes into play, offering a robust solution to this problem. Let’s explore this aspect, particularly focusing on how it aids in smooth transitions during Airflow version upgrades.</p><h4>The PythonVenvOperator Advantage</h4><p>Airflow’s PythonVenvOperator is a valuable tool for isolating Python environments for specific tasks. This isolation is not just about managing dependencies but also plays a crucial role in maintaining compatibility with different Airflow versions.</p><h4>Use Case: Seamless Airflow Upgrades in Data Pipelines</h4><p>Consider an organization relying heavily on Airflow for its data pipelines, facing an upgrade from an older version of Airflow to a newer one. One of the challenges in such upgrades is ensuring that existing Python tasks continue to run without issues, despite potential changes in Airflow’s internal architecture or dependencies.</p><p>Here’s where PythonVenvOperator shines. By creating isolated environments for each task, it ensures that these tasks are unaffected by the upgrade. Each task can have its dependencies, independent of the Airflow system’s overall Python environment.</p><h3>How PythonVenvOperator : A Dynamic Solution</h3><ol><li>Version Independence: Tasks run in environments with specific Python and library versions, making them independent of the Airflow version.</li><li>Dependency Management: It allows for precise control over the dependencies required for each task, avoiding conflicts that might arise from Airflow’s global dependencies.</li><li>Testing and Migration Ease: Before migrating to a new Airflow version, tasks can be tested in their isolated environments, ensuring compatibility and reducing the risk of unexpected issues post-upgrade.</li></ol><pre>from airflow import DAG<br>from airflow.operators.python_operator import PythonVirtualenvOperator<br>from datetime import datetime, timedelta</pre><pre>def data_processing_task():<br>    # Python code for data processing<br>    pass</pre><pre>dag = DAG(<br>    &#39;data_pipeline&#39;,<br>    default_args={<br>        &#39;owner&#39;: &#39;airflow&#39;,<br>        &#39;start_date&#39;: datetime(2023, 12, 21),<br>    },<br>    schedule_interval=timedelta(days=1),<br>)</pre><pre>processing_task = PythonVirtualenvOperator(<br>    task_id=&#39;process_data&#39;,<br>    python_callable=data_processing_task,<br>    requirements=[&quot;pandas==1.2.0&quot;, &quot;numpy==1.20.0&quot;],<br>    system_site_packages=False,<br>    dag=dag,<br>)</pre><pre>processing_task</pre><p>In this example, PythonVirtualenvOperator is used to ensure that the data_processing_task runs with specific versions of Pandas and NumPy, irrespective of the Airflow version or its global dependencies.</p><h3>ExternalPythonOperator: Minimizing Overhead</h3><h3>(New in version 2.4)</h3><p>The <strong>ExternalPythonOperator</strong> offers a less dynamic but more efficient solution, introduced in version 2.4. This operator requires a pre-existing, immutable Python environment with all necessary dependencies. Unlike <strong>PythonVirtualenvOperator</strong>, no new dependencies can be added dynamically.</p><h3>Benefits</h3><ol><li><strong>No Setup Overhead:</strong> The virtualenv is ready when the task starts, minimizing runtime overhead.</li><li><strong>Resource Reuse:</strong> Tasks with different dependencies can run on the same workers, optimizing resource utilization.</li><li><strong>No PyPI Access Required:</strong> Workers don’t need access to PyPI or private repositories, reducing chances of transient errors.</li></ol><pre>from airflow import DAG<br>from airflow.decorators import task</pre><pre>with DAG(<br>    dag_id=&#39;external-python-pipeline&#39;,<br>    start_date=datetime(2024, 1, 1),<br>    schedule=None,<br>):</pre><pre>    @task<br>    def start_task():<br>        print (&quot;start data pipeline&quot;)</pre><pre>    @task.external_python(<br>        python=&#39;/home/airflow/.pyenv/versions/my_env/bin/python&#39;<br>    )</pre><pre>    def data_processing():</pre><pre>        # packages used within the virtual environment have to be imported here<br>        import os<br>        import pkg<br>				<br>				# Python code for data processing</pre><pre>    @task<br>    def end_task():<br>        print(&quot;end data pipeline&quot;)</pre><pre>    start_task &gt;&gt; data_processing &gt;&gt; end_task</pre><p>Deployment Considerations</p><p>The pre-existing virtual environment should be prepared and deployed alongside Airflow installation, involving collaboration with DataOps team.</p><h3>Using DockerOperator or Kubernetes Pod Operator: Extending Dependency Management</h3><p>Another powerful strategy for managing dependencies in Apache Airflow involves utilizing the <strong>DockerOperator</strong> from the <strong>airflow.providers.docker.operators.docker</strong> module or the <strong>KubernetesPodOperator</strong> from <strong>airflow.providers.cncf.kubernetes.operators.pod</strong>. These operators enable task execution within Docker containers or Kubernetes Pods, providing a robust solution for isolation and dependency control.</p><h3>Taskflow Decorators Integration</h3><p>Similar to Python operators, taskflow decorators seamlessly integrate with these containerization operators. The decorators, such as <strong>@task.docker</strong> (introduced in version 2.2) and <strong>@task.kubernetes</strong> (introduced in version 2.4), simplify the execution of callable Python code within containers.</p><h3>Benefits</h3><ol><li><strong>Diverse Dependency Sets:</strong> Run tasks with varying Python and system-level dependencies, or even tasks in different programming languages or processor architectures (x86 vs. arm).</li><li><strong>Optimized Environments:</strong> Container immutability allows for optimized environments where similar sets of dependencies can efficiently reuse cached layers of the image.</li><li><strong>Pre-vetted Dependencies:</strong> Admins and security teams can pre-vet dependencies, ensuring stability and security with no dynamically added code.</li><li><strong>Complete Task Isolation:</strong> Tasks are entirely isolated, unable to influence each other except through standard Airflow XCom mechanisms.</li></ol><h3>Drawbacks</h3><ol><li><strong>Task Startup Overhead:</strong> While typically smaller than dynamically creating virtual environments, there is still significant overhead, especially for the <strong>KubernetesPodOperator</strong>.</li><li><strong>Serialization Limitations:</strong> Serializing and sending the entire method to the Docker Container or Kubernetes Pod introduces overhead and has system-level limitations on method size.</li><li><strong>Resource Overhead:</strong> Running tasks with these operators requires at least two processes, contributing to resource overhead. This includes the process in the container executing the task and a supervising process in the Airflow worker managing job submission and monitoring.</li><li><strong>Image Management:</strong> Container images need to be prepared upfront, limiting dynamic changes. Adding system dependencies or modifying Python requirements requires rebuilding and republishing the image.</li><li><strong>Understanding Container Details:</strong> Working with Docker or Kubernetes requires a deeper understanding of resources, networking, and container details, as the abstraction provided by these operators is somewhat “leaky.”</li></ol><h3>Taskflow Docker Example</h3><pre>from airflow import DAG<br>from airflow.decorators import dag, task<br>from airflow.operators.providers.docker import DockerOperator<br>from datetime import datetime, timedelta</pre><pre># Define DAG<br>@dag(schedule_interval=timedelta(days=1), start_date=datetime(2024, 1, 1), catchup=False)<br>def taskflow_docker_example():</pre><pre>    # Define a simple Python function to run in the Docker container<br>    @task.docker(image=&#39;my_custom_image&#39;, network_mode=&#39;bridge&#39;)<br>    def run_python_code():<br>        print(&quot;Executing Python code in Docker container.&quot;)<br>        # Your Python code here</pre><pre>    # Task execution<br>    docker_task = run_python_code()</pre><pre># Instantiate the DAG<br>dag_instance = taskflow_docker_example()</pre><p>This example uses the <strong>@task.docker</strong> decorator to specify that the <strong>run_python_code</strong> function should be executed within a Docker container. The <strong>image</strong> parameter indicates the Docker image to use, and additional parameters like <strong>network_mode</strong> allow fine-grained control over container settings.</p><h3>Taskflow Kubernetes Example</h3><pre>from airflow import DAG<br>from airflow.decorators import dag, task<br>from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator<br>from datetime import datetime, timedelta</pre><pre># Define DAG<br>@dag(schedule_interval=timedelta(days=1), start_date=datetime(2024, 1, 1), catchup=False)<br>def taskflow_kubernetes_example():</pre><pre>    # Define a simple Python function to run in the Kubernetes Pod<br>    @task.kubernetes(<br>        image=&#39;my_custom_image&#39;,<br>        namespace=&#39;my_namespace&#39;,<br>        affinity=&#39;my_affinity_rule&#39;,<br>    )<br>    def run_python_code():<br>        print(&quot;Executing Python code in Kubernetes Pod.&quot;)<br>        # Your Python code here</pre><pre>    # Task execution<br>    kubernetes_task = run_python_code()</pre><pre># Instantiate the DAG<br>dag_instance = taskflow_kubernetes_example()</pre><p>In this example, the <strong>@task.kubernetes</strong> decorator is used to specify that the <strong>run_python_code</strong> function should run within a Kubernetes Pod. Parameters like <strong>image</strong>, <strong>namespace</strong>, and <strong>affinity</strong> provide control over the Kubernetes Pod&#39;s settings.</p><h3>Future Work from Airflow Community : Exploring AIP-43 and AIP-46 for Dependency Management</h3><p>As the Apache Airflow ecosystem continues to evolve, exciting prospects emerge in the form of Apache Airflow Improvement Proposals. Two proposals, AIP-43 and AIP-46, hold promise for addressing dependency conflicts at a broader level, offering more comprehensive solutions.</p><h3><a href="https://cwiki.apache.org/confluence/display/AIRFLOW/AIP-43+DAG+Processor+separation">AIP-43: DAG Processor Separation</a></h3><p>AIP-43 introduces the concept of DAG Processor separation, aiming to enhance dependency management by allowing different DAG processors to run in distinct virtual environments. This approach provides a more nuanced and flexible way of isolating dependencies between different workflows, reducing the risk of conflicts across DAGs.</p><h3><a href="https://cwiki.apache.org/confluence/display/AIRFLOW/AIP-46+Runtime+isolation+for+airflow+tasks+and+dag+parsing">AIP-46: Runtime Isolation with Containers</a></h3><p>AIP-46 takes a bold step towards runtime isolation by incorporating containerization for Airflow tasks and DAG parsing. This proposal envisions leveraging container technologies to encapsulate each task’s dependencies, providing an isolated runtime environment. By doing so, AIP-46 aims to deliver a robust and comprehensive solution to dependency conflicts.</p><h3>Conclusion</h3><p>Using PythonVenvOperator in Airflow is more than just a best practice for dependency management; it’s a strategic approach to ensure smooth, hassle-free upgrades to newer Airflow versions. By isolating tasks in dedicated environments, data engineers can safeguard their workflows against compatibility issues, making the upgrade process more predictable and controlled.</p><p>Choosing between <strong>PythonVirtualenvOperator</strong> and <strong>ExternalPythonOperator</strong> depends on your specific use case and deployment constraints. Both offer solutions to mitigate dependency conflicts, providing flexibility and efficiency in managing Airflow tasks with distinct requirements. As you delve deeper into Airflow DAG development, these strategies will prove invaluable in maintaining a stable and scalable workflow orchestration environment.</p><p>Co-authored with <a href="https://www.linkedin.com/in/mohammedelfarw/overlay/about-this-profile/">Mohammed Hassan</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4384b32195ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Spark Memory Management: On-Heap vs Off-Heap in the Context of Tungsten Optimizer]]></title>
            <link>https://medium.com/@skraghunandan11/apache-spark-memory-management-on-heap-vs-off-heap-in-the-context-of-tungsten-optimizer-df6f641a2d93?source=rss-d9f99f7f79e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/df6f641a2d93</guid>
            <category><![CDATA[data-engineer]]></category>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Raghunandana Krishna Murthy Sanur]]></dc:creator>
            <pubDate>Wed, 29 Nov 2023 04:27:32 GMT</pubDate>
            <atom:updated>2023-11-29T04:27:32.874Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s_nb9ef_un-SV5iUxEwbRw.png" /></figure><p>Apache Spark, an advanced open-source distributed computing system, has revolutionized big data processing with its efficient memory management techniques. These techniques, particularly the on-heap and off-heap memory management, are central to its performance. Moreover, Spark’s Tungsten Optimizer further enhances these memory management strategies to optimize data processing.</p><h3>On-Heap vs Off-Heap Memory Management: A Comparative Overview</h3><p>The following table provides a clear comparison between on-heap and off-heap memory management in Apache Spark:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*d9f02ZhiYoaJZGh1Priijg.png" /></figure><h3>Tungsten Optimizer: Enhancing Spark’s Memory Management</h3><p>The Tungsten optimizer represents a significant advancement in Spark’s ability to efficiently process data. It optimizes both CPU and memory usage in Spark applications, leveraging on-heap and off-heap memory management techniques. Tungsten employs advanced strategies like binary in-memory data representation and explicit memory management.</p><h4>Key Benefits</h4><ul><li>Improved Execution Speed: Tungsten’s memory management strategies enable faster operation execution.</li><li>Efficient Resource Utilization: By balancing the use of on-heap and off-heap memory, Tungsten optimizes resource utilization.</li><li>Reduced Overhead: Minimizes the overhead of garbage collection, enhancing the overall performance of Spark applications.</li></ul><h4>Certainly, I’ll include information about relevant Spark configurations that need adjustment in off-heap mode in the “Integration with Spark Memory Management” section of the article:</h4><h3>Integration with Spark Memory Management</h3><p>When integrating Tungsten with Spark’s memory management, particularly in off-heap mode, certain Spark configurations need to be adjusted for optimal performance:</p><ul><li>spark.memory.offHeap.enabled: This configuration must be set to true to enable the use of off-heap memory.</li><li>spark.memory.offHeap.size: It specifies the amount of off-heap memory to be allocated (in bytes). This setting is crucial as it determines the memory capacity available for off-heap storage.</li><li>spark.executor.memory: While this parameter primarily configures on-heap memory, it&#39;s important to balance it with off-heap settings to ensure overall memory allocation is sufficient for the workload.</li><li>spark.executor.memoryOverhead: This setting is used to account for additional memory overhead apart from the memory used by the executor process. In off-heap mode, this might need to be increased to accommodate the extra memory usage.</li></ul><p>These configurations allow Spark to dynamically adjust memory usage based on the workload, leveraging the benefits of Tungsten’s optimization in both on-heap and off-heap memory management. Proper tuning of these parameters is key to maximizing data processing efficiency in Spark applications.</p><h3>Conclusion</h3><p>Apache Spark’s on-heap and off-heap memory management, integral to its performance in big data processing, are significantly enhanced by the Tungsten optimizer. This synergy ensures optimal resource utilization, enabling Spark to handle large-scale and complex data processing tasks effectively. As the demands for data processing continue to escalate, innovations in Spark’s memory management and optimization remain crucial in the realm of big data analytics.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df6f641a2d93" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Canary to Code: The Evolution of Alert Systems in DevOps]]></title>
            <link>https://medium.com/@skraghunandan11/from-canary-to-code-the-evolution-of-alert-systems-in-devops-6de051553686?source=rss-d9f99f7f79e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/6de051553686</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[site-reliability-engineer]]></category>
            <dc:creator><![CDATA[Raghunandana Krishna Murthy Sanur]]></dc:creator>
            <pubDate>Mon, 30 Oct 2023 08:23:31 GMT</pubDate>
            <atom:updated>2023-11-24T12:36:40.743Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IqQAlhqTpIVtT4j_sGlVDg.png" /></figure><p>Checkout my DevOps interview preparation course <a href="https://www.udemy.com/course/50-devops-interview-questions-answers/?referralCode=CD7F148E1AABC37E45A0">here</a></p><p>In the early 20th century, miners carried canaries into coal mines as a primitive alert system. The delicate respiratory systems of these birds made them susceptible to toxic gases such as <strong>carbon monoxide</strong>. A distressed or dead canary served as a warning, signaling miners to evacuate the premises, thus saving countless lives. This practice symbolizes the early inception of alert systems, which have evolved dramatically with the advent of technology.</p><p>Fast forward to the modern day, and we find ourselves amidst a digital mining field — the realm of Development and Operations (DevOps). In DevOps, we delve deep into the code, excavate through layers of algorithms, and constantly strive for the treasure of seamless operation. Yet, like the miners of yore, we too face unseen threats, bugs, and system failures that lurk in the depths, waiting to wreak havoc. How do we safeguard our operations against these unseen foes? The answer lies in the modern-day equivalent of the canary in the coal mine: vigilant alert systems within DevOps practices.</p><p>The ethos of DevOps emphasizes a culture of communication, collaboration, and quick response to changes. A crucial aspect of this is having an efficient alert system in place to notify teams about potential issues before they escalate into major problems. Much like the canary’s role in a coal mine, an effective alert system in a DevOps environment serves as an early warning mechanism, ensuring the health and reliability of the system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GayPY3sY9fiMkTMtI79eTg.png" /></figure><p>Sophisticated alerting tools and monitoring systems like Prometheus, Grafana, and Splunk have become the modern-day canaries for DevOps professionals. They monitor system performance, track anomalies, and send out alerts when predefined conditions are met or when unexpected behaviors arise. This proactive approach allows teams to address issues in real-time, promoting a culture of continuous improvement and resilience.</p><p>By automating monitoring and alerting processes, organizations are better positioned to maintain system stability and ensure uninterrupted service delivery. Moreover, these modern tools provide a wealth of data that can be analyzed to glean insights, aiding in the continuous refinement of operations and processes.</p><p>Just as the canary in the coal mine revolutionized safety measures in mining operations, modern alert systems are pivotal in advancing the safety and efficiency of DevOps practices. They embody the principle of learning and adapting to environmental conditions for better outcomes. As we continue to navigate through the digital mines of today, our modern-day canaries, alert systems, are indispensable companions, ensuring that we mine code safely and effectively.</p><p>In essence, the journey from canary to code encapsulates the evolution of alert systems, marking a transition from the tangible threats in coal mines to the digital challenges in DevOps environments. The legacy of the canary lives on, as we forge ahead in our quest for operational excellence in the realm of DevOps, ensuring a safer and more efficient digital mining experience.</p><p>Checkout my DevOps interview preparation course <a href="https://www.udemy.com/course/50-devops-interview-questions-answers/?referralCode=CD7F148E1AABC37E45A0">here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6de051553686" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why should data scientists try CML?]]></title>
            <link>https://medium.com/@skraghunandan11/why-should-data-scientists-try-cml-5e796c79393e?source=rss-d9f99f7f79e7------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e796c79393e</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Raghunandana Krishna Murthy Sanur]]></dc:creator>
            <pubDate>Mon, 10 Apr 2023 05:51:16 GMT</pubDate>
            <atom:updated>2023-04-10T05:51:16.478Z</atom:updated>
            <content:encoded><![CDATA[<p>Co-authored with <a href="https://www.linkedin.com/in/akul-kailwoo/">AKUL KAILWOO</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NLuKMppbCLmey1S2" /><figcaption>Photo by <a href="https://unsplash.com/de/@derekthomson?utm_source=medium&amp;utm_medium=referral">Derek Thomson</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A typical machine learning engineering life cycle involves the following phases :</p><ol><li>Data preparation</li><li>Model training</li><li>Model evaluation</li><li>Deployment</li><li>Serving</li></ol><p>The first three phases are collectively referred to as “Model development,” which is a highly iterative process that involves the ML practitioner experimenting with various techniques for feature engineering, algorithm selection, hyperparameter tuning, and so on. This stage typically consumes the majority of an ML engineer’s time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SLtS5yyMDCE85zjp" /></figure><p><em>ML Engineering process</em></p><p>Let’s list a few basic required processes to achieve the most ideal development lifecycle during ML model development.</p><ul><li>Codebase (Github/GitLab/BitBucket) to store the ML code.</li><li>Access to compute/memory infrastructure to train ML models during the development stage. (We won’t consider laptops as an infrastructure here 😜 )</li><li>Capture the ML development workflow</li><li>Hyperparameter changes</li><li>Model iteration performance</li><li>Record code changes</li></ul><p><strong>Few challenges</strong></p><ul><li>In most cases, We have the infrastructure-related code in Terraform in a different repo and the ML code in a different repo.</li><li>Even if we manage to spin a GPU instance, the question of cost will come into the picture: <em>“Why have a long-running instance run the test only 2 times a day?”</em></li><li><em>“You own what you run” </em>will end up with ML engineers spending at least 30–40% on acquiring and maintaining resources for running the model.</li></ul><p>After conquering all the above, Having a code repo, CI/CD and the test seem like cosmetic changes but it’s not. Not having any of the software engineer’s best practices is the 1st step toward technical debt.</p><p><strong>How can CML ( Continuous Machine Learning ) solve this problem?</strong></p><p><a href="https://github.com/iterative/cml">CML is an open-source</a> contribution project that focuses on automating development workflows. It’s part of <a href="https://iterative.ai/">iterative.ai</a>.</p><p>It&#39;s a command line utility that lets you create machine learning workflows and integrate with GitHub easily.</p><p>Example: using CML we can spin up a required GPU instance by a simple command</p><pre>cml runner \<br> - cloud=aws \ (can be GCP, Azure)<br> - cloud-region=us-west \<br> - cloud-type=g4dn.xlarge \<br> - labels=cml-gpu</pre><p># Code credit:<a href="https://github.com/iterative/cml"> https://github.com/iterative/cml</a></p><p>This spins up a necessary infrastructure in AWS (GCP, Azure), We don’t need to know Terraform nor this code needs to reside in a different repo.</p><p>Now let’s ingrate this into a data science model <strong>development lifecycle</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G2h2o0-XO0FJLUB4" /></figure><p>ML development using CML</p><p>Assuming we have our code in a GitHub repo, let’s enable GitHub actions and add the below workflow as an example</p><pre>name: Train-in-the-cloud<br>on: [push]<br>jobs:<br>deploy-runner:<br>runs-on: ubuntu-latest<br>steps:<br>- uses: iterative/setup-cml@v1<br>- uses: actions/checkout@v2<br>- name: Deploy runner on EC2<br>env:<br>REPO_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}<br>AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}<br>AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}<br>run: |<br>cml runner \<br> - cloud=aws \<br> - cloud-region=us-west \<br> - cloud-type=g4dn.xlarge \<br> - labels=cml-gpu<br>train-model:<br>needs: deploy-runner<br>runs-on: [self-hosted, cml-gpu]<br>timeout-minutes: 4320 # 72h<br>container:<br>image: docker://iterativeai/cml:0-dvc2-base1-gpu<br>options: - gpus all<br>steps:<br>- uses: actions/checkout@v2<br>- name: Train model<br>env:<br>REPO_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}<br>run: |<br>pip install -r requirements.txt<br>python train.py<br>cat metrics.txt &gt; report.md<br>cml send-comment report.md</pre><p># Code credit:<a href="https://github.com/iterative/cml"> https://github.com/iterative/cml</a></p><p><strong>What does Stage “deploy-runner” do?</strong></p><p>This stage runs the CML command to create an infrastructure in a given cloud (AWS in this case) and steps our ML playground.</p><p><strong>What does Stage Stage “train-model” do?</strong></p><p>This stage will check out our GitHub repo, install the requirements and then train the model.</p><p><strong>Addon:</strong> Automated report creation via metrics captured during model run time.</p><p>Implementing the <strong>CML runner with GitHub actions</strong> gives us most of the desired results we were looking for</p><ol><li>Tracking of model code change + hyperparameter code changes during training.</li><li>Spin up training infra as part of CI/CD <em>decoupling infra dependences</em>.</li><li>Metrics tracking and code reviews logics are add ons</li><li>Implementing CML in most cases can be a 1–2 sprint task for your MLops engineer, Resulting in a proper ML workflow development model.</li></ol><p>So tell me in the comment box, Would you try CML for your ML projects?</p><p>Co-authored with <a href="https://www.linkedin.com/in/akul-kailwoo/">AKUL KAILWOO</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e796c79393e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>