Skip to main content

YARN Resource Management

Module Duration: 3-4 hours Focus: Architecture, Schedulers, Configuration Prerequisites: MapReduce understanding from Module 3

Introduction to YARN

YARN (Yet Another Resource Negotiator) was introduced in Hadoop 2.0 to solve fundamental limitations of Hadoop 1.x: Hadoop 1.x Problems:
  • Fixed map/reduce slots → Resource underutilization
  • JobTracker overload → Scalability limit at ~4000 nodes
  • Only MapReduce → Can’t run other frameworks
YARN Solution: Separate resource management from application logic

YARN Architecture

Component Overview

ResourceManager (RM)

The master daemon that manages:
  1. Scheduler: Allocates resources to applications
    • Purely scheduling (no monitoring/fault tolerance)
    • Pluggable: FIFO, Capacity, Fair schedulers
  2. ApplicationsManager:
    • Accepts job submissions
    • Negotiates first container for ApplicationMaster
    • Restarts ApplicationMaster on failure

NodeManager (NM)

Per-machine agent that:
  • Monitors resource usage (CPU, memory, disk, network)
  • Reports to ResourceManager via heartbeats
  • Launches and monitors containers
  • Cleans up container processes

ApplicationMaster (AM)

Per-application process that:
  • Negotiates resources from ResourceManager
  • Works with NodeManager(s) to execute tasks
  • Monitors task progress
  • Handles task failures
Key Insight: Each application has its own AM → Framework-specific logic isolated

Container

The unit of resource allocation:

YARN Application Lifecycle

Submitting a MapReduce Job

Fault Tolerance

ApplicationMaster Failure:
Task Failure:
NodeManager Failure:

YARN Schedulers

1. FIFO Scheduler

Simplest scheduler: First-In-First-Out queue.
Use Case: Single-user clusters, simple testing Limitations: No resource sharing, large jobs block small ones

2. Capacity Scheduler

Multiple queues with guaranteed capacity. Configuration (capacity-scheduler.xml):
Behavior:
Use Case: Multi-tenant clusters with SLAs

3. Fair Scheduler

Dynamically balances resources across applications. Configuration (fair-scheduler.xml):
Fair Sharing Example:
Use Case: Shared clusters for interactive analytics (Hive, Spark)

Configuring YARN

yarn-site.xml

MapReduce Resource Configuration

mapred-site.xml:

Monitoring YARN

ResourceManager Web UI

Access: http://resourcemanager:8088 Key Metrics:
  • Cluster metrics: Total memory, cores, available resources
  • Running applications
  • Queue utilization
  • NodeManager status

Command-Line Tools

Programmatic Monitoring


Advanced: Writing a Custom YARN Application

Basic skeleton for a custom YARN application:

Best Practices

Resource Sizing

Calculate container size:

Queue Configuration

Monitoring and Alerts

Set up alerts for:
  • High queue utilization (>80%)
  • Long-running jobs (potential issues)
  • Failed applications
  • NodeManager failures

Interview Focus

Key Questions:
  1. “How does YARN improve upon Hadoop 1.x?”
    • Separates resource management from processing
    • Supports non-MapReduce applications
    • Better scalability (10,000+ nodes)
  2. “Explain the role of ApplicationMaster”
    • Per-application coordinator
    • Negotiates resources from RM
    • Monitors tasks, handles failures
  3. “Fair vs Capacity scheduler?”
    • Fair: Equal share, preemption, better for interactive
    • Capacity: Guaranteed capacity, hierarchical queues, better for SLAs

What’s Next?

Module 5: Hadoop Ecosystem & Integration

Explore Hive, Pig, HBase, and other ecosystem tools