Organizations with a separate transactional database and data warehouse typically have many data engineering activities. For example, they extract, transform and load data from various sources into their data warehouse. Sources include customer transactions, data from Software as a Service (SAAS) offerings, and third-party data that could be useful for analyzing customer behavior. Such ETL jobs are managed using ETL frameworks that help organize appointments into ordered workflow graphs, track them, and monitor service level agreements.
Airflow has excellent scheduling capabilities, and a graph-based execution flow makes it a great alternative for running ETL jobs. This post will help you learn the basics of Airflow and perform an ETL job to transfer data from Amazon S3 to Redshift.
Apache Airflow
The flagship project of the Apache Software Foundation has already inspired many companies. The highly scalable solution makes the platform suitable for any size of company, from startups to large corporations.
Image source – DataValley.com
Workflows are defined, planned and executed using simple Python codes. Even complex data channels with numerous internal dependencies between tasks in the workflow are defined quickly and robustly. Because data engineering challenges do not end there, Airflow brings a rich command-line interface, an extensive web interface and an extended REST API, starting with the new major version of Apache-Airflow 2.0. Several features make monitoring and troubleshooting much more accessible. Airflow can be extended with numerous plugins, macros and user-defined classes depending on the requirements.
The status of workflow runs and associated log files are available with a click. Important meta data such as interval and time of the last run are visible in the main view. While Apache Airflow ETL workflows run independently, you are well informed about the current status. However, viewing the web interface is not mandatory, as Airflow optionally sends a notification via email or Slack in case of a failed attempt. The application spectrum focuses on the ETL area, where Apache Airflow machine learning workflows are also optimally coordinated.
Image source – apache.airflow.com
Apache Airflow web interface ETL Apache Airflow web interface. The status of workflow runs is visible on the left (Running).
The status of the most recent workflow tasks is visible on the right (Recent Tasks).
In the second workflow (example_complex), the context menu is activated.
To get a better overview of the possible use cases of Apache Airflow, we have summarized different use cases for you. In addition to classic application ideas, here you will find inspiration on how to enrich your data channels with state-of-the-art functions.
Classical
Ambitious
(I’m)possible
Classical
The basic idea of workflow management systems is buried in classic use cases: Tasks – especially in ETL – should be performed reliably and on time. In addition, external and internal dependencies must be considered before running the job. For example, an external dependency is a file to process that the sales department provides. Internal dependencies describe a conditional sequence of tasks between each other.
Cron alternative
Cron jobs are often used when tasks such as cleaning the database, sending newsletters or evaluating log files are performed regularly. If these tasks are taken into Airflow instead, you stay on top of many jobs and benefit from the traceability of status information.
Conditional, modular workflows
Complex dependencies can be implemented easily with Airflow. Integrated concepts such as branching and Task Groups make it low maintenance possible to create complex workflows. Branching allows conditional execution of multiple alternatives, and Task Groups allow smaller parts of a workflow to be reused.
Image source – DataValley.com
Data processing directly after generation
When several systems work together, waiting situations often occur. For example, a Bash task should run directly after sending a file. However, the exact delivery time is unknown. Therefore, airflow will pause the workflow with the sensor job class until this file exists.
Ambitious
The more workflows run on Airflow, the faster ideas for particular use cases emerge. As a power user, you want to go beyond Apache Airflow’s best practices and fully utilize its capabilities. Some advanced use cases only require customizing the configuration file. Others are implemented using custom plugins and task types (operators) or macros. Overall, there are many ways to adjust airflow to meet emerging needs.
Flexible working procedures
Although many aspects of the workflow are predefined in Python files, some flexibility can be built into some areas. Context variables such as execution date are available at runtime. This can be used in SQL statements, for example. Additional (encrypted) variables can be created using the CLI, API or web GUI. This can be used, for example, to make file paths flexible for uploads.
Image source – DataValley.com
Last but not least, the workflow structure itself can be dynamic. For example, the number of job instances for a variable number of records in the database can be set using variables. Likewise, dynamic_component_# components are created using a variable in graphics.
Big Data – Horizontal Scaling with Airflow
Horizontally scaled Airflow can process up to 10,000 automated tasks per day. At the same time, several terabytes flow through the data channels every day. For example, Spark transformations and data warehouse downloads are managed by Airflow in the Big Data space. With Airflow, execution errors and inconsistencies are reliably detected, and a response can be implemented as quickly as possible.
For example, suppose the data scheme changes unannounced or the volume of data increases due to exceptional circumstances. In that case, the result is visible in the monitoring, and the notification of responsible persons can be automated.
REST API
As a unique feature, Airflow includes an extensive REST API. This can be used to get information about the status of workflow runs, to pause or start workflows, and to store variables and connection information in the backend. Context variables can optionally be passed when the workflow is activated via the interface. Authentication ensures security here. Airflow can also be connected to SAP BW via REST API.
(I’m)possible
Airflow limitations must also be considered to judge which application ideas are possible and which are not. At its core, Airflow is a large-scale batch scheduler mainly used to manage third-party systems. In the basic idea of work procedures
• Workflows without repair plans
Executing a workflow on multiple arbitrary dates cannot be set in motion without additional effort. The web interface and CLI do not offer any functionality for this. The solution provides a REST API or manual workflow execution at the desired time via a web interface.
• Data exchange between workflows
One of the primary applications is the design of data pipelines. With XCOM, at least the metadata is exchangeable between functions. Here, for example, the location of data in the cloud can be handed over to a downstream task. The maximum metadata size is currently limited to the size of a BINARY LARGE OBJECT (BLOB) in the metadata database.
Conclusion
The mentioned points are often the reason for own plug-ins and macros to extend the functionality of Airflow. However, to date, Airflow has proven to be a reliable and well-designed workflow management platform that addresses many challenges of modern data engineering. Airflow is also ideal for training machine learning models coupled with the Anaconda environment.
Airflow brings a rich command-line interface, an extensive web interface and an extended REST API, starting with the new major version of Apache-Airflow 2.0.
Complex dependencies can be implemented easily with Airflow. Integrated concepts such as branching and Task Groups make it low maintenance possible to create complex workflows.
With Airflow, execution errors and inconsistencies are reliably detected, and a response can be implemented as quickly as possible.
The media shown in this article is not owned by Analytics Vidhya and is used at the Author’s discretion.
I am a Machine Learning Enthusiast. Done some Industry level projects on Data Science and Machine Learning. Have Certifications in Python and ML from trusted sources like data camp and Skills vertex. My Goal in life is to perceive a career in Data Industry.
We use cookies essential for this site to function well. Please click to help us improve its usefulness with additional cookies. Learn about our use of cookies in our Privacy Policy & Cookies Policy.
Show details
Powered By
Cookies
This site uses cookies to ensure that you get the best experience possible. To learn more about how we use cookies, please refer to our Privacy Policy & Cookies Policy.
brahmaid
It is needed for personalizing the website.
csrftoken
This cookie is used to prevent Cross-site request forgery (often abbreviated as CSRF) attacks of the website
Identityid
Preserves the login/logout state of users across the whole site.
sessionid
Preserves users' states across page requests.
g_state
Google One-Tap login adds this g_state cookie to set the user status on how they interact with the One-Tap modal.
MUID
Used by Microsoft Clarity, to store and track visits across websites.
_clck
Used by Microsoft Clarity, Persists the Clarity User ID and preferences, unique to that site, on the browser. This ensures that behavior in subsequent visits to the same site will be attributed to the same user ID.
_clsk
Used by Microsoft Clarity, Connects multiple page views by a user into a single Clarity session recording.
SRM_I
Collects user data is specifically adapted to the user or device. The user can also be followed outside of the loaded website, creating a picture of the visitor's behavior.
SM
Use to measure the use of the website for internal analytics
CLID
The cookie is set by embedded Microsoft Clarity scripts. The purpose of this cookie is for heatmap and session recording.
SRM_B
Collected user data is specifically adapted to the user or device. The user can also be followed outside of the loaded website, creating a picture of the visitor's behavior.
_gid
This cookie is installed by Google Analytics. The cookie is used to store information of how visitors use a website and helps in creating an analytics report of how the website is doing. The data collected includes the number of visitors, the source where they have come from, and the pages visited in an anonymous form.
_ga_#
Used by Google Analytics, to store and count pageviews.
_gat_#
Used by Google Analytics to collect data on the number of times a user has visited the website as well as dates for the first and most recent visit.
collect
Used to send data to Google Analytics about the visitor's device and behavior. Tracks the visitor across devices and marketing channels.
AEC
cookies ensure that requests within a browsing session are made by the user, and not by other sites.
G_ENABLED_IDPS
use the cookie when customers want to make a referral from their gmail contacts; it helps auth the gmail account.
test_cookie
This cookie is set by DoubleClick (which is owned by Google) to determine if the website visitor's browser supports cookies.
_we_us
this is used to send push notification using webengage.
WebKlipperAuth
used by webenage to track auth of webenagage.
ln_or
Linkedin sets this cookie to registers statistical data on users' behavior on the website for internal analytics.
JSESSIONID
Use to maintain an anonymous user session by the server.
li_rm
Used as part of the LinkedIn Remember Me feature and is set when a user clicks Remember Me on the device to make it easier for him or her to sign in to that device.
AnalyticsSyncHistory
Used to store information about the time a sync with the lms_analytics cookie took place for users in the Designated Countries.
lms_analytics
Used to store information about the time a sync with the AnalyticsSyncHistory cookie took place for users in the Designated Countries.
liap
Cookie used for Sign-in with Linkedin and/or to allow for the Linkedin follow feature.
visit
allow for the Linkedin follow feature.
li_at
often used to identify you, including your name, interests, and previous activity.
s_plt
Tracks the time that the previous page took to load
lang
Used to remember a user's language setting to ensure LinkedIn.com displays in the language selected by the user in their settings
s_tp
Tracks percent of page viewed
AMCV_14215E3D5995C57C0A495C55%40AdobeOrg
Indicates the start of a session for Adobe Experience Cloud
s_pltp
Provides page name value (URL) for use by Adobe Analytics
s_tslv
Used to retain and fetch time since last visit in Adobe Analytics
li_theme
Remembers a user's display preference/theme setting
li_theme_set
Remembers which users have updated their display / theme preferences
We do not use cookies of this type.
_gcl_au
Used by Google Adsense, to store and track conversions.
SID
Save certain preferences, for example the number of search results per page or activation of the SafeSearch Filter. Adjusts the ads that appear in Google Search.
SAPISID
Save certain preferences, for example the number of search results per page or activation of the SafeSearch Filter. Adjusts the ads that appear in Google Search.
__Secure-#
Save certain preferences, for example the number of search results per page or activation of the SafeSearch Filter. Adjusts the ads that appear in Google Search.
APISID
Save certain preferences, for example the number of search results per page or activation of the SafeSearch Filter. Adjusts the ads that appear in Google Search.
SSID
Save certain preferences, for example the number of search results per page or activation of the SafeSearch Filter. Adjusts the ads that appear in Google Search.
HSID
Save certain preferences, for example the number of search results per page or activation of the SafeSearch Filter. Adjusts the ads that appear in Google Search.
DV
These cookies are used for the purpose of targeted advertising.
NID
These cookies are used for the purpose of targeted advertising.
1P_JAR
These cookies are used to gather website statistics, and track conversion rates.
OTZ
Aggregate analysis of website visitors
_fbp
This cookie is set by Facebook to deliver advertisements when they are on Facebook or a digital platform powered by Facebook advertising after visiting this website.
fr
Contains a unique browser and user ID, used for targeted advertising.
bscookie
Used by LinkedIn to track the use of embedded services.
lidc
Used by LinkedIn for tracking the use of embedded services.
bcookie
Used by LinkedIn to track the use of embedded services.
aam_uuid
Use these cookies to assign a unique ID when users visit a website.
UserMatchHistory
These cookies are set by LinkedIn for advertising purposes, including: tracking visitors so that more relevant ads can be presented, allowing users to use the 'Apply with LinkedIn' or the 'Sign-in with LinkedIn' functions, collecting information about how visitors use the site, etc.
li_sugr
Used to make a probabilistic match of a user's identity outside the Designated Countries
MR
Used to collect information for analytics purposes.
ANONCHK
Used to store session ID for a users session to ensure that clicks from adverts on the Bing search engine are verified for reporting purposes and for personalisation
We do not use cookies of this type.
Cookie declaration last updated on 24/03/2023 by Analytics Vidhya.
Cookies are small text files that can be used by websites to make a user's experience more efficient. The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies, we need your permission. This site uses different types of cookies. Some cookies are placed by third-party services that appear on our pages. Learn more about who we are, how you can contact us, and how we process personal data in our Privacy Policy.