Appearance
Data & Analytics — Theory (Bản gốc slide / Original slide)
1. Amazon Athena — Tổng quan
- Dịch vụ query serverless để phân tích dữ liệu lưu trong Amazon S3
- Dùng SQL chuẩn để query file (xây dựng trên nền Presto)
- Hỗ trợ định dạng CSV, JSON, ORC, Avro, Parquet
- Pricing: $5.00 / TB dữ liệu được scan
- Thường được dùng cùng Amazon QuickSight để làm reporting/dashboard
- Use case: business intelligence/analytics/reporting, phân tích & query VPC Flow Logs, ELB Logs, CloudTrail trail…
- Exam tip: phân tích dữ liệu trong S3 bằng serverless SQL → nghĩ ngay đến Athena
- Serverless query service to analyze data stored in Amazon S3
- Uses standard SQL language to query the files (built on Presto)
- Supports CSV, JSON, ORC, Avro, and Parquet
- Pricing: $5.00 per TB of data scanned
- Commonly used with Amazon QuickSight for reporting/dashboards
- Use cases: Business intelligence / analytics / reporting, analyze & query VPC Flow Logs, ELB Logs, CloudTrail trails, etc.
- Exam Tip: analyze data in S3 using serverless SQL → use Athena
2. Athena — Cải thiện hiệu năng (Performance Improvement)
- Dùng columnar data để tiết kiệm chi phí (scan ít hơn)
- Nên dùng Apache Parquet hoặc ORC
- Cải thiện hiệu năng rất lớn
- Dùng Glue để convert dữ liệu sang Parquet/ORC
- Nén dữ liệu để giảm dung lượng phải tải (bzip2, gzip, lz4, snappy, zlib, zstd…)
- Partition dataset trong S3 để dễ query theo virtual column:
s3://yourBucket/pathToTable/<PARTITION_COLUMN_NAME>=<VALUE>/...- Ví dụ:
s3://athena-examples/flight/parquet/year=1991/month=1/day=1/
- Dùng file lớn hơn (> 128 MB) để giảm overhead
- Use columnar data for cost-savings (less scan)
- Apache Parquet or ORC is recommended
- Huge performance improvement
- Use Glue to convert your data to Parquet or ORC
- Compress data for smaller retrievals (bzip2, gzip, lz4, snappy, zlib, zstd...)
- Partition datasets in S3 for easy querying on virtual columns
s3://yourBucket/pathToTable/<PARTITION_COLUMN_NAME>=<VALUE>/...- Example:
s3://athena-examples/flight/parquet/year=1991/month=1/day=1/
- Use larger files (> 128 MB) to minimize overhead
3. Athena — Federated Query
- Cho phép chạy SQL query trên nhiều nguồn dữ liệu — relational, non-relational, object storage, custom data source (trên AWS hoặc on-premises)
- Dùng Data Source Connector chạy trên AWS Lambda để thực hiện Federated Query (ví dụ: CloudWatch Logs, DynamoDB, RDS…)
- Lưu kết quả lại vào Amazon S3
- Allows you to run SQL queries across data stored in relational, non-relational, object, and custom data sources (AWS or on-premises)
- Uses Data Source Connectors that run on AWS Lambda to run Federated Queries (e.g., CloudWatch Logs, DynamoDB, RDS...)
- Store the results back in Amazon S3
4. Amazon Redshift — Tổng quan (Overview)
- Redshift dựa trên PostgreSQL, nhưng không dùng cho OLTP
- Đây là OLAP — online analytical processing (phân tích và data warehousing)
- Hiệu năng tốt hơn 10 lần so với các data warehouse khác, scale tới hàng petabyte
- Columnar storage (thay vì row-based) & parallel query engine
- Hai mode: Provisioned cluster hoặc Serverless cluster
- Có SQL interface để thực hiện query
- Tích hợp với BI tool như Amazon QuickSight hoặc Tableau
- So với Athena: query/join/aggregation nhanh hơn nhờ có index
- Redshift is based on PostgreSQL, but it's not used for OLTP
- It's OLAP — online analytical processing (analytics and data warehousing)
- 10x better performance than other data warehouses, scale to petabytes of data
- Columnar storage of data (instead of row based) & parallel query engine
- Two modes: Provisioned cluster or Serverless cluster
- Has a SQL interface for performing the queries
- BI tools such as Amazon QuickSight or Tableau integrate with it
- vs Athena: faster queries / joins / aggregations thanks to indexes
5. Redshift Cluster — Kiến trúc
- Leader node: dùng cho query planning và tổng hợp kết quả (result aggregation)
- Compute node: dùng để thực thi query, gửi kết quả về leader node
- Provisioned mode: chọn instance type trước; có thể reserve instance để tiết kiệm chi phí
- Leader node: for query planning, results aggregation
- Compute node: for performing the queries, send results to leader
- Provisioned mode: choose instance types in advance; can reserve instances for cost savings
6. Redshift — Snapshots & Disaster Recovery
- Redshift có chế độ "Multi-AZ" cho một số loại cluster
- Snapshot là bản backup tại một thời điểm (point-in-time) của cluster, lưu nội bộ trong S3
- Snapshot là incremental (chỉ lưu phần thay đổi)
- Có thể restore snapshot ra một cluster mới
- Automated: mỗi 8 giờ, mỗi 5 GB, hoặc theo lịch — retention từ 1 đến 35 ngày
- Manual: snapshot được giữ cho tới khi bạn tự xoá
- Có thể cấu hình Redshift tự động copy snapshot (automated hoặc manual) sang Region khác
- Redshift has "Multi-AZ" mode for some clusters
- Snapshots are point-in-time backups of a cluster, stored internally in S3
- Snapshots are incremental (only what has changed is saved)
- You can restore a snapshot into a new cluster
- Automated: every 8 hours, every 5 GB, or on a schedule — retention between 1 to 35 days
- Manual: snapshot is retained until you delete it
- You can configure Amazon Redshift to automatically copy snapshots (automated or manual) of a cluster to another AWS Region
7. Nạp dữ liệu vào Redshift (Loading Data)
- Insert theo lô lớn (large inserts) sẽ tốt hơn nhiều so với insert nhỏ lẻ
- Nguồn dữ liệu phổ biến: Amazon Kinesis Data Firehose → S3 (COPY command) → Redshift, hoặc EC2 Instance (JDBC driver) → Redshift
- Khi kết nối qua VPC:
- Without Enhanced VPC Routing: traffic đi qua Internet
- With Enhanced VPC Routing: traffic đi qua VPC, kiểm soát tốt hơn
- Ví dụ lệnh nạp dữ liệu:
sql
copy customer
from 's3://mybucket/mydata'
iam_role 'arn:aws:iam::0123456789012:role/MyRedshiftRole';- Large inserts are MUCH better than many small inserts
- Common sources: Amazon Kinesis Data Firehose → S3 (COPY command) → Redshift, or EC2 Instance (JDBC driver) → Redshift
- When connecting through a VPC:
- Without Enhanced VPC Routing: traffic goes through the Internet
- With Enhanced VPC Routing: traffic goes through the VPC, giving better control
- Example load command:
sql
copy customer
from 's3://mybucket/mydata'
iam_role 'arn:aws:iam::0123456789012:role/MyRedshiftRole';8. Redshift Spectrum
- Query trực tiếp dữ liệu đang nằm trong S3 mà không cần load vào cluster
- Vẫn cần có một Redshift cluster đang chạy để khởi động query
- Query sau đó được gửi tới hàng nghìn Redshift Spectrum node
- Query data that is already in S3 without loading it into the cluster
- Must have a Redshift cluster available to start the query
- The query is then submitted to thousands of Redshift Spectrum nodes
9. Amazon OpenSearch Service — Tổng quan
- Amazon OpenSearch là kế thừa của Amazon ElasticSearch
- Trong DynamoDB, query chỉ tồn tại theo primary key hoặc index…
- Với OpenSearch, bạn có thể search bất kỳ field nào, kể cả match từng phần (partial match)
- Thường dùng OpenSearch như phần bổ sung (complement) cho một database khác
- Hai mode: managed cluster hoặc serverless cluster
- Không hỗ trợ SQL natively (có thể bật qua plugin)
- Nhận dữ liệu (ingest) từ Kinesis Data Firehose, AWS IoT, CloudWatch Logs
- Bảo mật qua Cognito & IAM, mã hoá KMS, TLS
- Đi kèm OpenSearch Dashboards để trực quan hoá
- Amazon OpenSearch is the successor to Amazon ElasticSearch
- In DynamoDB, queries only exist by primary key or indexes…
- With OpenSearch, you can search any field, even partial matches
- It's common to use OpenSearch as a complement to another database
- Two modes: managed cluster or serverless cluster
- Does not natively support SQL (can be enabled via a plugin)
- Ingestion from Kinesis Data Firehose, AWS IoT, and CloudWatch Logs
- Security through Cognito & IAM, KMS encryption, TLS
- Comes with OpenSearch Dashboards (visualization)
10. OpenSearch — Các pattern tích hợp
- Từ DynamoDB (CRUD):
DynamoDB Table → DynamoDB Stream → Lambda Function → Amazon OpenSearch- DynamoDB dùng API để retrieve item, OpenSearch dùng API để search item
- Từ CloudWatch Logs:
- Real time:
CloudWatch Logs → Subscription Filter → Lambda Function (managed by AWS) → Amazon OpenSearch - Near real time:
CloudWatch Logs → Subscription Filter → Kinesis Data Firehose → Amazon OpenSearch
- Real time:
- Từ Kinesis Data Streams & Kinesis Data Firehose:
- Near real time:
Kinesis Data Firehose → Lambda (data transformation) → Amazon OpenSearch - Real time:
Kinesis Data Streams → Lambda Function → Amazon OpenSearch
- Near real time:
- From DynamoDB (CRUD):
DynamoDB Table → DynamoDB Stream → Lambda Function → Amazon OpenSearch- DynamoDB uses an API to retrieve items, OpenSearch uses an API to search items
- From CloudWatch Logs:
- Real time:
CloudWatch Logs → Subscription Filter → Lambda Function (managed by AWS) → Amazon OpenSearch - Near real time:
CloudWatch Logs → Subscription Filter → Kinesis Data Firehose → Amazon OpenSearch
- Real time:
- From Kinesis Data Streams & Kinesis Data Firehose:
- Near real time:
Kinesis Data Firehose → Lambda (data transformation) → Amazon OpenSearch - Real time:
Kinesis Data Streams → Lambda Function → Amazon OpenSearch
- Near real time:
11. Amazon EMR — Tổng quan & Loại Node
- EMR là viết tắt của "Elastic MapReduce"
- Giúp tạo Hadoop cluster (Big Data) để phân tích và xử lý khối lượng dữ liệu khổng lồ
- Cluster có thể gồm hàng trăm EC2 instance
- Đi kèm sẵn Apache Spark, HBase, Presto, Flink…
- EMR lo toàn bộ provisioning và configuration
- Auto-scaling và tích hợp với Spot Instance
- Use case: xử lý dữ liệu, machine learning, web indexing, big data…
Loại Node & Purchasing option:
- Master Node: quản lý cluster, điều phối, quản lý health — chạy dài hạn
- Core Node: chạy task và lưu dữ liệu — chạy dài hạn
- Task Node (tuỳ chọn): chỉ để chạy task — thường dùng Spot
- Purchasing option:
- On-demand: đáng tin cậy, có thể dự đoán, không bị terminate
- Reserved (tối thiểu 1 năm): tiết kiệm chi phí (EMR tự động dùng nếu có sẵn)
- Spot Instance: rẻ hơn, có thể bị terminate, kém tin cậy hơn
- Có thể chạy cluster dài hạn (long-running) hoặc cluster tạm thời (transient)
- EMR stands for "Elastic MapReduce"
- EMR helps creating Hadoop clusters (Big Data) to analyze and process vast amounts of data
- The clusters can be made of hundreds of EC2 instances
- EMR comes bundled with Apache Spark, HBase, Presto, Flink...
- EMR takes care of all the provisioning and configuration
- Auto-scaling and integrated with Spot Instances
- Use cases: data processing, machine learning, web indexing, big data...
Node types & purchasing:
- Master Node: manage the cluster, coordinate, manage health — long running
- Core Node: run tasks and store data — long running
- Task Node (optional): just to run tasks — usually Spot
- Purchasing options:
- On-demand: reliable, predictable, won't be terminated
- Reserved (min 1 year): cost savings (EMR will automatically use if available)
- Spot Instances: cheaper, can be terminated, less reliable
- Can have a long-running cluster, or a transient (temporary) cluster
12. Amazon QuickSight — Tổng quan & Tích hợp
- Dịch vụ business intelligence serverless, được hỗ trợ bởi machine learning để tạo dashboard tương tác
- Nhanh, tự động scale, embeddable, tính phí theo session
- Use case: business analytics, xây dựng visualization, ad-hoc analysis, lấy insight từ dữ liệu
- Tích hợp với RDS, Aurora, Athena, Redshift, S3…
- Dùng engine SPICE để tính toán in-memory khi dữ liệu được import vào QuickSight
- Enterprise edition: có thể thiết lập Column-Level Security (CLS)
- Nguồn dữ liệu tích hợp: AWS Service (RDS, Aurora, Redshift, Athena, S3, OpenSearch), on-premises database (JDBC), data import (log format ELF & CLF), SaaS (Timestream)
- Serverless, machine learning-powered business intelligence service to create interactive dashboards
- Fast, automatically scalable, embeddable, with per-session pricing
- Use cases: business analytics, building visualizations, perform ad-hoc analysis, get business insights using data
- Integrated with RDS, Aurora, Athena, Redshift, S3...
- In-memory computation using the SPICE engine if data is imported into QuickSight
- Enterprise edition: possibility to setup Column-Level Security (CLS)
- Integrated data sources: AWS Services (RDS, Aurora, Redshift, Athena, S3, OpenSearch), on-premises databases (JDBC), data imports (ELF & CLF log format), SaaS (Timestream)
13. QuickSight — Dashboard & Analysis
- Định nghĩa User (bản standard) và Group (bản enterprise)
- Các user & group này chỉ tồn tại trong QuickSight, không phải trong IAM!
- Một dashboard…
- là bản snapshot read-only của một analysis mà bạn có thể chia sẻ
- giữ nguyên cấu hình của analysis (filter, parameter, control, sort)
- Có thể share analysis hoặc dashboard với User hoặc Group
- Để share dashboard, phải publish nó trước
- User xem được dashboard thì cũng xem được dữ liệu gốc bên dưới
- Define Users (standard version) and Groups (enterprise version)
- These users & groups only exist within QuickSight, not IAM!
- A dashboard...
- is a read-only snapshot of an analysis that you can share
- preserves the configuration of the analysis (filtering, parameters, controls, sort)
- You can share the analysis or the dashboard with Users or Groups
- To share a dashboard, you must first publish it
- Users who see the dashboard can also see the underlying data
14. AWS Glue — Tổng quan (ETL)
- Managed ETL service (extract, transform, load)
- Hữu ích để chuẩn bị và biến đổi dữ liệu cho phân tích
- Dịch vụ hoàn toàn serverless
- Managed extract, transform, and load (ETL) service
- Useful to prepare and transform data for analytics
- Fully serverless service
15. Glue — Convert dữ liệu sang Parquet & Glue Data Catalog
Convert dữ liệu sang định dạng Parquet: S3 Put (input bucket) → trigger (Event notification / Lambda hoặc EventBridge) → Glue ETL Job (import CSV → chuyển sang Parquet) → S3 (output bucket) → Amazon Athena analyze.
Convert data into Parquet format: S3 Put (input bucket) → trigger (Event notification / Lambda or EventBridge) → Glue ETL Job (import CSV → convert to Parquet) → S3 (output bucket) → Amazon Athena analyzes.
Glue Data Catalog: catalog cho tất cả dataset. Glue Data Crawler đọc dữ liệu từ S3, RDS, DynamoDB, JDBC rồi ghi metadata (database/table) vào Glue Data Catalog — sau đó Athena, Redshift Spectrum, EMR dùng chính catalog này để data discovery.
Glue Data Catalog: catalog of all your datasets. The Glue Data Crawler reads from S3, RDS, DynamoDB, JDBC, then writes metadata (database/table) into the Glue Data Catalog — Athena, Redshift Spectrum, EMR then use that same catalog for data discovery.
16. Glue — Các tính năng cần biết
- Glue Job Bookmarks: tránh xử lý lại dữ liệu cũ
- Glue DataBrew: làm sạch & chuẩn hoá dữ liệu bằng các transformation dựng sẵn
- Glue Studio: GUI mới để tạo, chạy, giám sát ETL job trong Glue
- Glue Streaming ETL (xây trên Apache Spark Structured Streaming): tương thích với Kinesis Data Streaming, Kafka, MSK (managed Kafka)
- Glue Job Bookmarks: prevent re-processing old data
- Glue DataBrew: clean and normalize data using pre-built transformations
- Glue Studio: new GUI to create, run and monitor ETL jobs in Glue
- Glue Streaming ETL (built on Apache Spark Structured Streaming): compatible with Kinesis Data Streaming, Kafka, MSK (managed Kafka)
17. AWS Lake Formation
- Data lake = nơi tập trung toàn bộ dữ liệu phục vụ mục đích phân tích
- Dịch vụ fully managed, giúp thiết lập data lake chỉ trong vài ngày
- Discover, cleanse, transform, và ingest dữ liệu vào Data Lake
- Tự động hoá nhiều bước thủ công phức tạp (thu thập, làm sạch, di chuyển, catalog dữ liệu…) và de-duplicate (dùng ML Transforms)
- Kết hợp dữ liệu structured và unstructured trong data lake
- Có sẵn blueprint nguồn dữ liệu: S3, RDS, database quan hệ & NoSQL…
- Fine-grained Access Control cho ứng dụng (theo row và column-level)
- Được xây dựng trên nền AWS Glue
- Ví dụ Centralized Permissions:
S3/RDS/Aurora → ingest → Lake Formation (Access Control, Column-level security) → Data Lake (S3) → Athena, QuickSight, Users
- Data lake = central place to have all your data for analytics purposes
- Fully managed service that makes it easy to setup a data lake in days
- Discover, cleanse, transform, and ingest data into your Data Lake
- Automates many complex manual steps (collecting, cleansing, moving, cataloging data...) and de-duplicates (using ML Transforms)
- Combine structured and unstructured data in the data lake
- Out-of-the-box source blueprints: S3, RDS, relational & NoSQL DB...
- Fine-grained Access Control for your applications (row and column-level)
- Built on top of AWS Glue
- Centralized Permissions example:
S3/RDS/Aurora → ingest → Lake Formation (Access Control, Column-level security) → Data Lake (S3) → Athena, QuickSight, Users
18. Amazon Managed Service for Apache Flink
- Tên cũ: Kinesis Data Analytics for Apache Flink
- Flink (Java, Scala hoặc SQL) là framework để xử lý data stream
- Nguồn dữ liệu:
Kinesis Data StreamshoặcAmazon MSK (Apache Kafka)→ Amazon Managed Service for Apache Flink - Chạy bất kỳ ứng dụng Apache Flink nào trên một managed cluster của AWS
- Provisioned compute resource, parallel computation, auto-scaling
- Application backup (dưới dạng checkpoint và snapshot)
- Dùng mọi tính năng lập trình của Apache Flink để transform dữ liệu
- Lưu ý quan trọng: Flink không đọc trực tiếp từ Amazon Data Firehose
- Previously named: Kinesis Data Analytics for Apache Flink
- Flink (Java, Scala or SQL) is a framework for processing data streams
- Sources:
Kinesis Data StreamsorAmazon MSK (Apache Kafka)→ Amazon Managed Service for Apache Flink - Run any Apache Flink application on a managed cluster on AWS
- Provisioned compute resources, parallel computation, automatic scaling
- Application backups (implemented as checkpoints and snapshots)
- Use any Apache Flink programming features to transform data
- Important: Flink does not read from Amazon Data Firehose
19. Amazon MSK (Managed Streaming for Apache Kafka) & Kiến trúc Kafka
- Giải pháp thay thế cho Amazon Kinesis
- Fully managed Apache Kafka trên AWS
- Cho phép tạo, cập nhật, xoá cluster
- MSK tự tạo & quản lý Kafka broker node và Zookeeper node
- Triển khai MSK cluster trong VPC của bạn, multi-AZ (tối đa 3 AZ cho HA)
- Tự động phục hồi khỏi các lỗi phổ biến của Apache Kafka
- Dữ liệu lưu trên EBS volume trong thời gian tuỳ ý
- MSK Serverless: chạy Apache Kafka mà không cần quản lý capacity — MSK tự động provision resource, tự scale compute & storage
- Alternative to Amazon Kinesis
- Fully managed Apache Kafka on AWS
- Allow you to create, update, delete clusters
- MSK creates & manages Kafka broker nodes & Zookeeper nodes for you
- Deploy the MSK cluster in your VPC, multi-AZ (up to 3 for HA)
- Automatic recovery from common Apache Kafka failures
- Data is stored on EBS volumes for as long as you want
- MSK Serverless: run Apache Kafka without managing the capacity — MSK automatically provisions resources and scales compute & storage
Producer (code của bạn) ghi vào topic, dữ liệu được replicate qua các broker trong MSK Cluster; Consumer (code của bạn) poll từ topic để đọc dữ liệu — mô hình publish/subscribe kinh điển của Kafka.
Producers (your code) write to a topic, data is replicated across brokers in the MSK Cluster; Consumers (your code) poll from the topic to read the data — the classic Kafka publish/subscribe model.
20. Kinesis Data Streams vs. Amazon MSK & MSK Consumers
| Kinesis Data Streams | Amazon MSK | |
|---|---|---|
| Kích thước message | Giới hạn 1 MB | Mặc định 1MB, có thể chỉnh cao hơn (ví dụ 10MB) |
| Đơn vị phân vùng | Shard | Kafka Topic với Partition |
| Thay đổi phân vùng | Shard splitting & merging | Chỉ có thể thêm partition vào topic |
| Mã hoá in-flight | TLS | PLAINTEXT hoặc TLS |
| Mã hoá at-rest | KMS | KMS |
Amazon MSK Consumers phổ biến: Kinesis Data Analytics for Apache Flink, AWS Glue Streaming ETL Jobs (nền Apache Spark Streaming), Lambda, ứng dụng chạy trên EC2, ECS, EKS.
| Kinesis Data Streams | Amazon MSK | |
|---|---|---|
| Message size | 1 MB limit | 1MB default, configure for higher (e.g., 10MB) |
| Partitioning unit | Shards | Kafka Topics with Partitions |
| Partition changes | Shard splitting & merging | Can only add partitions to a topic |
| In-flight encryption | TLS | PLAINTEXT or TLS |
| At-rest encryption | KMS | KMS |
Popular Amazon MSK Consumers: Kinesis Data Analytics for Apache Flink, AWS Glue Streaming ETL Jobs (powered by Apache Spark Streaming), Lambda, applications running on EC2, ECS, EKS.
21. Case Study — Big Data Ingestion Pipeline
Yêu cầu: pipeline ingestion hoàn toàn serverless, thu thập dữ liệu real-time, transform dữ liệu, query bằng SQL, report lưu trong S3, và load dữ liệu vào warehouse để tạo dashboard.
Requirements: fully serverless ingestion pipeline, collect data in real time, transform the data, query the transformed data using SQL, reports stored in S3, load data into a warehouse and create dashboards.
- AWS IoT Core thu thập dữ liệu từ thiết bị IoT
- Kinesis rất tốt cho thu thập dữ liệu real-time
- Firehose giúp đưa dữ liệu vào S3 theo kiểu near real-time (mỗi 1 phút)
- Lambda giúp Firehose thực hiện data transformation
- Amazon S3 có thể trigger notification tới SQS
- Lambda có thể subscribe SQS (cũng có thể nối trực tiếp S3 → Lambda)
- Athena là serverless SQL service, kết quả được lưu trong S3
- Reporting bucket chứa dữ liệu đã phân tích, được dùng bởi công cụ report như AWS QuickSight, Redshift…
- IoT Core allows you to harvest data from IoT devices
- Kinesis is great for real-time data collection
- Firehose helps with data delivery to S3 in near real-time (1 minute)
- Lambda can help Firehose with data transformations
- Amazon S3 can trigger notifications to SQS
- Lambda can subscribe to SQS (we could have connected S3 to Lambda directly)
- Athena is a serverless SQL service and results are stored in S3
- The reporting bucket contains analyzed data and can be used by reporting tools such as AWS QuickSight, Redshift, etc.