Lesson 4 of 10Platform levers3 min read

Spot capacity for Spark on Amazon EMR

Spot Instances are spare EC2 capacity that AWS prices at up to a 90% discount to On-Demand, and they can be taken back. AWS's EMR guidance puts Spot on task nodes, lets application masters run only on core nodes so jobs survive Spot loss, and keeps the primary node off Spot unless sudden termination is acceptable. The saving is on the instance rate; the risk shows up as reruns.

By The Meter DeskSpark Cost ComparePublished

What does Spot change on the bill?

Spot acts on one lever: the price of the instances. AWS's EMR pricing page states: "Spot Instances are spare EC2 capacity available at up to a 90% discount compared to On-Demand prices." The job runs for the same time on the same number of nodes; each node simply costs less per second. "Up to" matters here: the discount varies by instance type, region and time.

Which nodes should run on Spot?

An EMR cluster has three node roles. The primary node runs the cluster's coordination services. Core nodes run tasks and hold HDFS data. Task nodes run tasks only. AWS's instance guidelines for EMR describe task nodes as the usual place for Spot, because losing one does not lose stored data.

AWS also describes a setting that lets application master processes run only on core nodes. In Spark on YARN the application master coordinates the job; if it sits on a Spot node that is reclaimed, the whole application can fail. Keeping it on core nodes means a reclaimed task node costs you that node's work, not the job.

On the primary node the guidance is plain: run it on Spot only if sudden termination of the cluster is acceptable.

Where does Spot cost you money back?

When a Spot node is reclaimed, the tasks it was running are rescheduled, and shuffle output it held may need to be recomputed. That is the fourth lever, reruns, working against you. For short, restartable jobs the trade is usually easy. For long jobs with large shuffles, measure runtime variance on Spot before you count the full discount as savings.

How does Spot interact with accelerators?

An accelerator that needs a specific instance family limits your Spot options to that family. Engines that run on standard CPU instances leave the choice open. GPU-based acceleration on EMR needs GPU instance types for core and task nodes. Check Spot availability for the exact instance type before you plan around both levers together.

What should you check before switching?

  1. Which jobs can tolerate a rerun, and which have deadlines.
  2. Whether application masters are confined to core nodes.
  3. Runtime variance across a week of Spot runs, not a single run.
  4. The real discount for your instance types in your region, from your own bill.

Spot pairs naturally with managed scaling, which decides how many task nodes you need at a given moment.

Sources