Amazon EMR integration with EC2 placement groups
When you launch an Amazon EMR multiple primary node cluster on Amazon EC2, you have the option to use placement group strategies to specify how you want the primary node instances deployed to protect against hardware failure.
Placement group strategies are supported starting with Amazon EMR version 5.23.0 as an
option for multiple primary node clusters. Currently, only primary node types
are supported by the placement group strategy, and the SPREAD
strategy is
applied to those primary nodes. The SPREAD
strategy places a small
group of instances across separate underlying hardware to guard against the loss of
multiple primary nodes in the event of a hardware failure. Note that an instance
launch request could fail if there is insufficient unique hardware to fulfill the
request. For more information about EC2 placement strategies and limitations, see Placement
groups in the EC2 User Guide for Linux
Instances.
There is an initial limit from Amazon EC2 of 500 placement group strategy-enabled clusters that can be launched per AWS region. Contact AWS support to request an increase in the number of allowed placement groups. You can identify EC2 placement groups Amazon EMR creates by tracking the key-value pair that Amazon EMR associates with the Amazon EMR placement group strategy. For more information about EC2 cluster instance tags, see View cluster instances in Amazon EC2.
Attach the placement group managed policy to the Amazon EMRrole
The placement group strategy requires a managed policy called
AmazonElasticMapReducePlacementGroupPolicy
, which allows Amazon EMR to
create, delete, and describe placement groups on Amazon EC2. You must attach
AmazonElasticMapReducePlacementGroupPolicy
to the service role for
Amazon EMR before you launch an Amazon EMR cluster with multiple primary nodes.
You can alternatively attach the AmazonEMRServicePolicy_v2
managed
policy to the Amazon EMR service role instead of the placement group managed policy.
AmazonEMRServicePolicy_v2
allows the same access to placement
groups on Amazon EC2 as the AmazonElasticMapReducePlacementGroupPolicy
. For
more information, see Service role for Amazon EMR (EMR role).
The AmazonElasticMapReducePlacementGroupPolicy
managed policy is the
following JSON text that is created and administered by Amazon EMR.
Note
Because the AmazonElasticMapReducePlacementGroupPolicy
managed
policy is updated automatically, the policy shown here may be out-of-date. Use
the AWS Management Console to view the current policy.
{ "Version":"2012-10-17", "Statement":[ { "Resource":"*", "Effect":"Allow", "Action":[ "ec2:DeletePlacementGroup", "ec2:DescribePlacementGroups" ] }, { "Resource":"arn:aws:ec2:*:*:placement-group/pg-*", "Effect":"Allow", "Action":[ "ec2:CreatePlacementGroup" ] } ] }
Launch an Amazon EMR cluster with multiple primary nodes using placement group strategy
To launch an Amazon EMR cluster that has multiple primary nodes with a placement group
strategy, attach the placement group managed policy
AmazonElasticMapReducePlacementGroupPolicy
to the Amazon EMR role. For
more information, see Attach the placement group managed
policy to the Amazon EMRrole.
Every time you use this role to start an Amazon EMR cluster with multiple primary
nodes, Amazon EMR attempts to launch a cluster with SPREAD
strategy applied
to its primary nodes. If you use a role that does not have the placement group
managed policy AmazonElasticMapReducePlacementGroupPolicy
attached to
it, Amazon EMR attempts to launch an Amazon EMR cluster that has multiple primary nodes
without a placement group strategy.
If you launch an Amazon EMR cluster that has multiple primary nodes with the
placement-group-configs
parameter using the Amazon EMRAPI or CLI, Amazon EMR
only launches the cluster if the Amazon EMRrole has the placement group managed policy
AmazonElasticMapReducePlacementGroupPolicy
attached. If the
Amazon EMRrole does not have the policy attached, the Amazon EMR cluster with multiple primary
nodes start fails.
Launch a cluster with multiple primary nodes without a placement group strategy
For a cluster with multiple primary nodes to launch primary nodes without the placement group strategy, you need to do one of the following:
-
Remove the placement group managed policy
AmazonElasticMapReducePlacementGroupPolicy
from the Amazon EMRrole, or -
Launch a cluster with multiple primary nodes with the
placement-group-configs
parameter using the Amazon EMRAPI or CLI choosingNONE
as the placement group strategy.
Checking placement group strategy configuration attached to the cluster with multiple primary nodes
You can use the Amazon EMR describe cluster API to see the placement group strategy configuration attached to the cluster with multiple primary nodes.
aws emr describe-cluster --cluster-id "j-xxxxx" { "Cluster":{ "Id":"j-xxxxx", ... ... "PlacementGroups":[ { "InstanceRole":"MASTER", "PlacementStrategy":"SPREAD" } ] } }