Hello! Welcome to the first lesson in our new module on Amazon EMR.
In the previous module, we focused entirely on AWS Glue, a serverless, managed ETL service. We concluded by learning how to orchestrate multi-step pipelines with Glue Workflows. Now, we're shifting gears to another cornerstone of the AWS data ecosystem: Amazon EMR (Elastic MapReduce). While Glue excels at abstracting away the underlying infrastructure, EMR gives you direct control over a managed cluster of EC2 instances running popular big data frameworks like Apache Spark, Hive, and Presto.
This lesson addresses the learning outcome: Configure EMR clusters with appropriate instance types and auto-scaling policies. Mastering this is fundamental to building cost-effective and high-performing data processing solutions with EMR. We will cover how to select the right hardware for your job and how to make your cluster dynamically adapt to your workload.
1. EMR Cluster Architecture: The Building Blocks
Before configuring a cluster, we need to understand its basic components. An EMR cluster consists of different types of nodes, each an EC2 instance with a specific role.
- Master Node: The brain of the cluster. It runs the primary components of your chosen frameworks (e.g., YARN ResourceManager, HDFS NameNode) and manages the distribution of data and tasks to the other nodes.
- Core Nodes: The workhorses. They both run tasks and store data in the Hadoop Distributed File System (HDFS). Your cluster must have at least one core node.
- Task Nodes: Optional compute power. They only run tasks and do not store data in HDFS. This makes them ideal for adding and removing capacity to handle processing spikes.
To get a clear overview of these components and how they fit together, please watch the following introductory video.
AWS EMR Tutorial [FULL COURSE in 60mins]
This video from the 'AWS EMR Tutorial' by Johnny Chivers provides a concise explanation of the master, core, and task nodes, as well as the important distinction between HDFS and EMRFS.
Watch the section from 07:26 to 10:27. As you watch, focus on: The distinct roles of master, core, and task nodes. The difference between storing data on the cluster in HDFS versus using EMRFS to access data in Amazon S3. Given your proficiency with S3, this concept should be very familiar.
As the video highlighted, using EMRFS (EMR File System) to read and write data directly to S3 is the most common and recommended pattern. This decouples your compute from your storage, allowing you to shut down your EMR cluster when it's not needed without losing your data, which remains durable in S3.
2. Choosing the Right Hardware: Instance Types and Purchasing Options
Selecting the right EC2 instance types for your nodes is a critical decision that directly impacts both performance and cost. Your choice should be driven by the characteristics of your workload.
- General Purpose (
mfamily, e.g.,m5.xlarge): A good starting point offering a balance of compute, memory, and networking. - Compute Optimized (
cfamily, e.g.,c5.xlarge): Ideal for CPU-bound jobs, like data transformations involving complex calculations. - Memory Optimized (
rfamily, e.g.,r5.xlarge): Best for memory-intensive Spark jobs that cache large datasets. - Storage Optimized (
ifamily, e.g.,i3.xlarge): Useful for workloads that require very high-performance local storage (e.g., using HDFS extensively).
The following video provides excellent best practices on how to match instance families to your job's needs.
Amazon EMR Deep Dive and Best Practices - AWS Online Tech Talks
The 'Amazon EMR Deep Dive and Best Practices' tech talk from AWS explains how to right-size your cluster by matching instance core-to-memory ratios with your job's requirements.
Watch from 10:41 to 12:14. Pay attention to the logic of choosing an 'r' series instance for a memory-intensive job over an 'm' series instance.
Purchasing Options for Cost Optimization
Beyond the instance family, you have different ways to pay for these instances, which is a major factor in cost optimization.
- On-Demand: The most expensive but most reliable. Guarantees capacity.
- Reserved Instances/Savings Plans: Offer discounts for a 1 or 3-year commitment.
- Spot Instances: Offer the deepest discounts (up to 90% off On-Demand) on spare EC2 capacity. The catch? AWS can reclaim this capacity with a two-minute warning.
The fault-tolerant nature of big data workloads makes Spot Instances a perfect fit for EMR, especially for task nodes. Losing a task node doesn't risk data loss (since they don't store HDFS data), and YARN can reschedule the lost work on another node.
Let's explore a common cost-saving strategy: mixing purchasing options.
Amazon EMR Deep Dive and Best Practices - AWS Online Tech Talks
This next segment of the same AWS tech talk explains how to strategically use different purchasing options for different node types and demonstrates the cost savings.
Watch from 25:18 to 30:54. Focus on the recommendations for each node type: Master Node: Use On-Demand for critical or long-running clusters to prevent cluster termination. Core Nodes: On-Demand is often recommended to protect HDFS data, though Spot can be used for less critical workloads. Task Nodes: The perfect candidate for Spot Instances to drastically lower costs. Pay close attention to the example calculation showing how adding Spot nodes can reduce both runtime and overall cost.
A modern feature to manage this mix is Instance Fleets. Instead of picking one instance type per node group (an "Instance Group"), you can provide a list of suitable instance types for your Task and Core fleets. EMR will then provision capacity from this list based on the lowest price and availability across Spot and On-Demand markets.

3. Elasticity Through Auto-Scaling
The "E" in EMR stands for "Elastic." One of its most powerful features is the ability to automatically add or remove nodes in response to workload demand. This ensures you have the performance you need during peak processing and saves money by removing idle resources.
There are two main ways to implement auto-scaling in EMR:
- EMR Managed Scaling: The modern, preferred method. You simply set minimum and maximum boundaries for your cluster, and EMR automatically makes intelligent scaling decisions based on multiple YARN metrics. It's simpler to configure and more responsive than the classic method.
- Custom Auto-Scaling: The classic method. You define specific scaling policies based on a single CloudWatch metric (e.g.,
YARNMemoryAvailablePercentage). You must configure the scale-up rule, scale-down rule, and cooldown periods yourself. This offers more granular control but is also more complex to manage and is primarily used for non-YARN applications like Presto.

The next video segment provides a superb visual comparison of these two approaches.
Amazon EMR Deep Dive and Best Practices - AWS Online Tech Talks
Let's return to the AWS tech talk for a comparison and demonstration of Managed Scaling versus classic auto-scaling.
Watch from 30:54 to 39:35. This is a critical section. Observe: The conceptual difference: Managed Scaling is declarative ('here are my boundaries'), while Custom Auto-Scaling is imperative ('scale when this metric does this'). The responsiveness: Note how much faster Managed Scaling reacts to both increases (scale-up) and decreases (scale-down) in load, which directly translates to cost savings.
While Managed Scaling is recommended for most Spark and Hadoop workloads, understanding Custom Auto-Scaling is still important for the exam and for specific scenarios. For a deeper dive into the mechanics and best practices of setting up custom policies, the following reading is invaluable.
Best practices for resizing and automatic scaling in ...
The AWS Big Data Blog post, 'Best practices for resizing and automatic scaling in Amazon EMR', provides excellent guidelines for when and how to configure auto-scaling policies.
Read the sections 'The superiority of Managed Scaling over Custom Auto Scaling' and 'Setting up policies for automatic scaling'. Focus on these key takeaways: When Custom Auto-Scaling is still the right choice (e.g., for Presto). Choosing the right metrics for scaling (e.g., HDFSUtilization for Core nodes, ContainerPendingRatio for Task nodes). The advice to scale Task nodes aggressively but be cautious when scaling Core nodes due to the HDFS decommissioning process.
Test your understanding!
You are designing an EMR cluster to run a continuous, 24/7 streaming analytics job using Apache Spark. The workload fluctuates significantly throughout the day. Your primary goals are to maintain performance during peak hours and minimize costs during quiet periods. The cluster processes sensitive data, so it must remain stable.
How would you approach configuring the cluster's nodes and scaling?
- Node Types & Purchasing Options: What purchasing option would you choose for the Master, Core, and Task nodes? Why?
- Scaling Strategy: Which auto-scaling method would you use? What would be your general approach to configuring it?
Show answer
- Node Types & Purchasing Options:
- Master Node: On-Demand. For a critical, long-running cluster, the stability of an On-Demand master node is non-negotiable. Losing a Spot master node would terminate the entire cluster.
- Core Nodes: On-Demand (or Reserved Instances for long-term commitment). Since HDFS data is stored here, and the cluster is long-running, On-Demand provides stability. Scaling core nodes is slow and disruptive, so it's better to provision a fixed, stable base.
- Task Nodes: Spot Instances using an Instance Fleet. Since task nodes are stateless compute, they are perfect for Spot. An Instance Fleet with multiple instance types would maximize the chances of acquiring cheap Spot capacity and increase resilience to Spot interruptions.
- Scaling Strategy:
- EMR Managed Scaling would be the ideal choice. It is designed for YARN applications like Spark, is highly responsive to fluctuating workloads, and is simple to configure.
- Configuration Approach: You would set the number of Core nodes to a fixed amount and only apply Managed Scaling to the Task nodes. You'd define a
MinimumCapacityUnits(perhaps 0 for quiet periods) and aMaximumCapacityUnitslarge enough to handle the highest peak load, and let EMR handle the rest.
Conclusion
In this lesson, we've laid the groundwork for using Amazon EMR effectively by focusing on its most fundamental configuration aspects. You now have a framework for making informed decisions about the hardware and elasticity of your clusters, which is central to optimizing for cost and performance.
Key Takeaways:
- An EMR cluster is composed of Master, Core, and Task nodes, each with a distinct role.
- Instance type selection should match your workload's profile (e.g., memory-intensive, compute-intensive).
- Strategically using Spot Instances, especially for Task nodes via Instance Fleets, is a key technique for cost reduction.
- EMR Managed Scaling is the modern, preferred method for automatically resizing clusters running YARN applications like Spark, offering simplicity and fast response times.
- Custom Auto-Scaling provides granular control but is more complex and is typically reserved for non-YARN workloads.
Next Up:
Now that we know how to configure the compute layer of an EMR cluster, the next logical step is to secure it. In the upcoming lesson, we will focus on how to "Configure EMR network security using security groups and VPC settings."