AWS Learning
Data Integration

Amazon EMR (Elastic MapReduce)

Managed Big Data Platform, Spark, Hadoop, Hive, Presto, 3 deployment options

Giới thiệu

Amazon EMR (Elastic MapReduce) là managed cluster platform giúp chạy các big data frameworks như Apache Spark, Hadoop, Hive, Presto để xử lý và phân tích petabytes of data.

┌─────────────────────────────────────────────────────────────────────────────┐
│                         Amazon EMR Overview                                 │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│   📊 BIG DATA PROCESSING PLATFORM                                           │
│                                                                             │
│   ┌─────────────────────────────────────────────────────────────────────┐   │
│   │                    Your Big Data                                    │   │
│   │       Logs  │  Clickstreams  │  IoT  │  Transactions                │   │
│   └─────────────────────────────────────────────────────────────────────┘   │
│                                 │                                           │
│                                  ▼                                          │
│   ┌─────────────────────────────────────────────────────────────────────┐   │
│   │                      Amazon EMR                                     │   │
│   │   ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐               │   │
│   │   │  Spark   │ │  Hadoop  │ │   Hive   │ │  Presto  │               │   │
│   │   └──────────┘ └──────────┘ └──────────┘ └──────────┘               │   │
│   │                                                                     │   │
│   │   Auto-scaling  │  Managed  │  Cost-effective  │  Fast              │   │
│   └─────────────────────────────────────────────────────────────────────┘   │
│                                 │                                           │
│                                  ▼                                          │
│   ┌─────────────────────────────────────────────────────────────────────┐   │
│   │                      Insights & Results                             │   │
│   │   Reports  │  ML Models  │  Analytics  │  Data Warehouse            │   │
│   └─────────────────────────────────────────────────────────────────────┘   │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

Đặc điểm chính

Đặc điểmMô tả
Managed ServiceAWS quản lý cluster, bạn focus vào data processing
ScalableXử lý từ GB đến PB data
Cost-effectivePer-second billing, Spot Instances support
Open SourceSpark, Hadoop, Hive, Presto, Flink...
FlexibleEC2, EKS, hoặc Serverless deployment

Kiến trúc

┌─────────────────────────────────────────────────────────────────────────────┐
│                         EMR Cluster Architecture                            │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│   ┌─────────────────────────────────────────────────────────────────────┐   │
│   │                    APPLICATIONS & PROGRAMS                          │   │
│   │   Spark │ Hive │ Presto │ Flink │ HBase │ TensorFlow │ Hudi         │   │
│   └─────────────────────────────────────────────────────────────────────┘   │
│                                   │                                         │
│   ┌─────────────────────────────────────────────────────────────────────┐   │
│   │                    DATA PROCESSING FRAMEWORK                        │   │
│   │              Hadoop MapReduce  │  Apache Spark                      │   │
│   └─────────────────────────────────────────────────────────────────────┘   │
│                                   │                                         │
│   ┌─────────────────────────────────────────────────────────────────────┐   │
│   │                    RESOURCE MANAGEMENT                              │   │
│   │                         YARN                                        │   │
│   └─────────────────────────────────────────────────────────────────────┘   │
│                                   │                                         │
│   ┌─────────────────────────────────────────────────────────────────────┐   │
│   │                    STORAGE LAYER                                    │   │
│   │   ┌──────────────┐  ┌──────────────┐  ┌──────────────┐              │   │
│   │   │     HDFS     │  │    EMRFS     │  │   Local FS   │              │   │
│   │   │  (ephemeral) │  │ (S3-backed)  │  │              │              │   │
│   │   └──────────────┘  └──────────────┘  └──────────────┘              │   │
│   └─────────────────────────────────────────────────────────────────────┘   │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

EMR Cluster Nodes

Node TypeVai tròBắt buộc
Master NodeQuản lý cluster, run YARN ResourceManager✅ Yes
Core NodeChạy tasks + lưu data trong HDFSTùy chọn
Task NodeChỉ chạy tasks, không lưu dataTùy chọn

Storage Options

StorageĐặc điểmDùng khi
HDFSEphemeral, distributed, fast I/OTemporary processing
EMRFS (S3)Persistent, scalable, cost-effectiveLong-term storage
Local FSInstance storageBuffers, caches

EMRFS = EMR File System - cho phép EMR đọc/ghi S3 như file system thông thường


Deployment Options

EMR có 3 deployment options:

┌─────────────────────────────────────────────────────────────────────────────┐
│                      EMR Deployment Options                                 │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│   ┌──────────────────────┐  ┌──────────────────────┐  ┌──────────────────┐  │
│   │    EMR on EC2        │  │    EMR on EKS        │  │  EMR Serverless  │  │
│   │                      │  │                      │  │                  │  │
│   │  ┌────────────────┐  │  │  ┌────────────────┐  │  │  ┌────────────┐  │  │
│   │  │  EC2 Instances │  │  │  │ EKS Pods       │  │  │  │ Auto-scale │  │  │
│   │  │  ┌────┐┌────┐  │  │  │  │ ┌────┐┌────┐  │  │  │  │ resources  │   │  │
│   │  │  │    ││    │  │  │  │  │ │    ││    │  │  │  │  └────────────┘   │  │
│   │  │  └────┘└────┘  │  │  │  │ └────┘└────┘  │  │  │                   │  │
│   │  └────────────────┘  │  │  └────────────────┘  │  │  No cluster      │  │
│   │                      │  │                      │  │  management!     │  │
│   │  Full control        │  │  Kubernetes          │  │                  │  │
│   │  Spot Instances      │  │  Container-based     │  │  Pay per use     │  │
│   └──────────────────────┘  └──────────────────────┘  └──────────────────┘  │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

So sánh Deployment Options

EMR on EC2EMR on EKSEMR Serverless
Quản lýBạn quản lý clusterBạn quản lý EKSAWS quản lý hoàn toàn
ControlFull control instancesContainer-levelChỉ submit jobs
ScalingManual/ManagedKubernetes autoscalingAuto (fine-grained)
Spot support✅ (EC2 mode)
Best forLong-running, predictableKubernetes shopsBursty, batch jobs

Frameworks hỗ trợ

FrameworkDùng đểĐặc điểm
Apache SparkGeneral processing, ML, streamingIn-memory, rất nhanh
Apache HadoopBatch processingMapReduce traditional
Apache HiveSQL queries on big dataData warehouse style
PrestoInteractive SQL queriesFast, federated queries
Apache FlinkReal-time streamingLow latency
Apache HBaseNoSQL databaseRandom read/write
Apache HudiData lake transactionsACID on data lakes
TensorFlow/MXNetMachine LearningDistributed ML training

Use Cases

┌─────────────────────────────────────────────────────────────────────────────┐
│                         EMR Use Cases                                       │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│   📊 BIG DATA ANALYTICS                                                     │
│   • Analyze clickstream data                                                │
│   • Process log files                                                       │
│   • Business intelligence                                                   │
│                                                                             │
│   🔄 ETL (Extract, Transform, Load)                                         │
│   • Clean và transform data                                                 │
│   • Move data between systems                                               │
│   • Data pipeline processing                                                │
│                                                                             │
│   🤖 MACHINE LEARNING                                                       │
│   • Train ML models on large datasets                                       │
│   • Feature engineering                                                     │
│   • Hyperparameter tuning                                                   │
│                                                                             │
│   📈 REAL-TIME STREAMING                                                    │
│   • Process IoT data                                                        │
│   • Real-time analytics                                                     │
│   • Fraud detection                                                         │
│                                                                             │
│   🔍 INTERACTIVE ANALYTICS                                                  │
│   • Ad-hoc SQL queries                                                      │
│   • Data exploration                                                        │
│   • BI tools integration                                                    │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

Pricing

Per-second billing (1-minute minimum)

DeploymentChi phí
EMR on EC2EC2 price + EMR uplift (varies by instance)
EMR on EKSEKS price ($0.10/hr) + EC2/Fargate + EMR uplift
EMR ServerlessvCPU/hr + Memory/hr + Storage/hr

Cost Optimization Tips

StrategyTiết kiệm
Spot InstancesĐến 90% cho Task nodes
EMR ServerlessChỉ trả cho resources dùng
Auto-terminationTerminate cluster khi xong job
Right-sizingChọn instance types phù hợp

Ví dụ pricing

EMR on EC2 example (m6g.xlarge):
─────────────────────────────────
EC2 price:   $0.154/hr
EMR uplift:  $0.045/hr
────────────────────────
Total:       $0.199/hr

→ 10-node cluster chạy 2 giờ = 10 × $0.199 × 2 = $3.98

So sánh với các services khác

ServiceDùng khi
EMRBig data processing với open-source frameworks (Spark, Hadoop)
AWS GlueServerless ETL, nhẹ hơn EMR
AthenaAd-hoc SQL queries trên S3 (không cần cluster)
RedshiftData warehouse, structured data
KinesisReal-time streaming ingestion

EMR vs Glue

EMRAWS Glue
TypeCluster-basedServerless ETL
ControlFull control, flexibleLimited, managed
FrameworksNhiều (Spark, Hadoop, Hive...)Spark only
PricingPer-second (cluster)Per DPU-hour
Best forComplex processing, MLSimple ETL jobs

Exam Tips

Key Points cho Cloud Practitioner

Câu hỏiĐáp án
"Process petabytes of data với Hadoop/Spark?"Amazon EMR
"Managed big data cluster platform?"Amazon EMR
"Run Apache Spark on AWS?"Amazon EMR
"ETL với full control, nhiều frameworks?"Amazon EMR
"Simple serverless ETL?"AWS Glue (không phải EMR)

Nhớ

EMR = "Elastic MapReduce"
    = Managed cluster cho BIG DATA
    = Chạy Spark, Hadoop, Hive, Presto...
    
3 deployment options:
├── EMR on EC2     → Full control
├── EMR on EKS     → Kubernetes
└── EMR Serverless → No cluster management

Storage:
├── HDFS    → Ephemeral (in-cluster)
└── EMRFS   → Persistent (S3-backed)

Tài liệu tham khảo