

# Cost Estimation and Optimization

Amazon EMR pricing depends on the deployment option. With Amazon EMR on Amazon EC2, you pay a per-second rate that includes EMR and the underlying EC2 and EBS costs. With Amazon EMR on Amazon EKS, you pay a per-second rate for the vCPU and memory your jobs use on top of your EKS costs. With Amazon EMR Serverless, you pay only for the vCPU, memory, and storage your applications consume while they run. For full pricing, see [Amazon EMR pricing](https://aws.amazon.com/emr/pricing/).

## Estimating your EMR costs
<a name="estimating-emr-costs"></a>

Start with your on-premises metrics and map them to the equivalent Amazon EMR resources for each deployment option. The following table shows the billing model and the estimation inputs for each option.


**Amazon EMR billing models and estimation inputs**  

| Deployment option | Billing model | Estimation inputs | 
| --- | --- | --- | 
| Amazon EMR on Amazon EC2 | EC2 instances \+ EMR service fee \+ EBS volumes (per node) | Instance family, node count per role (primary, core, task), runtime hours, storage volume | 
| Amazon EMR on Amazon EKS | EC2 instances \+ EKS cluster fee \+ EMR service fee (per vCPU-hour and GB-hour) | vCPU and memory per pod, job runtime, node configuration | 
| Amazon EMR Serverless | vCPU-hours \+ memory GB-hours \+ storage GB-hours | Worker size, worker count, runtime | 

### Sizing persistent clusters
<a name="sizing-persistent-clusters"></a>

To size a persistent cluster, map your on-premises aggregate vCPU and memory to Amazon EMR node capacity. Work through the following steps.
+ **Aggregate compute and memory** — determine the average and peak aggregate vCPU and memory across your existing cluster.
+ **Performance adjustment** — the Amazon EMR runtime for Apache Spark outperforms open-source Spark on the same hardware. For conservative planning, assume you need only 75% of your current average capacity, and validate the assumption through testing.
+ **vCPU-to-memory ratio** — divide total average memory by total average vCPU, then select the instance family. A ratio of 1:2 to 1:3 maps to the compute-optimized C-family, 1:4 to 1:5 maps to the general-purpose M-family, and 1:6 to 1:8 maps to the memory-optimized R-family.
+ **Baseline and scaling** — size the baseline primary and core nodes to steady-state demand, and let Amazon EMR managed scaling add task nodes for peaks.

The following table shows a worked example of this sizing process.


**Persistent cluster sizing example**  

| Input | Value | 
| --- | --- | 
| On-premises aggregate (average) | 800 vCPU, 3,200 GB memory | 
| On-premises aggregate (peak) | 1,000 vCPU, 4,000 GB memory | 
| Performance adjustment | 75% | 
| vCPU-to-memory ratio | 1:4 | 
| Target instance family | M-family (general-purpose) | 
| Persistent cluster sizing | Baseline = 600 vCPU / 2,400 GB; managed scaling to 750 vCPU / 3,000 GB at peak | 

After you know the target capacity, choose a specific instance size for each node role. Core and task nodes are typically similar in size. The primary node can be smaller because it handles cluster management rather than data processing. Size each role independently. For guidance on matching instance families to workloads, see [Optimizing costs](#optimizing-costs).

The following table shows how the example sizing converts to billable units.


**Persistent cluster charges**  

| Component | Calculation | Billable units | 
| --- | --- | --- | 
| Core and task node sizing | General-purpose instance: 48 vCPU, 192 GB memory | — | 
| Primary nodes (HA) | 3 nodes x 730 hrs/mo | 2,190 instance-hours | 
| Core nodes (baseline) | 600 vCPU / 48 vCPU per node = 13 nodes x 730 hrs/mo | 9,490 instance-hours | 
| Task nodes (peak scaling) | 150 vCPU / 48 vCPU per node = 4 nodes x active hrs/mo | Varies by workload pattern | 
| EBS storage | Provisioned GB per node x node count | GB-months | 

**Note**  
Each instance-hour incurs both an EC2 charge and an EMR service charge. Use the AWS Pricing Calculator to combine these into a monthly estimate.

### Estimating charges for job-based workloads
<a name="estimating-job-based-workloads"></a>

Transient Amazon EMR on Amazon EC2, Amazon EMR on Amazon EKS, and Amazon EMR Serverless incur EMR charges only while a job runs. For each representative job, capture the vCPU and memory, the runtime, and the frequency. Then convert these inputs to monthly billable units.

The following table shows an example job that uses 250 vCPU and 1,000 GB memory, runs for 2 hours, and runs 20 times per month.


**Job-based charges example**  

| Deployment model | Monthly billable unit | 
| --- | --- | 
| Transient Amazon EMR on Amazon EC2 | 5 nodes x 2 hours x 20 runs = 200 instance-hours | 
| Amazon EMR Serverless | 250 vCPU x 2 hours x 20 runs = 10,000 vCPU-hours; 1,000 GB x 2 hours x 20 runs = 40,000 GB-hours | 
| Amazon EMR on Amazon EKS | 250 vCPU x 2 hours x 20 runs = 10,000 vCPU-hours; 1,000 GB x 2 hours x 20 runs = 40,000 GB-hours, plus EKS/EC2 infrastructure | 

### Tools for estimation
<a name="tools-for-estimation"></a>

The following tools help you build an estimate.
+ **AWS Pricing Calculator** — estimates all three Amazon EMR deployment options.
+ **Amazon EMR Serverless cost estimator** — estimates Serverless costs from your worker configuration and runtime.

## Optimizing costs
<a name="optimizing-costs"></a>

Amazon EMR provides multiple features that lower your costs. As you plan your deployment, consider the following factors.

### Workload type
<a name="workload-type"></a>

Your workload type determines whether a transient or a long-running cluster fits best.

![Diagram classifying typical Amazon EMR workloads into transient and long-running cluster types.](https://docs.aws.amazon.com/whitepapers/latest/amazon-emr-migration-guide/images/figure1.png)


**Figure 1: Typical workloads and their cluster types**
+ **Transient** — the cluster starts, runs its jobs, and terminates. You pay only for the time the cluster runs. This pattern fits scheduled batch jobs, ETL, and ad-hoc analysis.
+ **Long-running or persistent** — the cluster stays up continuously. You pay for all 24 hours of each day, including idle time. This pattern fits interactive query engines, Apache HBase serving, and shared analytics.

The following table maps common workload patterns to a recommended deployment option.


**Workload patterns and recommended deployment options**  

| Pattern | Workload characteristic | Recommended deployment option | 
| --- | --- | --- | 
| Long-running | Steady, predictable load | Amazon EMR on Amazon EC2 with Reserved Instances or Savings Plans | 
| Long-running | Apache HBase | Amazon EMR on Amazon EC2 (required for HBase) | 
| Long-running or transient | Organization runs on Amazon EKS and wants to share cluster capacity between Spark and other container workloads | Amazon EMR on Amazon EKS | 
| Transient | Large batch jobs that tolerate Spot interruptions | Amazon EMR on Amazon EC2 with Spot Instances | 
| Transient | Bursty Apache Spark or Apache Hive jobs | Amazon EMR Serverless | 
| Transient | Interactive SQL or notebooks with unpredictable usage | Amazon EMR Serverless | 

Instance selection also affects cost. Most clusters run on general-purpose instances. Compute-intensive clusters benefit from compute-optimized instances, and workloads such as databases, memory caching, and large shuffles benefit from memory-optimized instances. Match the family's vCPU-to-memory ratio to your workload. AWS Graviton-based instances offer better price-performance than equivalent x86 instances. For the instance types that Amazon EMR supports, see Supported instance types with Amazon EMR.

The primary node has low compute needs. For clusters of 50 or fewer nodes, use a general-purpose type for the primary node, and use a larger type for larger clusters. With Amazon EMR Serverless, you configure worker vCPU and memory at the application or job level and choose x86\_64 (the default) or arm64 (Graviton).

### Application settings
<a name="application-settings"></a>

Job performance depends on your application settings. For example, Amazon EMR clusters that run Apache HBase allocate half the memory to HBase and half to Apache Hadoop YARN. Do not run HBase and Spark on a single large cluster. Instead, run each on a separate, smaller cluster.

## Storage optimization
<a name="storage-optimization"></a>

Decouple compute and storage by using Amazon S3 as your persistent data store. Optimizing storage improves job performance, lets you use less hardware, and lets you run clusters for shorter periods. Use Amazon S3 Intelligent-Tiering to reduce storage costs further. Amazon EMR presents Amazon S3 as an HDFS-compatible layer, so your applications need no code changes.

On Amazon EMR on Amazon EC2, HDFS remains available for cases where local-disk performance matters. Consider HDFS for the following workloads.
+ Apache HBase tables that need sub-millisecond read latency, such as financial services, ad tech, fraud detection, and time-series workloads.
+ Apache Spark shuffle and spill data on shuffle-heavy jobs, such as large joins, aggregations, and sorts.
+ Iterative workloads that reuse intermediate data across steps.

HDFS does not persist beyond the cluster lifecycle, so it is not a substitute for Amazon S3 as a durable store.

### Partition data
<a name="partition-data"></a>

Partitioning a dataset by a column that your queries read reduces the amount of data scanned. For example, consider a 5 GB dataset of 12 million rows. The query against the partitioned dataset took 5.7 seconds, because Spark read only the partitions that matched by year, month, and day. The query against the non-partitioned dataset took 13.3 seconds, because it scanned all 5 GB.

![Chart comparing query performance on partitioned versus non-partitioned data.](https://docs.aws.amazon.com/whitepapers/latest/amazon-emr-migration-guide/images/figure2.png)


**Figure 2: Queries on partitioned and non-partitioned data**

### Optimize file sizes
<a name="optimize-file-sizes"></a>

Avoid files smaller than about 128 MB. Fewer, larger files reduce the number of Amazon S3 LIST requests. For example, for a same-size dataset, reading 50 files took 44 seconds, while reading 25,000 files took 233 seconds.

![Chart showing how query time varies with the number of files scanned.](https://docs.aws.amazon.com/whitepapers/latest/amazon-emr-migration-guide/images/figure3.png)


**Figure 3: Query time difference on number of files**

### Compress the dataset
<a name="compress-the-dataset"></a>

Compression reduces storage and network traffic. Use a splittable codec or an optimal file size so that Spark can process the data in parallel. Parquet and ORC compress by default. The following codecs are common choices.
+ **Snappy** — fast, with a moderate compression ratio. It is the default for Parquet in Spark and works well for hot data and query workloads.
+ **Zstandard (Zstd)** — higher compression ratios at comparable speed. It is the default for Apache Iceberg and works well for storage-optimized and large datasets.
+ **Gzip** — a high compression ratio, but not splittable on text such as CSV or JSON. Avoid Gzip on large text files because of the risk of out-of-memory errors. It is fine inside Parquet or ORC.

As an example, a Parquet dataset is about 5x smaller than the equivalent JSON dataset.

![Chart comparing storage and query performance for compressed and non-compressed datasets.](https://docs.aws.amazon.com/whitepapers/latest/amazon-emr-migration-guide/images/figure4.png)


**Figure 4: Compressed and non-compressed datasets**

### Optimize file formats
<a name="optimize-file-formats"></a>

Columnar formats such as Parquet and ORC improve read performance when your queries select a subset of columns. For queries that select all columns but a subset of rows, use a row format such as Apache Avro. For example, a select count(\*) over 12 million rows took 10 seconds against uncompressed JSON (5.7 GB) and 1.27 seconds against Parquet with Snappy (1.7 GB), about 8x faster.

![Chart comparing the performance of different data file formats.](https://docs.aws.amazon.com/whitepapers/latest/amazon-emr-migration-guide/images/figure5.png)


**Figure 5: Performance comparison of file formats**

These strategies apply to file-based tables in Amazon S3. Open table formats, such as Apache Iceberg, Apache Hudi, and Delta Lake, add ACID transactions, row-level updates, time travel, and schema evolution, and they manage partitioning, compaction, and metadata themselves. For a comparison of table formats, see [Incremental Data Processing](incremental-data-processing.md).

## Compute optimization
<a name="compute-optimization"></a>

Amazon EC2 provides On-Demand, Spot, and Reserved options. For more information, see Instance Purchasing Options in the Amazon EMR Management Guide.

### Spot Instances
<a name="spot-instances"></a>

Spot Instances offer spare Amazon EC2 capacity at a discount. They are not ideal for jobs with strict SLAs, but you can use them for interruptible or resumable workloads. A two-minute interruption warning lets your applications checkpoint their work, and Amazon EMR proactively decommissions task nodes so that YARN reschedules containers. Interruption rates vary by instance type, Region, and time, so monitor them with the AWS Spot Instance Advisor and the Spot placement score API. Use Instance fleets with the price-capacity-optimized allocation strategy and multiple instance types and Availability Zones. Combine Spot Instances for task nodes with On-Demand or Reserved Instances for primary and core nodes. Spot Instances are also well suited to testing and development.

### Reserved Instances
<a name="reserved-instances"></a>

Reserved Instances reserve Amazon EC2 capacity at a lower price. They are best for predictable needs matched to a specific instance family and Region. Your Reserved Instance utilization over a year must exceed about 70% to save money. For example, a transient cluster that runs 12 hours per day is only 50% utilized, so Reserved Instances might not help.

### Savings Plans
<a name="savings-plans"></a>

Savings Plans offer a flexible discount in exchange for a committed hourly compute spend over one or three years. Compute Savings Plans provide up to 66% savings and apply to any Amazon EC2 usage regardless of Region, instance family, operating system, or tenancy, including EMR clusters. EC2 Instance Savings Plans provide up to 72% savings for a specific instance family within a Region. AWS recommends Savings Plans as the default discount model for new commitments. Choose Reserved Instances only for a fixed instance configuration over the full term.

### Instance Fleets
<a name="instance-fleets"></a>

Instance fleets let you provision Spot, On-Demand, or a mix of both. You select a target capacity and a list of instance types and Availability Zones. You can also set a maximum Spot price, a provisioning timeout, and allocation strategies such as price-capacity-optimized. An instance fleet can span multiple Availability Zones and instance types.

### Amazon EMR Managed Scaling
<a name="emr-managed-scaling"></a>

Amazon EMR managed scaling continuously monitors cluster metrics and adds or removes core and task nodes. You set a minimum and a maximum cluster size. Managed scaling is available for Instance fleets or instance groups and supports YARN applications such as Spark, Hadoop, Hive, and Flink. It does not apply to HBase, Trino, or Presto, and it scales only core and task nodes.

#### Setting the scaling parameters
<a name="setting-scaling-parameters"></a>
+ **Minimum capacity** — the baseline that always runs. Size it to steady-state demand.
+ **Maximum capacity** — the ceiling. Size it to peak demand plus headroom within your budget.
+ **Maximum On-Demand capacity** — limits the On-Demand portion. Capacity above this limit goes to Spot Instances. A common pattern matches this value to the minimum capacity so that the baseline is On-Demand and scale-up uses Spot Instances.
+ **Maximum core capacity** — limits the core nodes that store HDFS data. Size it to your HDFS needs so that scale-out uses task nodes.

#### Validating managed scaling for your workload
<a name="validating-managed-scaling"></a>

Amazon EMR publishes one-minute CloudWatch metrics that you can use to validate your scaling configuration.
+ Monitor `TotalUnitsRequested`, `TotalNodesRequested`, and `TotalVCPURequested`, which represent target capacity. A persistent gap versus the actual capacity means that scale-up lags.
+ Monitor `ContainerPending`, which represents queued YARN work. A sustained high value means the cluster is undersized, so consider raising the maximum. A value near zero means you have enough capacity.
+ With Amazon EMR 7.3 and later, also monitor `YarnContainersUsedMemoryGBSeconds` and `YarnContainersTotalMemoryGBSeconds`. Their ratio shows memory utilization. A low ratio at steady state means you can lower the minimum capacity.
+ With Amazon EMR 7.3 and later, also monitor `YarnNodesUsedVCPUSeconds` and `YarnNodesTotalVCPUSeconds`, which show vCPU utilization.

For more information, see Using managed scaling in Amazon EMR in the Amazon EMR Management Guide.

#### When to use Advanced Scaling
<a name="when-to-use-advanced-scaling"></a>

Starting with Amazon EMR 7.0, Advanced Scaling adds a utilization-performance index that balances cost against job completion speed. Set the index to 1, 25, 50, 75, or 100. A value of 1 (utilization optimized) prioritizes cost. A value of 50 (balanced) is the starting point that AWS recommends. A value of 100 (performance optimized) prioritizes performance for SLA-sensitive workloads. For more information, see Advanced Scaling for Amazon EMR in the Amazon EMR Management Guide.

## Cost estimation summary
<a name="cost-estimation-summary"></a>

The cost components differ by deployment option.
+ **Amazon EMR on Amazon EC2** — EMR cost, EC2 instance cost, and EBS volume cost (if you use EBS).
+ **Amazon EMR on Amazon EKS** — EMR cost (billed on vCPU and memory per pod), EKS cluster cost, and the underlying EC2 cost for worker nodes.
+ **Amazon EMR Serverless** — vCPU-hour, memory-GB-hour, and storage-GB-hour costs.

**Note**  
Amazon EMR uses per-second pricing, so a 10-node cluster that runs for 10 hours costs about the same as a 100-node cluster that runs for 1 hour. The hourly rate depends on the instance type. For more information, see [Amazon EMR pricing](https://aws.amazon.com/emr/pricing/).

## Optimizing Apache Hadoop YARN-based applications
<a name="optimizing-yarn-applications"></a>

YARN-based applications give you several controls that affect both performance and cost. This section explains how YARN manages resources and how to tune and monitor your cluster.

### Apache Hadoop YARN and job optimization
<a name="yarn-and-job-optimization"></a>

YARN is the resource management and job scheduling technology in open-source Hadoop. Nodes register with YARN and provide virtual memory and vCPU, and the total cluster resources are the sum of the participating nodes. Ideally, the YARN memory and CPU closely match the underlying hardware. On Amazon EMR on Amazon EC2, defaults are provided for each node. For more information, see Task Configuration in the Amazon EMR Release Guide.

A job runs subsets of its work in containers, called tasks. The job requests memory and CPU for each container. A container that is sized incorrectly wastes resources, runs slowly, or fails. You must consider both the YARN resources and the job requests. YARN manages virtual resources that do not necessarily map to the hardware, and both the YARN and the task-scheduler configuration affect how the hardware is used.

### Optimizing and monitoring your cluster
<a name="optimizing-and-monitoring-cluster"></a>

First, make sure that YARN is optimized. If containers are constantly available, you can shrink the cluster. Amazon EMR emits a `ContainerPending` metric to CloudWatch. A constant queue of container requests means that increasing the cluster size helps.

Next, monitor the physical hardware by using the CloudWatch agent. If 100% of the YARN resources (vCPU and memory) are used but the actual CPU and memory usage is below 80%, reduce the container size to run more concurrent containers. If either CPU or memory is at 100% while the other is underused, move to a better-fit instance type. For example, if CPU is at 100% and memory is below 50% on a memory-optimized or general-purpose instance, move to a compute-optimized instance.

Amazon EMR sends basic cluster metrics to CloudWatch every 5 minutes at no cost. Amazon EMR 7.0 and later include the CloudWatch agent, which reports per-node vCPU, memory, disk, and network metrics at 1-minute intervals. Amazon EMR 7.1 and later add application-specific metrics for Hadoop, YARN, and HBase. Additional CloudWatch charges apply when you enable these metrics.

To enable the agent, do the following at cluster creation.
+ Select Amazon CloudWatch Agent in Applications.
+ Attach an Amazon EMR configuration classification that lists the components and metrics. See the JSON format reference.
+ Attach a bootstrap action to forward specific YARN, HDFS, and Spark logs to CloudWatch Logs.

The Amazon EMR console Monitoring tab renders these metrics. You can filter by the HDFS, YARN, HBase, or Custom classifications.

![Screenshot of default Amazon EMR cluster-status metrics in the EMR console.](https://docs.aws.amazon.com/whitepapers/latest/amazon-emr-migration-guide/images/figure6.png)


**Figure 6: Default Amazon EMR cluster-status metrics in the EMR console**

The default cluster-status metrics show YARN container and step counts, which reflect what YARN was asked to do rather than the physical work. The CloudWatch agent efficiency panels overlay YARN allocation (`AllocatedVCores` and `CapabilityVirtualCores`) against physical usage (`cpu_usage_user` and `mem_used_percent`). When YARN allocation is near 100% while physical usage stays low, that is the signal to shrink container sizes, shown with UnderUsage 40 and OverUsage 90 bands. This view requires Amazon EMR 7.1 and later with the AmazonCloudWatchAgent application and the emr-metrics classification. The managed-scaling panel shows YARN nodes against the Min and Max settings, with instance launches and terminations and step boundaries. Sustained running at Max means the ceiling throttles throughput, and long stretches near Min with containers pending mean the scaling policy reacts too slowly. For more information about enhanced monitoring with the Amazon CloudWatch agent on Amazon EMR 7.x, see [EMR Observability](emr-observability.md).

![CloudWatch agent dashboard comparing YARN resource allocation against physical utilization.](https://docs.aws.amazon.com/whitepapers/latest/amazon-emr-migration-guide/images/figure7.png)


**Figure 7: CloudWatch agent dashboard — YARN allocation versus physical utilization**

![CloudWatch agent dashboard showing cluster utilization under managed scaling.](https://docs.aws.amazon.com/whitepapers/latest/amazon-emr-migration-guide/images/figure8.png)


**Figure 8: CloudWatch agent dashboard — cluster utilization under managed scaling**

### Tuning controls for cluster optimization
<a name="tuning-controls-cluster-optimization"></a>

You have two controls for tuning a cluster. The first is the resources that each container uses. Change the default container sizes through Amazon EMR Application Configuration, and make sure that the container size is a multiple of the total YARN resources. The second is the virtual resources that each node can reserve. Set `yarn.nodemanager.resource.memory-mb` and `yarn.nodemanager.resource.cpu-vcores` through the Amazon EMR configuration API. For more information, see Hadoop Daemon Configuration Settings in the Amazon EMR Release Guide.

When you use Instance fleets with mixed instance families and sizes, the Amazon EMR runtime for Apache Spark uses heterogeneous executors by default (`spark.yarn.heterogeneousExecutors.enabled=true`), which lets Spark calculate executor sizes for each instance. For homogeneous fleets or instance groups, set this property to false and configure the executor sizes explicitly.

The following decision logic summarizes how to respond to what you observe.
+ If YARN utilization is at 100% but physical CPU and memory are below 80%, reduce the container size to increase concurrency.
+ If either CPU or memory is saturated while the other is underused, move to a better-fit instance family.
+ If there is a constant container queue with no idle capacity, scale the cluster up.

![Decision chart outlining the steps for optimizing job performance.](https://docs.aws.amazon.com/whitepapers/latest/amazon-emr-migration-guide/images/figure9.png)


**Figure 9: Job optimization decision chart**

You can monitor pod utilization through Amazon CloudWatch Container Insights. Under-utilized pods are over-allocated, and pods that hit their limits are under-allocated. For the vCPU-to-memory ratio, use 1:2 for compute-intensive workloads, 1:4 (the default) for general-purpose workloads, and 1:8 for memory-intensive workloads such as large shuffles and joins. With Amazon EMR Serverless, you configure the worker size with `spark.emr-serverless.driver.cores`, `spark.emr-serverless.driver.memory`, `spark.emr-serverless.executor.cores`, and `spark.emr-serverless.executor.memory`.