<?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 Sidharth Ramalingam on Medium]]></title>
        <description><![CDATA[Stories by Sidharth Ramalingam on Medium]]></description>
        <link>https://medium.com/@sidharth.ramalingam?source=rss-c90d0cf5596------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*bjh_stCv4kop1nTEe4wl7A.jpeg</url>
            <title>Stories by Sidharth Ramalingam on Medium</title>
            <link>https://medium.com/@sidharth.ramalingam?source=rss-c90d0cf5596------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 09:56:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sidharth.ramalingam/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[Data Engineering Project-2|Building Spotify ETL using Python and Airflow]]></title>
            <link>https://blog.devgenius.io/data-engineering-project-2-building-spotify-etl-using-python-and-airflow-432dd8e4ffa3?source=rss-c90d0cf5596------2</link>
            <guid isPermaLink="false">https://medium.com/p/432dd8e4ffa3</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[projects]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Sidharth Ramalingam]]></dc:creator>
            <pubDate>Mon, 30 Jan 2023 06:56:33 GMT</pubDate>
            <atom:updated>2023-01-30T13:34:53.676Z</atom:updated>
            <content:encoded><![CDATA[<p>Create an Extract Transform Load pipeline using python and automate with airflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dm8hVrPTPMenyRY4uJiBIA@2x.png" /><figcaption>Image by Author</figcaption></figure><p>In this blog post, will explain how to create a simple ETL(Extract, Transform, Load) pipeline using Python and automate the process through Apache airflow.</p><h3>Problem Statement:</h3><p>We need to use Spotify’s API to read the data and perform some basic transformations and Data Quality checks finally will load the retrieved data to PostgreSQL DB and then automate the entire process through airflow. <strong>Est.Time:</strong>[4–7 Hours]</p><h3>Tech Stack / Skill used:</h3><ol><li>Python</li><li>API’s</li><li>Docker</li><li>Airflow</li><li>PostgreSQL</li></ol><h3>Prerequisite:</h3><ol><li>Knowledge on API</li><li>Understand what docker and docker-compose</li><li>Intermediate Python and SQL</li><li>A basic understanding of Airflow <a href="https://www.youtube.com/watch?v=AHMm1wfGuHE&amp;t=705s">this </a>will help</li></ol><h3>Learning Outcomes:</h3><ol><li>Understand how to interact with API to retrieve data</li><li>Handling Dataframe in pandas</li><li>Setting up Airflow and PostgreSQL through Docker-Compose.</li><li>Learning to Create DAGs in Airflow</li></ol><h3>Introduction:</h3><p>This is a beginner-friendly project to get started with building a simple pipeline and automating through airflow. First, we will focus on entirely building the pipeline and then extend the project by combining it with Airflow.</p><h3>Building ETL Pipeline:</h3><p><strong>Dataset: </strong>In this project, we are using Spotify’s API so please go ahead and create an account for yourself. After creating the account head to this <a href="https://developer.spotify.com/console/get-recently-played/?limit=&amp;after=&amp;before=">page</a>. Now you will be able to see a get token icon click that and select user recently played and click get token.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*4UKYwl00ALuF9PQj-TTJyA.png" /><figcaption>Image by Author</figcaption></figure><p>You can see your token like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*CPZYseTyKH-CruoJpyNl-w.png" /><figcaption>Image by Author</figcaption></figure><p>Now, this is the procedure to get the token. You may need to generate this often as it expires after some time.</p><h4>Extract.py</h4><p>We are using this token to Extract the Data from Spotify. We are Creating a function return_dataframe(). The Below python code explains how we extract API data and convert it to a Dataframe.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/271251f379a23950889cca51c0830b00/href">https://medium.com/media/271251f379a23950889cca51c0830b00/href</a></iframe><h4>Transform.py</h4><p>Here we are exporting the Extract file to get the data.</p><p><strong>def Data_Quality(load_df): </strong>Used to check for the empty data frame, enforce unique constraints, checking for null values. Since these data might ruin our database it&#39;s important we enforce these Data Quality checks.</p><p><strong>def Transform_df(load_df): </strong>Now we are writing some logic according to our requirement here we wanted to know our favorite artist so we are grouping the songs listened to by the artist. Note: This step is not required you can implement it or any other logic if you wish but make sure you enforce the primary constraint.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53048c558868b63e8efd274b0d8e7ac5/href">https://medium.com/media/53048c558868b63e8efd274b0d8e7ac5/href</a></iframe><h4>Load.py</h4><p>In the load step, we are using sqlalchemy and SQLite to load our data into a database and save the file in our project directory.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5f4770bd7b2748381517cc1dffa3d1b/href">https://medium.com/media/d5f4770bd7b2748381517cc1dffa3d1b/href</a></iframe><p>Finally, we have completed our ETL pipeline successfully. The structure of the project folder should look like this(inside the project folder we have 3 files).</p><pre>E:\DE\PROJECTS\SPOTIFY_ETL\SPOTIFY_ETL<br>│   Extract.py<br>│   Load.py<br>│   my_played_tracks.sqlite<br>│   spotify_etl.py<br>│   Transform.py<br>└───</pre><p>After running the <strong>Load.py</strong> you could see a .sqlite file will be saved to the project folder, to check the data inside the file head <a href="https://inloop.github.io/sqlite-viewer/">here</a> and drop your file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OpGD1spYMVIulWVCKPttlw.png" /><figcaption>Image by Author</figcaption></figure><p>Now we will automate this process using Airflow.</p><h3>Automating through Airflow</h3><p>For those who have made it this far I appreciate your efforts 👏 but from here it gets a little tricky. Hence, I am mentioning some important points below.</p><ol><li>We have completed an ETL and this itself is a mini project hence save the work.</li><li>Now we are going to extend this with airflow using docker.</li><li>Why docker? we are using docker since it’s easier to install and maintain and it&#39;s OS independent.</li><li>How to set up airflow using Docker? Follow the guide provided in this <a href="https://medium.com/@garc1a0scar/how-to-start-with-apache-airflow-in-docker-windows-902674ad1bbe">blog</a>.</li><li>You need to change the Yaml file alone from the above guidelines please refer <a href="https://github.com/sidharth1805/Spotify_etl/blob/main/docker-compose.yml">here</a>.</li><li>After setting up the airflow place your dags inside the dags folder.</li><li>After the docker is up you could see 4 services running.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*txaw4D2bowisN98SbG6PZQ.png" /><figcaption>Image by Author</figcaption></figure><p>Your Airflow folder should look like the below structure.</p><pre>C:\USERS\SIDHA\DOCKER\AIRFLOW<br>│   docker-compose.yml<br>├───dags<br>│   │   YOUR_DAGS.py<br>├───logs<br>├───plugins<br>└───scripts</pre><p>Now that we have set up airflow we can view the airflow UI by visiting the <a href="http://localhost:8080/">8080 port</a>. The username and password would be airflow.</p><p>It’s time to create the required Dag for our project. But Before Jumping on to DAG let us understand what dag is DAG stands for Directed Acyclic Graph which is a set of tasks defined in the order of execution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*cImMkJ3NRWWLmw2o4mH9NQ.png" /><figcaption>Image by Author</figcaption></figure><p>So inside our dag, we need to create tasks to get our job done. To keep it simple I will use two tasks i.e. one to create Postgres Table and another to load the Data to the Table our dag will look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*hYbRd0gKRffQZn1Xipt-BA.png" /></figure><h4>spotify_etl.py</h4><p>In this Python File will write a logic to extract data from API → Do Quality Checks →Transform Data.</p><ol><li><strong>yesterday = today — datetime.timedelta(days=1)</strong> → Defines the number of days you want data for, change as you wish since our job is the daily load I have set it to 1.</li><li><strong>def spotify_etl()</strong> → Core function which returns the Data Frame to the DAG python file.</li><li>This file needs to be placed inside the dags folder</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/46e198027dd5629778c57b19671072a3/href">https://medium.com/media/46e198027dd5629778c57b19671072a3/href</a></iframe><h4>spotify_final_dag.py</h4><p>This is the most important section you need to pay attention to. First, learn the basics about airflow DAG’s <a href="https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/dags.html">here</a> it might take around 15 mins or you can search for it on youtube. After the basics please follow the below guideline.</p><ol><li><strong>from airflow.operators.python_operator import PythonOperator</strong> → we are using the python operator to perform python functions such as inserting DataFrame to the table.</li><li><strong>from airflow.providers.postgres.operators.postgres import PostgresOperator</strong> → we are using the Postgres operator to create tables in our Postgres database.</li><li><strong>from airflow. hooks.base_hook import BaseHook</strong> → A hook is an abstraction of a specific API that allows Airflow to interact with an external system. Hooks are built into many operators, but they can also be used directly in DAG code. We are using a hook here to connect Postgres Database from our python function</li><li><strong>from spotify_etl import spotify_etl</strong> → Importing spotify_etl function from spotify_etl.py</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ce381cc3b11820f412a9e33d0f4142f/href">https://medium.com/media/5ce381cc3b11820f412a9e33d0f4142f/href</a></iframe><h4>Code Explanation:</h4><p>Setting up the default arguments and interval time. We can change the interval time start date according to our needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YoZQLQWbgXUn4WOo_Z1o7Q.png" /></figure><p>Understanding Postgres connection and task.</p><ol><li><strong>conn = BaseHook.get_connection(‘[Your Connection ID]’)</strong> → Connects to your Postgres DB.</li><li><strong>df.to_sql(‘[Your Table Name]’, engine, if_exists=’replace’)</strong> → Loads the DF to the table</li><li><strong>create_table &gt;&gt; run_etl</strong> → Defining the flow of the task</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WjsH1W213_nOkQv8pgrAvA.png" /></figure><h4>Setting up the Postgres Connection on Airflow UI:</h4><p>Head to the Airflow UI and click connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uLaXIfiaWXPbVCJPr8oeMg.png" /></figure><p>Then create a connection.</p><ol><li><strong>The connection id:</strong> postgre_sql would be the one we used in our code.</li><li><strong>Connection Type:</strong> Postgres</li><li><strong>Host: </strong>Postgres</li><li><strong>Schema:</strong> spotify_db, you can use your own name but make sure to check in the proper database when validating.</li><li><strong>Login: </strong>airflow</li><li><strong>Password:</strong> airflow</li><li><strong>Port:</strong> 5432</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WJQ5g1OCONYLy-nYP4DBDQ.png" /></figure><p>Now its time to deploy :)</p><h4><strong>Deployment:</strong></h4><p>Check for your Dag in the dags section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S0T8xwbjYmgl1hZLy70Z-A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*J8wRUrI_5YYVoh8eeDP1vw.png" /></figure><p>After activation now run the dag by triggering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vK59llhtj85Q-MZg1qL5bA.png" /></figure><p>After completion check for the logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BuGKkg7OIav6AOGFTgSwcw.png" /></figure><p>Now we will validate by connecting to the Postgres database. Open terminal and execute: <strong>pgcli -h localhost -p 5432 -u airflow -d spotify_db.</strong>It will prompt for a password, enter airflow. Here <strong>spotify_db </strong>is our database name or schema of connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*NoiKtC3VXkhOV9BySpH1TA.png" /></figure><p>Type \d to see the tables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*jIO4zUKsmKPxz7jfVkNTLQ.png" /></figure><p>We can see our table is created and now let&#39;s check the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BcUcfyKepcxVLisLEUk_Cw.png" /></figure><p>Finally, we have made it :)</p><p>Now our requirement is to automate this entire process for demonstration purposes let me change the airflow interval time to <strong>3 mins</strong> and listen to some music🎵🎵🎵.</p><p>Now the current timestamp is shown below, let’s check after some time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*1o7tk-Sy4CfoJK6TB6u1Jw.png" /></figure><p>Hurray 🥳 we have made it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sqe43Kaofk9I-AmLzXQvIA.png" /></figure><p>The new song that I just listened to has been uploaded to our database automatically.</p><p>Let’s check the logs and task details. It’s a <strong>scheduled task</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*UXLjVHYORJ69U3QZdIuSgg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*7OM4LPzn7sR66cjBMGgNnw.png" /></figure><h3>Conclusion:</h3><p><strong>Note:</strong> We may need to change the token in our ETL python file since it expires after some time. There are some limitations to this project they can be overcome by using a refresh token to automatically renew the token and we can set up the airflow in cloud services to run 24/7 and pick data once a day making it a Daily load but to make this beginner-friendly I haven&#39;t covered those I will let those as TODO 😉.</p><p>Github Repo:<a href="https://github.com/sidharth1805/Spotify_etl">https://github.com/sidharth1805/Spotify_etl</a>. I hope you would have enjoyed the guided project a lot. I am pretty sure that you will face a lot of issues while doing the project Stack overflow is our best friend and feel free to connect with me on <a href="https://www.linkedin.com/in/sidharth-ramalingam/">LinkedIn</a> for any further questions. Follow me on <a href="https://medium.com/@sidharth.ramalingam">medium </a>to learn more about Data engineering stuff.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=432dd8e4ffa3" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/data-engineering-project-2-building-spotify-etl-using-python-and-airflow-432dd8e4ffa3">Data Engineering Project-2|Building Spotify ETL using Python and Airflow</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Spark : AQE(Adaptive Query Execution)]]></title>
            <link>https://blog.devgenius.io/apache-spark-aqe-adaptive-query-execution-d754afff96ba?source=rss-c90d0cf5596------2</link>
            <guid isPermaLink="false">https://medium.com/p/d754afff96ba</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Sidharth Ramalingam]]></dc:creator>
            <pubDate>Tue, 06 Dec 2022 11:30:43 GMT</pubDate>
            <atom:updated>2022-12-06T12:18:01.362Z</atom:updated>
            <content:encoded><![CDATA[<h3>Apache Spark : AQE(Adaptive Query Execution)</h3><h3>Spark Adaptive Query Execution</h3><p>Adaptive Query Execution (AQE) is one of the most significant features of Spark 3.0 which reoptimizes and adjusts query plans based on runtime statistics collected during the execution of the query.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jhivdDiEYfOaViR0M-OC7g@2x.png" /></figure><p>In spark 3.0 AQE is supported by :</p><p><strong>🎯Dynamically Switch Join Strategies</strong></p><p><strong>🎯Dynamically Coalesce Shuffle Partitions</strong></p><p><strong>🎯Dynamically Handle Skew Joins</strong></p><h4><strong>🎯Dynamically Switch Join Strategies:</strong></h4><p>Spark switches sort-merge join to broadcast hash join when the runtime statistics of any join side are smaller than the adaptive broadcast hash join threshold. By doing this we can save sorting operations on both tables and read shuffle files locally to save the network.</p><p><strong>Important Tuning Variables:</strong></p><p><strong>traffic.spark.sql.adaptive.localShuffleReader.enabled</strong> needs to be true if shuffling must be done locally.</p><p>spark.sql.adaptive.autoBroadcastJoinThreshold<strong>10Mb</strong>, If the value is set to -1 then Broadcasting will be disabled</p><h4><strong>🎯Dynamically Coalesce Shuffle Partitions</strong></h4><p>Shuffle Operation plays a key role in the performance of a spark application. One of the Key Properties of Shuffle is the number of partitions. If we set a few partitions then the data size of each partition may be very large, and the tasks to process these large partitions may need to spill data to disk and, as a result, slow down the query. If there are too many partitions, then the data size of each partition may be very small, and there will be a lot of small network data fetches to read the shuffle blocks, which can also slow down the query. To solve this we set a relatively large partition at the beginning and spark and AQE coalesces the small partitions into one. Hence always spark maintains optimal Partitions to perform Shuffle Upon</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*VG4CdzRAMUaBu7Jg4YAJlw.png" /><figcaption>Image Source: <a href="https://www.databricks.com/blog/2020/05/29/adaptive-query-execution-speeding-up-spark-sql-at-runtime.html">Databricks Blog</a></figcaption></figure><p>In the above example, we are required to perform Shuffle Operation on all 5 partitions. Now if AQE is Enabled spark joins the smaller Partitions and performs Shuffle on fewer Partitions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*zAi-F_Y54T7565KR.png" /><figcaption>Image Source: <a href="https://www.databricks.com/blog/2020/05/29/adaptive-query-execution-speeding-up-spark-sql-at-runtime.html">Databricks Blog</a></figcaption></figure><p><strong>Important Tuning Variables:</strong></p><p>spark.sql.adaptive.coalescePartitions.enabled<strong>true</strong></p><p>spark.sql.adaptive.coalescePartitions.minPartitionSize<strong>1MB. </strong>The minimum size of shuffle partitions after coalescing.</p><h4><strong>🎯Dynamically Handle Skew Joins</strong></h4><p>This feature is exactly opposite to the Coalescing partitions. In most of our applications, we are required to deal with Data skewness. Severe skew can significantly downgrade query performance, especially with joins. Hence Spark has the ability to identify such skewness.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gqnYQFXrwZ4iM5Ug.png" /></figure><p>In this example, you can notice <strong>A0</strong> Partition is pretty large compared to other partitions hence A0 needs to be split into two partitions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2-5PQ9WpUG3iv6B7.png" /></figure><p><strong>Important Tuning Variables:</strong></p><p>One can enable this feature in spark by setting <strong>spark.sql.adaptive.skewJoin.enabled </strong>as true, the default value is True.</p><p>spark.sql.adaptive.skewJoin.skewedPartitionThresholdInBytes<strong>256MB</strong>.A partition is considered as skewed if its size in bytes is larger than this threshold.</p><p>spark.sql.adaptive.skewJoin.skewedPartitionFactor<strong>5</strong>. A partition is considered skewed if its size is larger than this factor multiplied by the median partition size</p><h4>Reference:</h4><ul><li><a href="https://spark.apache.org/docs/latest/sql-performance-tuning.html#adaptive-query-execution">https://spark.apache.org/docs/latest/sql-performance-tuning.html#adaptive-query-execution</a></li><li><a href="https://www.databricks.com/blog/2020/05/29/adaptive-query-execution-speeding-up-spark-sql-at-runtime.html">https://www.databricks.com/blog/2020/05/29/adaptive-query-execution-speeding-up-spark-sql-at-runtime.html</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d754afff96ba" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/apache-spark-aqe-adaptive-query-execution-d754afff96ba">Apache Spark : AQE(Adaptive Query Execution)</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spark Architecture 101 | Concepts & Application]]></title>
            <link>https://blog.devgenius.io/spark-architecture-101-concepts-application-f5260783ac9d?source=rss-c90d0cf5596------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5260783ac9d</guid>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Sidharth Ramalingam]]></dc:creator>
            <pubDate>Mon, 14 Nov 2022 08:17:43 GMT</pubDate>
            <atom:updated>2022-11-14T09:00:19.047Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/816/0*ujD9drLEQp9gJ-LR.png" /></figure><p>In this blog post, we will understand Apache spark’s Architecture. This article will help you comprehensively understand how apache spark works. We will cover all the essential topic’s about spark architecture.</p><h3>Topic Covered in this Blog:</h3><ol><li>Spark Introduction</li><li>Spark Components</li><li>Stages</li><li>Shuffling</li><li>Spark Lifecycle.</li></ol><h3>Spark Introduction:</h3><p>Spark is a unified computing engine for parallel processing across clusters. Think of spark as a programming language like python or java which allows us to divide the process across different CPUs. That being said Spark supports multiple widely used programming languages (Python, Java, Scala, and R), includes libraries for diverse tasks ranging from SQL to streaming and machine learning, and runs anywhere from a laptop to a cluster of thousands of servers.</p><p><strong>Analogy:</strong> For a better understanding of the Spark architecture in detail we will use an analogy. Consider you run a restaurant, there is a bag full of apples and your task is to cut them into smaller pieces. let&#39;s say that the bag contains 10 apples and one person can cut the apples in that bag in 10 minutes. If there are 100 such bags it will take 1000 minutes(16.6 Hrs) to cut all the apples. Hence we need to distribute this work to more people and make them cut the apples parallelly so you could prepare your delicious salad. This is what exactly spark does.</p><h3><strong>Spark Components:</strong></h3><p>After understanding the analogy let’s use the same idea to understand the spark components.</p><p><strong>Driver</strong>: Consider Driver as a head chef/manager of the restaurant who distributes the work among the other chef.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*3I6ib_cBbBlifGtCxqdAkw.png" /></figure><p>In spark, the Driver is responsible for assigning <strong>Tasks </strong>to the<strong> </strong>executors. From a Data engineer&#39;s perspective if we want to filter a table consisting of 1000 rows these rows will be divided and distributed across the executors by <strong>Driver. </strong>Note that the driver will not be allowed to view the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*OFD9zrBljyRYdxTp" /><figcaption>Driver &amp; Executor Architecture(Source:<a href="https://datacadamia.com/db/spark/cluster/core">Datacademia</a>)</figcaption></figure><p><strong>Executors</strong>: Consider executors as a workstation/chopping board where the chef performs the task(cutting apples).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*PZ89uYWXORYq10PHpKFX_g.png" /></figure><p>In spark, the executors are the Java Virtual Machine where your task is being performed. The executors are responsible for running the individual task and sending the result to the driver.</p><p><strong>Slots/Cores: </strong>Slots or Cores are referred to the chefs performing the tasks of cutting apples. An executor consists of Cores/Slots. An executor(workstation) can consist of one or more cores/slots.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*3pdKefyydJ7lnYMLKaN2DQ.png" /></figure><p>In spark, Cores/Slots are the CPU that performs the actual task. The total number of cores present is responsible for executing more tasks parallelly.</p><p><strong>Jobs, Tasks, Dataset, Partitions:</strong></p><p><strong>Dataset </strong>is a collection of apples in a basket.</p><p><strong>Partitioning </strong>is the process of splitting the dataset into smaller parts. Partitioning is done by the driver.</p><p><strong>Tasks </strong>are usually the total number of partitions that needs to process for example if we have 4 baskets of 3 apples in each then we have 12 apples(Dataset) to be cut. This is divided into 12 partitions by driver hence 12 tasks have to be performed in total. Each task is performed by each core. Hence if we have 3 executors of 2 cores in each executor then we have 6 cores in total therefore there can be only a maximum of 6 tasks that can be performed parallelly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pnjy6CoDbl-9cBpLSSEBHw.png" /></figure><p><strong>Job </strong>is the overall instruction that the driver receives. In this case, we need to cut 4 baskets of 3 apples in each.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*nOSAYVR5Ng3CqizcB1gbAw@2x.png" /></figure><h3>Stages:</h3><p>Stages in Spark represent groups of tasks that can be executed together to compute the same operation on multiple machines. As we know already that the driver is not allowed to see the dataset then have you wondered how the driver knows the total no of rows in the dataset or apples in our example? Spark tackles this issue by distributing the dataset across executors and asking them for the count. Let’s understand the entire process by going through two stages.</p><p><strong>Stage 1:</strong> In this stage, the driver divides the dataset and distributes them to a set of executors. The driver now asks the executors to count the number of rows in the dataset. In this stage, the work of the executors is to find the no of apples in each basket. Now the count is stored within each executor on the disk to use in later stages this is also called <strong>shuffle data</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uPIllYDr2pyw8gpadKQL0g.png" /></figure><p><strong>Stage 2:</strong> Even now each of the executors can’t give the result directly to the driver and ask it to count the sum. So this process of adding the count of apples from each executor is performed by another executor and the total sum is given to the driver finally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nrUWxonMQBi7yqzTkUnZIw.png" /></figure><p>Since an executor is required to collect the information from all the other executors these operations are called <strong>wide transformation. Transformation </strong>is an instruction given by the spark to produce a new dataframe from an existing one.</p><p>Whenever there is an exchange of data between executors then we have a wide transformation and if no exchange of data is done then it&#39;s called a <strong>narrow transformation. </strong>More details of the transformation can be found <a href="https://sparkbyexamples.com/apache-spark-rdd/spark-rdd-transformations/">here</a>.</p><p>Now after these two stages are done we have now a total no of apples in our 12 it is. Now the driver exactly knows how to divide these apples among the other chefs. Now let us convert our understanding into stages.</p><p><strong>Stage 1:</strong>Divide the baskets among executors<br><strong>Stage 2:</strong>Count the total and deliver the result to the executor<br><strong>Stage 3:</strong>Driver divides the apple among the executor and the executor cut them into pieces.<br><strong>Stage 4:</strong> An executor is assigned to collect all the pieces from the other executors and deliver the result to the driver.</p><h3>Shuffling:</h3><p>Shuffling is the process of rearranging data within the cluster between stages. To understand shuffle better, we will take an example now our task is to count the distinct() fruit types present in our basket. Same as before now this task is done in two stages.</p><p><strong>Stage 1: </strong>The basket is distributed among executors. Now each executor is performing in counting the distinct fruits in the basket. This data is now stored in the disk of each executor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DGiRKYctK6Zl8lIlVtt2oA.png" /></figure><p><strong>Stage 2: </strong>Now each executor reads the data stored in another executor to find the total distinct fruits. This process of sharing data across the executors is known as <strong>shuffling</strong>. Shuffling is an expensive process in terms of architecture. Hence it&#39;s best to reduce our number of wide transformations as much as possible. Most of the time spark does it by it selves and the process is known as <strong>pipelining</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T1yYQLZWZ1m2ZEuEwZMNZQ.png" /></figure><h3>Spark Lifecycle:</h3><p>Now we have understood the important concepts of Spark, let us understand its entire lifecycle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*EzZs4uEuO30lV51KV07_RA.png" /></figure><p><strong>The cluster manager</strong> is responsible for maintaining the driver and the executors. Currently, there are three cluster managers available standalone cluster manager, Apache Mesos, and Hadoop YARN.</p><p><strong>Step 1: </strong>The user will submit a spark application. Here we are requesting the cluster manager to accept our request and allocate the resources for our application. You can find more on how to write a spark-submit application with examples <a href="https://sparkbyexamples.com/spark/spark-submit-command/">here</a>.</p><p><strong>Step 2: </strong>Now your application should create a <strong>SparkSession</strong>. This initializes the drivers and executors present in the cluster. The SparkSession will subsequently communicate with the cluster manager, asking it to launch Spark executor processes across the cluster. The number of executors and their relevant configurations are set by the user via the command-line arguments in the original <strong>spark-submit</strong> call.</p><p><strong>Step 3: </strong>Now the actual execution of the code happens. Let us understand it by running a simple count operation on a dataframe.</p><p>Creating the Dataframe:</p><pre>orders_df=spark.read.csv(&#39;dbfs:/FileStore/tables/Data/orders/part_00000&#39;,schema=&quot;&quot;&quot;order_id INT,order_date DATE,order_customer_id INT,order_status STRING&quot;&quot;&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kpPVYCfRtzn8jkZnFfHFaA.png" /></figure><p>Here the count operation is done in two stages.</p><p><strong>Stage 1:</strong> Locally counting the number of records.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*3NO684kiTXduBcq5N8ubgA.png" /></figure><p><strong>Stage 2:</strong> Shuffle stage where shuffling happens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*dsbipdi9vTERoMGzZn82cw.png" /></figure><blockquote>This execution plan is a directed acyclic graph (DAG) of transformations, each resulting in a new immutable DataFrame, on which we call an action to generate a result.</blockquote><h3><strong>Conclusion:</strong></h3><p>I hope after reading this article you would have a basic understanding of how apache spark works and what happens when we run our spark application. Follow me on <a href="https://medium.com/@sidharth.ramalingam">medium </a>to learn more about spark and Data engineering stuff. Feel free to connect with me on <a href="https://www.linkedin.com/in/sidharth-ramalingam/">LinkedIn</a> for any further questions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5260783ac9d" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/spark-architecture-101-concepts-application-f5260783ac9d">Spark Architecture 101 | Concepts &amp; Application</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Processing and Analysis using Spark | Spark Project-1]]></title>
            <link>https://blog.devgenius.io/data-processing-and-analysis-using-spark-spark-project-1-3f52516272a7?source=rss-c90d0cf5596------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f52516272a7</guid>
            <category><![CDATA[big-data-projects]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[spark]]></category>
            <dc:creator><![CDATA[Sidharth Ramalingam]]></dc:creator>
            <pubDate>Tue, 25 Oct 2022 09:25:58 GMT</pubDate>
            <atom:updated>2022-10-25T17:43:02.513Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rOe5v0px2ooR-uS1jMksTg.png" /><figcaption>Overview of the Design</figcaption></figure><p>In this blog post, we will understand how to perform simple operations on top of a relational database to get valuable Insights using Apache Spark.</p><h4>Problem Statement:</h4><p>We have three data tables which are of type CSV. We are performing basic joins in those tables and Creating a Demoralized data frame so that we could perform some processing and Analytics on top of our Data.</p><h4>Dataset:</h4><p>For this project, we are going to use the <a href="https://github.com/sidharth1805/Data-Processing-and-Analysis-using-Spark-Spark-Project-1/tree/main/Data">Retail Dataset</a>. These Datasets consist of three tables customer, orders, and order_items.</p><h4>Tech Stack / Skill used:</h4><ol><li>Spark</li><li>SQL</li></ol><h4>Setting the workspace:</h4><p>We will use Databricks Community Edition which is free of cost to perform the Spark operations if you prefer to use spark locally or in the Hadoop cluster it’s fine.</p><p>Refer: <a href="https://www.databricks.com/product/faq/community-edition">https://www.databricks.com/product/faq/community-edition</a></p><p>After setting up the workspace create a cluster and Open a workbook. You are all set to go.</p><h4>Project:</h4><p>Now it&#39;s time to add our data to the Databricks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3luM6g9xUS6mSd8LrM6Grg.png" /></figure><p>Upload the Data by creating proper folders in this below example I have created a folder Data under which I created a folder orders and uploaded the Data File.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q1y2jq4HCyl3G6DzXwVcQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*03P0lXF0JXsLNO6sMzd0nA.png" /></figure><p>Now That we are done with Setting up the Data in databricks now it&#39;s time to write some code.</p><p><strong>Step 1: </strong>Check if all the required files are placed</p><pre>%fs ls dbfs:/FileStore/tables/Data</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O4S_5uileBxtBJEG6XShww.png" /></figure><p><strong>Step 2:</strong> Create Dataframes for orders,order_items, and customers. The CSV files we are using don&#39;t have a schema hence while creating the data frame we define the schema.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd0590eb5b99c5f465a7150fafb12c8d/href">https://medium.com/media/fd0590eb5b99c5f465a7150fafb12c8d/href</a></iframe><p><strong>Step 3:</strong> View DataFrame</p><pre>order_items_df.show(2)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fLwzJ0n53JYNF_HvJ95TOg.png" /></figure><p><strong>Step 4:</strong> Join Our Tables into a new DataFrame(oreder_details) to create a Denormalized data frame.</p><ul><li>Joining customers and orders table initially.</li></ul><pre>customers_orders_df=customer_df.join(orders_df,customer_df[&#39;customer_id&#39;]==orders_df[&#39;order_customer_id&#39;])</pre><ul><li>Project the required Data using SELECT clause.</li></ul><pre>customers_orders_df.select(&#39;customer_id&#39;,&#39;order_id&#39;,&#39;order_date&#39;,&#39;order_status&#39;).orderBy(&#39;customer_id&#39;).show(10)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ld6Tas61Cx_n5zjXYAoEew.png" /></figure><ul><li>Consolidating order_id,order_date, and order_status to structure data type.</li></ul><pre>from pyspark.sql.functions import struct</pre><pre>customers_orders_df.select(&#39;customer_id&#39;,struct(&#39;order_id&#39;,&#39;order_date&#39;,&#39;order_status&#39;).alias(&#39;order_details&#39;)).orderBy(&#39;customer_id&#39;).show(10)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dsrz0kso_cnF3hg8NEttNA.png" /></figure><ul><li>Generate an array of struct. field using order_details. Here we are grouping the customer_id and storing the order_details in form of an array.</li></ul><pre>customer_order_struct=customers_orders_df.select(&#39;customer_id&#39;,struct(&#39;order_id&#39;,&#39;order_date&#39;,&#39;order_status&#39;).alias(&#39;order_details&#39;))</pre><pre>from pyspark.sql.functions import collect_list</pre><pre>final_df=customer_order_struct.groupBy(&#39;customer_id&#39;).agg(collect_list(&#39;order_details&#39;).alias(&#39;order_details&#39;)).orderBy(&#39;customer_id&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PHJ6r19u5SVJXtMxmfgkWg.png" /></figure><p><strong>Step 5: </strong>Export Data Frame into a JSON File.</p><pre>final_df.coalesce(1).write.json(&#39;dbfs:/FileStore/tables/Data/final&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*opuVNdwkT9jE2fkByiQu2g.png" /></figure><p>Previously we had performed the Denormalization for orders and customers. Now we will perform for the entire three tables.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4212dbe230306940c9c2914ce88700d1/href">https://medium.com/media/4212dbe230306940c9c2914ce88700d1/href</a></iframe><p>Export Data Frame into a JSON File.</p><pre>denorm_df.coalesce(1).write.json(&#39;dbfs:/FileStore/tables/Data/denorm&#39;)</pre><p>Now we have the required data to do our analysis. Now it&#39;s time to analyze the Denormalized data using Spark.</p><p>We shall perform the below analysis on our data</p><ol><li>Get the Details of the order placed by the customer on 2014 January 1st</li><li>Compute the monthly customer Revenue</li></ol><h4>Problem Statement — 1:</h4><p>Read the Data Frame.</p><pre>json_df=spark.read.json(&#39;dbfs:/FileStore/tables/Data/denorm/part-00000-tid-4357456608139543307-49cdb4fe-37a2-4435-be01-b6711f29eb3d-211-1-c000.json&#39;)</pre><pre>json_df.show(2)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dlMPVpTiJx4wGwB2BX7kGQ.png" /></figure><pre>json_df.select(&#39;customer_id&#39;,&#39;customer_fname&#39;,explode(&#39;order_details&#39;).alias(&#39;order_details&#39;)). \<br>filter(&#39;order_details.order_date LIKE &quot;2014-01-01%&quot;&#39;). \<br>orderBy(&#39;customer_id&#39;). \<br>select(&#39;customer_id&#39;,&#39;customer_fname&#39;,&#39;order_details.order_id&#39;,&#39;order_details.order_date&#39;,&#39;order_details.order_status&#39;). \<br>show(10)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BoRk9EEsk3zj68o5G8gfcA.png" /></figure><h4>Problem Statement — 2:</h4><ul><li>To calculate the monthly customer revenue we need to perform aggregations(SUM) on order_item_subtotal from the order_items table.</li><li>In our input data, we have wrapped all the details into a struct data type Hence it&#39;s time to flatten all the details.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8f05b6c3636c3f6b1595e5033db9095/href">https://medium.com/media/b8f05b6c3636c3f6b1595e5033db9095/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ccilDd7dyxW3Cp44lk7COw.png" /></figure><ul><li>After flattening our data let&#39;s write the logic to get the monthly revenue</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c848f0cc1d57c9ebd142944faaf53b9d/href">https://medium.com/media/c848f0cc1d57c9ebd142944faaf53b9d/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*2WssNX_in6Yy_JwDSeBvNA.png" /></figure><p>Hope this project will give you the required understanding of how to denormalize Data tables and use Spark to perform analysis on top of the data. Please refer <a href="https://github.com/sidharth1805/Data-Processing-and-Analysis-using-Spark-Spark-Project-1">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f52516272a7" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/data-processing-and-analysis-using-spark-spark-project-1-3f52516272a7">Data Processing and Analysis using Spark | Spark Project-1</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Three Key Metrics to look for while Investing and Trading]]></title>
            <link>https://medium.com/@sidharth.ramalingam/three-key-metrics-to-look-for-while-investing-and-trading-e5559792de67?source=rss-c90d0cf5596------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5559792de67</guid>
            <category><![CDATA[stock-market]]></category>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[investing]]></category>
            <dc:creator><![CDATA[Sidharth Ramalingam]]></dc:creator>
            <pubDate>Wed, 02 Feb 2022 17:46:13 GMT</pubDate>
            <atom:updated>2022-02-02T17:46:13.486Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hVKh9v6xVHuLQdaa" /><figcaption>Photo by <a href="https://unsplash.com/@jsnbrsc?utm_source=medium&amp;utm_medium=referral">Jason Briscoe</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Investing or trading your hard-earned money can be a very difficult task. A lot of people nowadays come with complex models to forecast financial markets. However, Most of them do not have a clear idea of what to expect. Hence I am listing out these three key parameters so that you could get a clear idea of what to expect while Investing or trading.</p><p>The three key metrics to look for</p><h3>1. Time</h3><p>When I say the time it means how many days or months or even years you are willing to wait to get the fruit from the seed you had sowed. A simple analogy more the time you wait you can expect a good return. According to the famous mathematician/trader, William Delbert Gann markets are seasonal and a single complete market cycle consists of 100 years. An important thing to remember is a cycle consists of a bull, bear, and a sideways market. Hence if you are going to be invested for a long run in a good Instrument(stocks, commodities, Bonds, Mutual Funds)you can expect a good return. Here if you are willing to put the time you can even have small investment, little risk, and still can expect a good return on investment if compounded.</p><h3>2. Return on Investment/Position</h3><p>The second parameter is the return on investment. Let me explain this with an example suppose you are investing in a stock trading at 100 dollars by buying a share and after a month the stock price moves to 110 you make a profit of 10 dollars on an investment of 100 hence ROI(Return on Investment) is 10%. While trading your position comes into play instead of the investment. Return on investment is the key factor that a lot of people don&#39;t think about while Investment especially while trading. To give you a simple picture investing in index Mutal funds is expected to give a return of <strong>12–15%</strong> in India while you can expect <strong>10–12%</strong> on gold. Hence next time you invest or trade think in percentage rather than thinking in the money you want to make. The percentage is strongly correlated with the time while investing. The percentage we saw above works in the long run over 10 years. After the pandemic 2020, the index has given a very good return which is more than 15% but if you are invested for more than 10 years it would be giving an annualized return of 12–15%. So while investing you need to be focusing on <strong>annualized ROI</strong>(<em>the geometric average amount of money earned by an investment each year over a given time period</em>). As far as trading is concerned it is going to be lasting for less than a month hence annualized ROI doesn&#39;t come to play. The trader&#39;s mindset should be fixing a percentage rather than a fixed amount. Let me explain this with an example suppose u need to make 500 dollars a month u need a model or system where with a position of 1000 dollars in each trade are expecting 2% and on average u need to take 50 trades and have an accuracy of more than 70 percent. This is the right way to achieve the goals.</p><h3>3. Risk</h3><p>Risk is one of the important parameters that a lot of people underestimate. It is the brakes that allow a car to go at high speed. Similarly, with proper risk management, one can expect a good return consistently. Instruments like options and futures are so risky but they can give u good returns in a short period of time. I think now you would have got an idea of how all the parameters are affecting one another if you are a person who can take big risks then u will be rewarded highly in a short span of time. A higher risky strategy/investment simply means the probability of winning is less. A small-cap stock may be an interesting investment but it comes with a greater risk than a well-established large-cap stock.</p><p>Summing up I would give some scenarios with examples</p><ol><li>Instrument A: Long waiting time, high return, low risk. eg)Investment in Gold, Index funds.</li><li>Instrument B: Moderate waiting time, moderate return, moderate risk eg)Investment in Large-cap Stocks, Real Estate</li><li>Instrument C: Less waiting time, high return, high risk. eg)Investment in startups, small-cap, and cryptocurrency.</li></ol><p>So the next time you put your money into something evaluate these three parameters properly and set your expectations accordingly. Thank You</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OjBewXaE3GLaLTivUlwiJQ.png" /><figcaption>Image by Author</figcaption></figure><p><strong><em>Please Note</em></strong><em>: The content in this blog is intended to be used and must be used for information and education purposes only. It is very important to do your own analysis before making any investment based on your own personal circumstances. You should take independent financial advice from a professional in connection with, or independently research and verify, any information that you find in this blog and wish to rely upon, whether for the purpose of making an investment decision or otherwise.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5559792de67" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>