<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>largecats' blog</title>
    <description>Technical blog.</description>
    <link>https://largecats.github.io//blog/</link>
    <atom:link href="https://largecats.github.io//blog/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Thu, 01 Sep 2022 02:39:04 +0000</pubDate>
    <lastBuildDate>Thu, 01 Sep 2022 02:39:04 +0000</lastBuildDate>
    <generator>Jekyll v3.9.2</generator>
    
      <item>
        <title>Stream Processing 101</title>
        <description>This post is based on a sharing I did on general concepts in stream processing.</description>
        <pubDate>Thu, 10 Jun 2021 00:00:00 +0000</pubDate>
        <link>https://largecats.github.io//blog/2021/06/10/stream-processing-101/</link>
        <guid isPermaLink="true">https://largecats.github.io//blog/2021/06/10/stream-processing-101/</guid>
        
        <category>flink</category>
        
        
        <category>work</category>
        
      </item>
    
      <item>
        <title>Spark Data Pipeline Framework Management</title>
        <description>&lt;head&gt;
    &lt;script src=&quot;https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/x-mathjax-config&quot;&gt;
        MathJax.Hub.Config({
            tex2jax: {
            skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
            inlineMath: [['$','$']]
            }
        });
    &lt;/script&gt;
&lt;/head&gt;

Data pipelines are widely used to support business needs. As the business expands, both the volumn and diversity of its data increase. This calls for a system of data pipelines, each channelling data for a specific area of the business that may interact in various ways with other business areas. How to manage this system of data pipelines? If they share a common structure, is it worth it to maintain this structure in a separate framework package? How to manage the framework package together with the data pipelines that use it?

</description>
        <pubDate>Tue, 30 Mar 2021 00:00:00 +0000</pubDate>
        <link>https://largecats.github.io//blog/2021/03/30/spark-data-pipeline-framework-package-management/</link>
        <guid isPermaLink="true">https://largecats.github.io//blog/2021/03/30/spark-data-pipeline-framework-package-management/</guid>
        
        <category>spark</category>
        
        <category>python</category>
        
        <category>scala</category>
        
        
        <category>work</category>
        
      </item>
    
      <item>
        <title>sbt Multi-Project Dependency</title>
        <description>&lt;head&gt;
    &lt;script src=&quot;https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/x-mathjax-config&quot;&gt;
        MathJax.Hub.Config({
            tex2jax: {
            skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
            inlineMath: [['$','$']]
            }
        });
    &lt;/script&gt;
&lt;/head&gt;

If a project depends on an external project, how to manage the dependency in sbt?

</description>
        <pubDate>Tue, 30 Mar 2021 00:00:00 +0000</pubDate>
        <link>https://largecats.github.io//blog/2021/03/30/sbt-multiproject-dependency/</link>
        <guid isPermaLink="true">https://largecats.github.io//blog/2021/03/30/sbt-multiproject-dependency/</guid>
        
        <category>spark</category>
        
        <category>sbt</category>
        
        <category>scala</category>
        
        
        <category>work</category>
        
      </item>
    
      <item>
        <title>Spark Magnet: Push-based Shuffle</title>
        <description>&lt;head&gt;
    &lt;script src=&quot;https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/x-mathjax-config&quot;&gt;
        MathJax.Hub.Config({
            tex2jax: {
            skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
            inlineMath: [['$','$']]
            }
        });
    &lt;/script&gt;
&lt;/head&gt;

Recently, our data infrastructure team deployed a new version of Spark, called Spark Magnet. It is said to offer 30% to 50% improvement in performance, compared to the original Spark 3.0.

Spark Magnet is a patch to Spark 3 that improves shuffle efficiency:

&lt;div style=&quot;text-align: center&quot;&gt;&lt;img src=&quot;/blog/images/spark_magnet_jira_ticket.png&quot; width=&quot;800px&quot; /&gt;&lt;/div&gt;
&lt;div align=&quot;center&quot;&gt;
&lt;sup&gt;Spark Magnet's JIRA ticket.&lt;/sup&gt;
&lt;/div&gt;

Provided by LinkedIn’s data infrastructure team, it makes use of the Magnet shuffle service, which is a novel shuffle mechanism built on top of Spark’s native shuffle service. It improves shuffle efficiency by addressing several major bottlenecks with reasonable trade-offs.

</description>
        <pubDate>Sun, 07 Mar 2021 00:00:00 +0000</pubDate>
        <link>https://largecats.github.io//blog/2021/03/07/spark-magnet-push-based-shuffle/</link>
        <guid isPermaLink="true">https://largecats.github.io//blog/2021/03/07/spark-magnet-push-based-shuffle/</guid>
        
        <category>spark</category>
        
        
        <category>work</category>
        
      </item>
    
      <item>
        <title>Spark Partitions</title>
        <description>&lt;head&gt;
    &lt;script src=&quot;https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/x-mathjax-config&quot;&gt;
        MathJax.Hub.Config({
            tex2jax: {
            skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
            inlineMath: [['$','$']]
            }
        });
    &lt;/script&gt;
&lt;/head&gt;

Spark partitions are important for parallelism.

</description>
        <pubDate>Sat, 02 Jan 2021 00:00:00 +0000</pubDate>
        <link>https://largecats.github.io//blog/2021/01/02/spark-partitions/</link>
        <guid isPermaLink="true">https://largecats.github.io//blog/2021/01/02/spark-partitions/</guid>
        
        <category>spark</category>
        
        
        <category>work</category>
        
      </item>
    
      <item>
        <title>Variances in Type Systems</title>
        <description>&lt;head&gt;
    &lt;script src=&quot;https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/x-mathjax-config&quot;&gt;
        MathJax.Hub.Config({
            tex2jax: {
            skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
            inlineMath: [['$','$']]
            }
        });
    &lt;/script&gt;
&lt;/head&gt;

The concept of variance is used to describe relations among subtyping. Subtyping is a relation defined between two types &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;S&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;T&lt;/code&gt;, such that if &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;S&lt;/code&gt; is a subtype of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;T&lt;/code&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;S &amp;lt;: T&lt;/code&gt;), then a thing of type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;S&lt;/code&gt; can be used in any context where a thing of type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;T&lt;/code&gt; is expected. E.g., if &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Cat&lt;/code&gt; is a subtype of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Animal&lt;/code&gt;, a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Cat&lt;/code&gt; can replace an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Animal&lt;/code&gt;.

But how should the following be related?

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Collection[Cat]&lt;/code&gt; vs &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Collection[Animal]&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;get_cat: () -&amp;gt; Cat&lt;/code&gt; vs &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;get_animal: () -&amp;gt; Animal&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;print_cat: Cat -&amp;gt; ()&lt;/code&gt; vs &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;print_animal: Animal -&amp;gt; ()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

This is where variance comes in. Variance refers to how subtyping of a more complex type relates to subtyping of its component type.

</description>
        <pubDate>Tue, 01 Dec 2020 00:00:00 +0000</pubDate>
        <link>https://largecats.github.io//blog/2020/12/01/variances-in-type-systems/</link>
        <guid isPermaLink="true">https://largecats.github.io//blog/2020/12/01/variances-in-type-systems/</guid>
        
        <category>scala</category>
        
        
        <category>work</category>
        
      </item>
    
      <item>
        <title>Caching in Spark</title>
        <description>&lt;head&gt;
    &lt;script src=&quot;https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/x-mathjax-config&quot;&gt;
        MathJax.Hub.Config({
            tex2jax: {
            skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
            inlineMath: [['$','$']]
            }
        });
    &lt;/script&gt;
&lt;/head&gt;

Spark’s caching mechanism can be leveraged to optimize performance. Here are some facts and caveats about caching.

</description>
        <pubDate>Sat, 17 Oct 2020 00:00:00 +0000</pubDate>
        <link>https://largecats.github.io//blog/2020/10/17/spark-cache/</link>
        <guid isPermaLink="true">https://largecats.github.io//blog/2020/10/17/spark-cache/</guid>
        
        <category>spark</category>
        
        <category>YARN</category>
        
        
        <category>work</category>
        
      </item>
    
      <item>
        <title>Solving Spark timeout errors</title>
        <description>&lt;head&gt;
    &lt;script src=&quot;https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/x-mathjax-config&quot;&gt;
        MathJax.Hub.Config({
            tex2jax: {
            skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
            inlineMath: [['$','$']]
            }
        });
    &lt;/script&gt;
&lt;/head&gt;

Timeout errors may occur while the Spark application is running or even after the Spark application has finished. Below are some common timeout errors and their solutions.

</description>
        <pubDate>Fri, 09 Oct 2020 00:00:00 +0000</pubDate>
        <link>https://largecats.github.io//blog/2020/10/09/spark-timeout-errors/</link>
        <guid isPermaLink="true">https://largecats.github.io//blog/2020/10/09/spark-timeout-errors/</guid>
        
        <category>spark</category>
        
        
        <category>work</category>
        
      </item>
    
      <item>
        <title>Collecting Log in Spark Cluster Mode</title>
        <description>&lt;head&gt;
    &lt;script src=&quot;https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/x-mathjax-config&quot;&gt;
        MathJax.Hub.Config({
            tex2jax: {
            skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
            inlineMath: [['$','$']]
            }
        });
    &lt;/script&gt;
&lt;/head&gt;

Spark has 2 deploy modes, client mode and cluster mode. Cluster mode is ideal for batch ETL jobs submitted via the same “driver server” because the driver programs are run on the cluster instead of the driver server, thereby preventing the driver server from becoming the resource bottleneck. But in cluster mode, the driver server is only responsible for running a client process that submits the application, after which the driver program would be run on a different machine in the cluster. This poses the following challenges:

&lt;ol&gt;
  &lt;li&gt;We can’t access the driver program’s log from the driver server (only the client process’ log is available to the driver server).&lt;/li&gt;
  &lt;li&gt;We can’t terminate the spark application via Ctrl-C or by marking success/killing tasks in the Airflow scheduler (doing so will only kill the client process running on the driver server, not the spark application itself).&lt;/li&gt;
&lt;/ol&gt;

&lt;div style=&quot;text-align: center&quot;&gt;&lt;img src=&quot;/blog/images/cluster_mode-Page-1.png&quot; width=&quot;800px&quot; /&gt;&lt;/div&gt;
&lt;div align=&quot;center&quot;&gt;
&lt;/div&gt;

We want to make use of cluster mode’s advantage and find workarounds to:

&lt;ol&gt;
  &lt;li&gt;Access and store logs for recent as well as historical jobs conveniently;&lt;/li&gt;
  &lt;li&gt;View log conveniently in real time;&lt;/li&gt;
  &lt;li&gt;Kill applications via keyboard or Airflow.&lt;/li&gt;
&lt;/ol&gt;

</description>
        <pubDate>Mon, 21 Sep 2020 00:00:00 +0000</pubDate>
        <link>https://largecats.github.io//blog/2020/09/21/spark-cluster-mode-collect-log/</link>
        <guid isPermaLink="true">https://largecats.github.io//blog/2020/09/21/spark-cluster-mode-collect-log/</guid>
        
        <category>spark</category>
        
        <category>YARN</category>
        
        <category>shell-scripting</category>
        
        
        <category>work</category>
        
      </item>
    
      <item>
        <title>Caching and Unpersisting Pyspark RDD</title>
        <description>&lt;head&gt;
    &lt;script src=&quot;https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/x-mathjax-config&quot;&gt;
        MathJax.Hub.Config({
            tex2jax: {
            skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
            inlineMath: [['$','$']]
            }
        });
    &lt;/script&gt;
&lt;/head&gt;

A cached RDD can only be unpersisted through a variable referencing it.

</description>
        <pubDate>Fri, 06 Dec 2019 00:00:00 +0000</pubDate>
        <link>https://largecats.github.io//blog/2019/12/06/pyspark-rdd-cache-unpersist/</link>
        <guid isPermaLink="true">https://largecats.github.io//blog/2019/12/06/pyspark-rdd-cache-unpersist/</guid>
        
        <category>pyspark</category>
        
        
        <category>work</category>
        
      </item>
    
  </channel>
</rss>
