<?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 Merchant on Medium]]></title>
        <description><![CDATA[Stories by Varun Merchant on Medium]]></description>
        <link>https://medium.com/@varunmerchant?source=rss-e24ce6c8b16c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9Sy6JT8Vor3QwfK2PZ3OPw.jpeg</url>
            <title>Stories by Varun Merchant on Medium</title>
            <link>https://medium.com/@varunmerchant?source=rss-e24ce6c8b16c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 16:07:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@varunmerchant/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[Dockerizing Airflow: A Quick Guide to a Scalable Data Workflow]]></title>
            <link>https://medium.com/@varunmerchant/dockerizing-airflow-a-quick-guide-to-a-scalable-data-workflow-fabd43af49ba?source=rss-e24ce6c8b16c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fabd43af49ba</guid>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[airflow-installation]]></category>
            <dc:creator><![CDATA[Varun Merchant]]></dc:creator>
            <pubDate>Fri, 10 Oct 2025 15:58:38 GMT</pubDate>
            <atom:updated>2025-10-15T17:10:04.604Z</atom:updated>
            <content:encoded><![CDATA[<p>Apache Airflow is an open source tool that helps us to manage, monitor &amp; schedule DAGs.</p><p>For installing and running Airflow using Docker, we will need to first work on the following pre-requisites.</p><h4>Pre-requisite Installations</h4><p>Follow the steps mentioned in the below link install Docker Desktop -<a href="https://docs.docker.com/desktop/setup/install/windows-install">Docker Desktop</a></p><h4>Get the <em>docker-compose.yaml</em> file</h4><p>You will also require a Docker Compose yaml file. To get the docker-compose.yaml file, go to the below link. <br>At the time of this BLOG, I have used the latest airflow available which is version 3.1.0. If you want to know the latest available Airflow re;eases visit below link</p><p><strong>Airflow Releases</strong>: <a href="https://airflow.apache.org/docs/apache-airflow/stable/release_notes.html">https://airflow.apache.org/docs/apache-airflow/stable/release_notes.html</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C9zVFC5sf7dtJxN-Crf9Qw.png" /></figure><p>To get the docker compose file, visit the below URL<br>https://airflow.apache.org/docs/apache-airflow/3.1.0/docker-compose.yaml<br>Change the airflow version number as per the version that you are working with.</p><h4>Setup Airflow</h4><p>Now we will setup Airflow with Docker for Windows, installed.<br>Go to the local directory where you would like to setup Airflow — C:/directory/airflow-project. You can change the directory name or its path as needed.<br>Move the docker-compose.yaml file we got earlier into the Project directory and create 3 new folders there — “dags”, ”plugin”, ”logs”.</p><p>Now we can either go to Command Prompt or you can also open the folder in VS Code and open a new terminal. <br>Make sure that the path in Terminal or Command Prompt is the parent directory that you created earlier.<br>Execute the below commands:</p><pre>docker-compose up airflow-init</pre><pre>docker-compose up</pre><p>As soon as both the commands are executed, you will see a Container showing up in the Docker Desktop app like below and you can notice all the airflow related services that were installed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JdsvLiT0M_2KtTFmUoJCxw.png" /></figure><h4>Start Airflow</h4><p>If Airflow is properly installed, you can start it with the URL <a href="http://localhost:8080/">http://localhost:8080</a><br>With a default installation, use airflow as the username and password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5NA2Ljqb3txbnr1N-Fv34w.png" /><figcaption>Airflow Home</figcaption></figure><h4>Benefits of using Airflow with Docker</h4><ol><li>Dependency Management — Running Airflow in a Docker container simplifies managing dependencies. You can easily specify the required versions of Airflow and its dependencies without worrying about conflicts with other software on your machine.</li><li>Simplified Setup — Docker allows for the rapid spin-up of complete Airflow environments (including web server, scheduler, and database) using tools like <strong>Docker Compose</strong>. This can significantly reduce setup time.</li><li>Scalability — Docker makes it easier to scale your Airflow setup. You can quickly add more workers or services as needed without complex configurations.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fabd43af49ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ETL Optimization Techniques]]></title>
            <link>https://medium.com/@varunmerchant/etl-optimization-techniques-579db0d3dbdd?source=rss-e24ce6c8b16c------2</link>
            <guid isPermaLink="false">https://medium.com/p/579db0d3dbdd</guid>
            <category><![CDATA[data-optimization-basics]]></category>
            <category><![CDATA[etl-optimization]]></category>
            <category><![CDATA[data-optimization]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Varun Merchant]]></dc:creator>
            <pubDate>Wed, 21 May 2025 11:56:59 GMT</pubDate>
            <atom:updated>2025-05-28T14:27:11.943Z</atom:updated>
            <content:encoded><![CDATA[<p>Today, the corporates of the world are working on extremely data centric applications where they are prioritizing data as the backbone of their operations. Any number of sectors from manufacturing to retail to real estate to product companies are now leveraging their data capabilities to guide their businesses and grow them further.</p><p>It is estimated that, by 2028 the world will be dealing with data to the tune of 394 zettabytes.</p><p>This is where mainly ETL/ELT processes come in to load data from multiple source systems. But along with this, we also have a lot of challenges in processing such huge amounts of data. Below are some of the techniques from my learnings to help make thos process more efficient.</p><h3>ETL Optimizations</h3><p>Below are some of the ways I have optimised my ETL processes.</p><h3>Data Cleansing and Standardization Techniques</h3><h3>Data Standardization</h3><p>Data should always be first standardized while bringing it into the Bronze or the Silver layer. Data Standardization will make sure that the memory utilization for each column will be relatively uniform.</p><blockquote>For ex, let’s assume some data sources will use ‘Male’ or ‘Female’ whereas others will use “M” or “F”. Standardization of the data to specific formats will help in making the data more consistent.</blockquote><blockquote>Another example is when we have date values, if we don’t need a long date format then it is always better to keep the dates in the short date format. This helps in keeping the data volume and in turn memory consumption in check. The same would also be true for maintaining data types in small int/ int / double formats.</blockquote><p>Another use of effective standardization is when machine learning models need to be built on top of the data. Having a standard set of values wherever applicable helps in effective feature engineering as well.</p><h3>Data Cleaning</h3><h4>Null Handling</h4><p>We should try and avoid keeping null attributes as much as possible. If we still do need to keep nulls then it would be a good idea to standardize these values to certain fixed values, such as default dates, “UNKNOWNS”, 9999, etc. depending on the data and then bring these values back to nulls after processing is completed.</p><h4>Deduplication</h4><p>Data should always be deduplicated before it is brought into the Bronze or the Silver layer. Especially at times when the source is an event-based trigger, it would always be a good idea to get it deduplicated first to save on processing power and data volumes.</p><h4>Discard Outliers</h4><p>If there are some specific outliers, then these should also be discarded. Although for this step, please ensure that there is sufficient knowledge of the data domain when it comes to outlier identification and discard.</p><h3>Caching Policy Utilization</h3><p>Pyspark caching improves overall performance of Pyspark executions although you should be judicious in caching or one might end up with “Out Of Memory” issues. Below are the caching types:</p><ul><li>In-Memory Caching — cache()<br> - Here, the data is not stored on the disk physically. Dataframe.cache() is a lazy command so we would always require a action command to initiate the caching in memory.</li><li>Persistent Caching — persist()<br> - This is like using cache() except you can actually mention where the data needs to be stored (in memory, on disk or both)</li></ul><p>Benefits of caching:</p><ul><li>Better resource utilization — As the dataframe is cached, it would not be recomputed every time it is called.</li><li>Reduced data movement between nodes — Since the dataframe is cached, it will remain on the nodes, improving the processing speed especially across the network.</li><li>Faster execution — Caching will overall improve your Pyspark application performance as it will help in reading the same data from the disk multiple times.</li></ul><p>Note: One should always uncache() or unpersist() data after the dataframe processing is complete. This will ensure that all the occupied memory will be cleared and will not impact other applications in the spark context.</p><h3>Using Column Selections in Select statements</h3><p>It is always a good idea to mention column names in your SELECT statements and never use * operator. This saves a lot of time especially when the tables are quite huge.</p><h3>Avoid Data Shuffling</h3><p>Shuffling generally happens when wide transformations are used like groupBy(), repartiton(), join(). Data needs to be repartitioned which causes a shuffle in all the nodes. Shuffling is expensive due to</p><ul><li>Network I/O: When data is moved across multiple nodes, this involves network transfers which take away more time.</li><li>Serialization/Deserialization: When the data is moved across nodes, it forst needs to be serialized and then it needs to be deserialized on receipt at the target node.</li><li>Disk I/O: If the data frames are huge, and if the shuffle operation spills memory then the data is written to disk in which case there will be an overhead of data retrieval from disk and memory as well.</li></ul><p>The following are some of the ways we can avoid Data Shuffling:</p><ul><li>Broadcast Joins<br>- A lot of times, we need to join the data between multiple tables — like between a fact and a dimension table. When one of the tables in the join is less than 10MB in data or it is small enough to fit in memory, one should use Broadcast joins which will have the smaller data frame on all the nodes thereby reducing shuffling and improving performance.</li><li>Use repartition() judiciously<br>- When we repartition data, we end up shuffling data between nodes. So this can become a costly operaton if the dataframes are huge and can take away a lot of time.</li><li>Write Partitions<br>- It is important to partition the data on specific keys (Most queried columns) in a dataframe as this will ensure low shuffling while reading the data back.</li><li>Use of reduceByKey() vs groupByKey() functions<br>- The use of reduceByKey() vs groupByKey() functions depends on the outcome of the groupBy operation that we need.</li></ul><blockquote>groupByKey() — If we need to retain the values associated with keys, then we should use the groupByKey(). This function returns all the values associated with the keys as an iterative collection such as a list.</blockquote><blockquote>reduceByKey() — If we need to aggregate data, let’s say performing a sum or count based on certain keys, then it is better to use reduceByKey() as it will perform a local aggregation on each partition first before shuffling the data. This in turn reduces the amount of data passed over the network while shuffling and makes the process much faster.</blockquote><h3>Join Optimization</h3><ul><li>Ensuring join keys should not have any nulls<br>- Always ensure that the keys used for joins in your data should not have nulls. These would cause data skews when the joins are taking place. Data Skews generally cause the application to work very slowly, especially when the datasets that need joining are large</li><li>Ensure using only required columns in data frames while joining them.<br>- Always make sure that the data frames are deduped to the correct key and columns before joining the data. This will immensely help in optimizing the ETL process.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=579db0d3dbdd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>