Using an auto-termination policy
An auto-termination policy lets you orchestrate cluster cleanup without the need to monitor and manually terminate unused clusters. When you add an auto-termination policy to a cluster, you specify the amount of idle time after which the cluster should automatically shut down.
Depending on release version, Amazon EMR uses different criteria to mark a cluster as idle. The following table outlines how Amazon EMR determines cluster idleness.
When you use ... | A cluster is considered idle when ... |
---|---|
Amazon EMR versions 6.4.0 and later |
|
Amazon EMR versions 5.30.0 - 5.33.0 and 6.1.0 - 6.3.0 |
Amazon EMR marks a cluster as idle and may automatically terminate the cluster even if you have an active Python3 kernel. This is because executing a Python3 kernel does not submit a Spark job on the cluster. To use auto-termination with a Python3 kernel, we recommend that you use Amazon EMR version 6.4.0 or later. |
Amazon EMR versions 6.4.0 and later support an on-cluster file for detecting activity
on the master node: /emr/metricscollector/isbusy
. When you use
a cluster to run shell scripts or non-YARN applications, you can periodically touch
or update isbusy
to tell Amazon EMR that the cluster is not idle.
You can attach an auto-termination policy when you create a cluster, or add a policy to an existing cluster. To change or disable auto-termination, you can update or remove the policy.
Considerations
Consider the following features and limitations before using an auto-termination policy:
-
Auto-termination is supported with Amazon EMR versions 5.30.0 and 6.1.0 and later.
-
Auto-termination is available in the following AWS Regions: US East (N. Virginia, Ohio), US West (N. California, Oregon), Asia Pacific (Mumbai, Seoul, Singapore, Sydney, Tokyo, Hong Kong), Canada (Central), China (Beijing, Ningxia), Europe (Ireland, Frankfurt, London, Paris, Stockholm, Milan), South America (São Paulo), Middle East (Bahrain), and Africa (Cape Town).
-
Idle timeout defaults to 60 minutes (one hour) when you don't specify an amount. You can specify a minimum idle timeout of one minute, and a maximum idle timeout of 7 days.
-
With Amazon EMR versions 6.4.0 and later, auto-termination is enabled by default when you create a new cluster using the Amazon EMR console.
-
Amazon EMR publishes high-resolution Amazon CloudWatch metrics when you enable auto-termination for a cluster. You can use these metrics to track cluster activity and idleness. For more information, see Cluster capacity metrics.
-
Auto-termination is not supported when you use non-YARN based applications such as Presto, Trino, or HBase.
-
To use auto-termination, the metrics-collector process must be able to connect to the public API endpoint for auto-termination in API Gateway. If you use a private DNS name with Amazon Virtual Private Cloud, auto-termination won't function properly. To ensure that auto-termination works, we recommend that you take one of the following actions:
-
Remove the API Gateway interface VPC endpoint from your Amazon VPC.
-
Follow the instructions in Why do I get an HTTP 403 Forbidden error when connecting to my API Gateway APIs from a VPC?
to disable the private DNS name setting. -
Launch your cluster in a private subnet instead. For more information, see the topic on Private subnets.
-
-
(EMR 5.30.0 and later) If you remove the default Allow All outbound rule to 0.0.0.0/ for the master security group, you must add a rule that allows outbound TCP connectivity to your security group for service access on port 9443. Your security group for service access must also allow inbound TCP traffic on port 9443 from the master security group. For more information about configuring security groups, see Amazon EMR-managed security group for the master instance (private subnets).
Permissions to use auto-termination
Before you can apply and manage auto-termination policies for Amazon EMR, you need the permissions that are listed in the following example IAM permissions policy.
{ "Version": "2012-10-17", "Statement": { "Sid": "AllowAutoTerminationPolicyActions", "Effect": "Allow", "Action": [ "elasticmapreduce:PutAutoTerminationPolicy", "elasticmapreduce:GetAutoTerminationPolicy", "elasticmapreduce:RemoveAutoTerminationPolicy" ], "Resource": "
<your-resources>
" } }
Attach, update, or remove an auto-termination policy
This section includes instructions to help you attach, update, or remove an auto-termination policy from an Amazon EMR cluster. Before you work with auto-termination policies, make sure you have the necessary IAM permissions. See Permissions to use auto-termination.