Real-Time Streaming Data Enrichment with Database CDC | 2/5

AWS Developers · Beginner ·📊 Data Analytics & Business Intelligence ·2y ago

Key Takeaways

This video series demonstrates how to use Apache Flink and Change Data Capture (CDC) to enrich real-time streaming data, with a focus on keeping reference data up to date and using CDC to update Flink state in real-time. The series covers the setup of a CDC enrichment system using AWS CDK, MySQL, and Aurora MySQL, as well as the use of temporal joins in Apache Flink to process real-time event data.

Full Transcript

you might have struggled in the past between keeping the reference data up to date and enriching data streams at speed at the same time mainly because it's hard to enrich the data at Speed without keeping the reference data into the cash and as the data cached you have stale values on the other side if you decide to go directly to the database for the lookup every time it's too slow for realtime analytics welcome to part two of the series where we will be building realtime gaming leaderboard application using APF link over the course of five episodes you will learn all parts of streaming architecture starting from ingestion enrichment and all the way to the visualization you will also learn Advanced analytics techniques like control channel for AB testing handling late arrival of data exactly once archival and On Demand replay of the data in last video I provided you with the overview of a streaming architecture are building and completed the inje portion if you haven't seen part one I highly recommend you to watch it to get yourself familiar with the use case streaming Concepts and overall architecture we are building in this video I will show you how you can enrich a data stream at speed using my SQL database chain data capture we'll also talk about the data freshness you can find the GitHub repo containing everything you need in the description below let's begin so let's understand what is CDC and how we can use this CDC method to update the state which is cached within the Flink so imagine you have a table in the database with two Fields one is the ID and second is the subscription type with the player one and subscription type is free this is called initial setup and as as you have this initial setup CDC connector is going to bring this data into the Flink state in terms of the event and event will be insert in this case now imagine at sometime T2 in future there's a new row which is added and player to join the goal membership you again get the insert event propagated towards the Flink next one player One upgrades the subscription type from fre to 7day trial and that generates a update event this time instead of the insert one finally player two data get deleted and that generates the delete events what is the purpose of generating these events which is in sync with the database these events help us to update the Flink State and hold the most latest up toate value which is exact reflection of what you have in the database how we will use this reflected data of a Flink State into the joining process so imagine now you have the state of a player one with the free membership at time T1 and you receive the event for exit same player which is PED 280 so in this case the joined and reach data will produce player one subscription type free and speed is 280 but when the same data comes in future with let's say time T3 player one has now speed 300 because Flink has the most upto-date data received already from the database and in the cache Flink will say okay again I need to generate the data for player one but this time with subscription 7-Day trial because that's updated and the speed will be 300 what we have built so far is already ingestion portion of the architecture in this case We'll add two more components one is the Lambda function which is again the data generator continuously generating these update delete and insert events into the database and then we connect this database into the Flink now let me give you an overview of the code changes and guide you through the how to deploy cdk changes in your setup so we already finished the injection portion as you see here in this case you start with the branch number two which is CDC enrichment setup what it does for us is creates a network which is basically a VPC with two subnet types first one is the public which allows two directional internet second one is private which allows AWS resources to go out and contact the internet but doesn't allow the reverse traffic to any internet resources to come back and contact AWS resources next it sets up serverless database where you have two options first one is to use the Aurora my SQL if you wish to for the demos we are going with the ec2 based MySQL setup which is essentially mix of a secret manager which holds the credential for the database and the instance which is running the mySQL database for you third one data generator for player which MX the changes into the database in terms of the insert update and delete events let's go ahead now and deploy this so again going back to the terminal I in the branch two and in the infra folder already I'll say cdk deploy when prompted for the changes again you say yes to confirm let's wait for the changes to be deployed if you have any questions about anything in this architecture please leave comment and I will answer it so let me show you where is the code for building the WEA CDC connector so it's in the jar folder you'll already see one jar pre-compiled for you it's a pom.xml which builds it the pom.xml is like the Java way of building the fat jar with all the dependencies together what you will see this pom.xml is I have included two libraries first one is vevera connector for MySQL second one is the MySQL connector Java and then you have a Shar plug in which brings all the dependencies together and builds the fat jar just like this using the cdk that we have it already ships this fat jar to AWS and reference that into a notebook that's how we are using this jar and therefore we are able to use the mascu CDC as a connector type for the tables we already discussed about how we will use we a CDC connector for apach link to connect and stream CDC changes from MySQL now let's understand how we build this connector and use it in Notebook as you see you will have two new outputs appeared in the stack in cloud formation console first one with mySQL credential link and second is the host name of the mySQL database let's go to the K's analytic service and the studio notebook book you will see the new studio notebook appearing here which is quite similar to what you spinned up in the last part now let's hit run to start this notebook and then hit open up a zeppelin to load the Zeppelin you can hit import select the challenges notebook from the same notebook folder the GitHub Rao click open it will load up the new challenges notebook for you let's open this what you already have done is the events table if you haven't created it just make sure that you change the region and run the run it again you can run it a number of times because it always drops the table and recreates if it already exist in my case I am in us east1 so I'm doing that again now going to the players table as you see it uses the myql CDC connector now take the take the host name and the password from the cloud formation you can see the player table schema already here it contains variety of fields like operation Tim stamp player ID elas and other thing operation Tim stamp is the the Tim stamp of a given operation like insert update or delete and the rest of the schema is here now as you see the table is created you will use the player ID column to make a join across the two tables in the event table you also see the event time and event time TZ the mainly difference is event time TZ is time zoned one so the challenge for you here is can you select the data from the player table you can use these two commands to describe the schema the next challenge can you select from player table and plot a pie chart showing player distribution by country next challenge 2. to can you join the player and the event table based on the system time use the event time zone you can refer this link which gives you more information about how the temporal join Works in case of Apache Flink in this video we learn how to keep your data fresh through streaming enrichment in real time if you are enjoying this series please like this video and consider subscribing in the next video I will show you how how to process data calculate leaderboard and create easy to understand visuals stay tuned

Original Description

Learn how to keep reference data up to date while simultaneously enriching your data streams, with Apache Flink. We’ll take an in-depth look at how Apache Flink streaming join works with real-time event data and the database row level, using Change Data Capture (CDC). In this series, Anand Shah (Data Analytics and Streaming Specialist at AWS) will help you build a modern data streaming architecture for a real-time gaming leaderboard. This architecture includes data ingestion, real-time enrichment with database change data capture (CDC), data processing, as well as computing, storing and visualizing the results. You will also learn advanced streaming analytics techniques, such as the control channel method for A/B testing, updating features and parameters with zero downtime, and how to handle late arrival of data. Anand will also talk you through the process of data de-duplication, as well as how you can store historical data for replay on-demand. 🎉 🌟 Get started with Amazon Managed Service for Apache Flink today, to build and run your fully managed Apache Flink applications on AWS! 👉 https://aws.amazon.com/managed-service-apache-flink/ 🔗 Github repository: https://github.com/build-on-aws/real-time-gaming-leaderboard-apache-flink Resources used in this video: 🔗 AWS CDK Overview: https://docs.aws.amazon.com/cdk/v2/guide/home.html 🔗 Apache Flink CDC Connectors: https://github.com/apache/flink-cdc 🔗 Apache Flink Joins: https://nightlies.apache.org/flink/flink-docs-release-1.18/docs/dev/table/sql/queries/joins/ 🔗 Modern Streaming Data Architecture on AWS: https://docs.aws.amazon.com/whitepapers/latest/build-modern-data-streaming-analytics-architectures/what-is-a-modern-streaming-data-architecture.html Follow AWS Developers: 👾 Twitch: https://twitch.tv/aws 🐦 Twitter: https://twitter.com/awsdevelopers 💻 LinkedIn: https://www.linkedin.com/showcase/aws Follow Anand Shah: 🐦 Twitter: https://twitter.com/anandshah110 💻 LinkedIn: https://www.link
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from AWS Developers · AWS Developers · 0 of 60

← Previous Next →
1 Using Microsoft Active Directory across On-premises and Cloud Workloads
Using Microsoft Active Directory across On-premises and Cloud Workloads
AWS Developers
2 What is Cloud Computing with AWS? | Hebrew Webinar
What is Cloud Computing with AWS? | Hebrew Webinar
AWS Developers
3 Best Practices for Getting Started with AWS | Hebrew Webinar
Best Practices for Getting Started with AWS | Hebrew Webinar
AWS Developers
4 Best Practices for Using AWS Identity and Access Management (IAM) Roles
Best Practices for Using AWS Identity and Access Management (IAM) Roles
AWS Developers
5 Building Scalable Web Apps | Hebrew Webinar
Building Scalable Web Apps | Hebrew Webinar
AWS Developers
6 Dev & Test on the AWS Cloud | Hebrew Webinar
Dev & Test on the AWS Cloud | Hebrew Webinar
AWS Developers
7 Storage & Backup on AWS | Hebrew webinar
Storage & Backup on AWS | Hebrew webinar
AWS Developers
8 Disaster Recovery on AWS | Hebrew Webinar
Disaster Recovery on AWS | Hebrew Webinar
AWS Developers
9 AWS Israel News  | Episode 1
AWS Israel News | Episode 1
AWS Developers
10 Security Best Practices on AWS | Hebrew Webinar
Security Best Practices on AWS | Hebrew Webinar
AWS Developers
11 Ready: Introduction to AI on AWS | Hebrew Webinar
Ready: Introduction to AI on AWS | Hebrew Webinar
AWS Developers
12 Set: What is ML for developers? | Hebrew Webinar
Set: What is ML for developers? | Hebrew Webinar
AWS Developers
13 Go!: Building your own ChatBot with Amazon Lex | Hebrew Webinar
Go!: Building your own ChatBot with Amazon Lex | Hebrew Webinar
AWS Developers
14 And Beyond: Amazon Sagemaker | Hebrew Webinar
And Beyond: Amazon Sagemaker | Hebrew Webinar
AWS Developers
15 Building API-Driven Microservices with Amazon API Gateway - AWS Online Tech Talks
Building API-Driven Microservices with Amazon API Gateway - AWS Online Tech Talks
AWS Developers
16 Understanding AWS Secrets Manager - AWS Online Tech Talks
Understanding AWS Secrets Manager - AWS Online Tech Talks
AWS Developers
17 Best Practices for Building Enterprise Grade APIs with Amazon API Gateway - AWS Online Tech Talks
Best Practices for Building Enterprise Grade APIs with Amazon API Gateway - AWS Online Tech Talks
AWS Developers
18 Build, Train and Deploy Machine Learning Models on AWS with Amazon SageMaker - AWS Online Tech Talks
Build, Train and Deploy Machine Learning Models on AWS with Amazon SageMaker - AWS Online Tech Talks
AWS Developers
19 AWS Israel News | Episode 2 | re:Invent
AWS Israel News | Episode 2 | re:Invent
AWS Developers
20 AWS Floor28 News - January
AWS Floor28 News - January
AWS Developers
21 AWS Floor28 News - February - Hebrew
AWS Floor28 News - February - Hebrew
AWS Developers
22 AWS Floor28 News - March - Hebrew
AWS Floor28 News - March - Hebrew
AWS Developers
23 AWS Floor28 News - April - Hebrew
AWS Floor28 News - April - Hebrew
AWS Developers
24 AWS Floor28 News - May - Hebrew
AWS Floor28 News - May - Hebrew
AWS Developers
25 Authentication for Your Applications: Getting Started with Amazon Cognito - AWS Online Tech Talks
Authentication for Your Applications: Getting Started with Amazon Cognito - AWS Online Tech Talks
AWS Developers
26 AWS Floor28 News - June - Hebrew
AWS Floor28 News - June - Hebrew
AWS Developers
27 AWS Floor28 News - July - Hebrew
AWS Floor28 News - July - Hebrew
AWS Developers
28 Enriching your app with Image Recognition and AWS AI Services - AWS Webinar - Hebrew
Enriching your app with Image Recognition and AWS AI Services - AWS Webinar - Hebrew
AWS Developers
29 Personalize, Forcast, and Textract - AWS Webinar - Hebrew
Personalize, Forcast, and Textract - AWS Webinar - Hebrew
AWS Developers
30 Managing Your ML Development Lifecycle with Amazon SageMaker - AWS Webinar - Hebrew
Managing Your ML Development Lifecycle with Amazon SageMaker - AWS Webinar - Hebrew
AWS Developers
31 Running your ML code in Amazon Sagemaker - AWS Webinar - Hebrew
Running your ML code in Amazon Sagemaker - AWS Webinar - Hebrew
AWS Developers
32 Get Started in Minutes with Amazon Connect in Your Contact Center - AWS Online Tech Talks
Get Started in Minutes with Amazon Connect in Your Contact Center - AWS Online Tech Talks
AWS Developers
33 AWS Floor28 News - August - Hebrew
AWS Floor28 News - August - Hebrew
AWS Developers
34 AWS Floor28 News - September - Hebrew
AWS Floor28 News - September - Hebrew
AWS Developers
35 Deep Dive on Amazon EventBridge - AWS Online Tech Talks
Deep Dive on Amazon EventBridge - AWS Online Tech Talks
AWS Developers
36 Advanced Serverless Orchestration with AWS Step Functions - AWS Online Tech Talks
Advanced Serverless Orchestration with AWS Step Functions - AWS Online Tech Talks
AWS Developers
37 Living on the Edge - an Introduction to  Amazon CloudFront and Lambda@Edge  - Hebrew Webinar
Living on the Edge - an Introduction to Amazon CloudFront and Lambda@Edge - Hebrew Webinar
AWS Developers
38 AWS Floor28 News - October - Hebrew - YouTube
AWS Floor28 News - October - Hebrew - YouTube
AWS Developers
39 What's New with AWS Storage - AWS Online Tech Talks
What's New with AWS Storage - AWS Online Tech Talks
AWS Developers
40 How to Build a Compelling Migration Business Case Using TSO Logic - AWS Online Tech Talks
How to Build a Compelling Migration Business Case Using TSO Logic - AWS Online Tech Talks
AWS Developers
41 Configuring and Managing Amazon S3 Replication - AWS Online Tech Talks
Configuring and Managing Amazon S3 Replication - AWS Online Tech Talks
AWS Developers
42 AWS Floor28 News - November - Hebrew
AWS Floor28 News - November - Hebrew
AWS Developers
43 Using Relational Databases with AWS Lambda - Easy Connection Pooling - AWS Online Tech Talks
Using Relational Databases with AWS Lambda - Easy Connection Pooling - AWS Online Tech Talks
AWS Developers
44 AWS Floor28 News - December 2019 - Hebrew
AWS Floor28 News - December 2019 - Hebrew
AWS Developers
45 AWS Floor28 News - January 2020 - Hebrew
AWS Floor28 News - January 2020 - Hebrew
AWS Developers
46 Top 10 Data Migration Best Practices - AWS Online Tech Talks
Top 10 Data Migration Best Practices - AWS Online Tech Talks
AWS Developers
47 How to Use Azure Active Directory with AWS SSO - AWS Online Tech Talks
How to Use Azure Active Directory with AWS SSO - AWS Online Tech Talks
AWS Developers
48 AWS Tips & Tricks - Amazon Redshift Advisor - Hebrew
AWS Tips & Tricks - Amazon Redshift Advisor - Hebrew
AWS Developers
49 AWS Tips & Tricks - Amazon Redshift Elastic Resize - Hebrew
AWS Tips & Tricks - Amazon Redshift Elastic Resize - Hebrew
AWS Developers
50 AWS Tips & Tricks - Amazon Redshift Spectrum - Hebrew
AWS Tips & Tricks - Amazon Redshift Spectrum - Hebrew
AWS Developers
51 AWS Tips & Tricks - Savings Plans & Cost Explorer - Hebrew
AWS Tips & Tricks - Savings Plans & Cost Explorer - Hebrew
AWS Developers
52 AWS Tips & Tricks - Amazon Redshift Concurrency Scaling - Hebrew
AWS Tips & Tricks - Amazon Redshift Concurrency Scaling - Hebrew
AWS Developers
53 AWS Tips & Tricks - Training Models with Amazon SageMaker - Hebrew
AWS Tips & Tricks - Training Models with Amazon SageMaker - Hebrew
AWS Developers
54 AWS Tips & Tricks - Auto Model Tuning with Amazon SageMaker - Hebrew
AWS Tips & Tricks - Auto Model Tuning with Amazon SageMaker - Hebrew
AWS Developers
55 AWS Tips & Tricks - Amazon Comprehend - Hebrew
AWS Tips & Tricks - Amazon Comprehend - Hebrew
AWS Developers
56 Understanding High Availability and Disaster Recovery Features for Amazon RDS for Oracle
Understanding High Availability and Disaster Recovery Features for Amazon RDS for Oracle
AWS Developers
57 Amazon Forecast  – Forecasting  - From Months to Days (Hebrew)
Amazon Forecast – Forecasting - From Months to Days (Hebrew)
AWS Developers
58 Visualize your data with Amazon QuickSight (Hebrew)
Visualize your data with Amazon QuickSight (Hebrew)
AWS Developers
59 Amazon Kendra (Hebrew)
Amazon Kendra (Hebrew)
AWS Developers
60 AWS Floor28 News - AI/ML Special Edition
AWS Floor28 News - AI/ML Special Edition
AWS Developers

This video series teaches how to use Apache Flink and CDC to enrich real-time streaming data, with a focus on keeping reference data up to date and using CDC to update Flink state in real-time. The series covers the setup of a CDC enrichment system using AWS CDK, MySQL, and Aurora MySQL, as well as the use of temporal joins in Apache Flink to process real-time event data.

Key Takeaways
  1. Create a network with a VPC and two subnets (public and private)
  2. Set up the CDC connector to bring data into Flink state as events
  3. Use Flink state in the joining process to produce accurate results
  4. Deploy CDK changes in your setup
  5. Build WEA CDC connector using Java and Shar plugin
  6. Use MySQL CDC connector for streaming changes
  7. Create events and players tables in Zeppelin notebook
  8. Plot pie chart showing player distribution by country
  9. Join the player and the event table based on system time using event time zone
💡 The use of CDC to update Flink state in real-time allows for accurate and efficient processing of real-time event data, enabling real-time data enrichment and analysis.

Related Reads

📰
Common Mistakes New Data Engineers Make (And How to Avoid Them)
Learn to avoid common mistakes new data engineers make to improve data pipeline efficiency and reliability
Dev.to · Abhishek Konagalla
📰
DuckDB vs PostgreSQL: I Ran the Same Query on Both. One Finished in 12ms. The Other Timed Out.
Compare DuckDB and PostgreSQL performance by running the same query on both to determine when to use each database system
Medium · Programming
📰
Stop Using GROUP BY for Real-Time Leaderboards: How to Track the Top 10 Sales Performers Across 100…
Learn how to build real-time leaderboards without relying on GROUP BY, and discover a more efficient approach to tracking top performers in large datasets.
Medium · Programming
📰
Form 4 transaction codes, and why 1 in 5 insider sales isn’t a sale
Understand Form 4 transaction codes to accurately interpret insider sales data, as 1 in 5 sales may not be a traditional sale
Medium · Data Science
Up next
How to Prompt Your LLM Directly from SQL
Ian Wootten
Watch →