forked from awslabs/ec2-spot-workshops
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding FIS to the EMR Workshop awslabs#187
- Loading branch information
Showing
17 changed files
with
423 additions
and
96 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
content/running_spark_apps_with_emr_on_spot_instances/analyzing_costs.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
content/running_spark_apps_with_emr_on_spot_instances/automations_monitoring.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 20 additions & 26 deletions
46
...spot_instances/conclusions_and_cleanup.md → ...ith_emr_on_spot_instances/calltoaction.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,20 @@ | ||
--- | ||
title: "Conclusions and cleanup" | ||
weight: 150 | ||
--- | ||
|
||
**Congratulations!** you have reached the end of the workshop. In this workshop, you learned about the need to be flexible with EC2 instance types when using Spot Instances, and how to size your Spark executors to allow for this flexibility. You ran a Spark application solely on Spot Instances using EMR Instance Fleets, you verified the results of the application, and saw the cost savings that you achieved by running the application on Spot Instances. | ||
|
||
|
||
#### Cleanup | ||
|
||
Select the correct tab, depending on where you are running the workshop: | ||
{{< tabs name="EventorOwnAccount" >}} | ||
{{< tab name="In your own account" include="cleanup_ownaccount" />}} | ||
{{< tab name="In an AWS event" include="cleanup_event.md" />}} | ||
{{< /tabs >}} | ||
|
||
|
||
#### Thank you | ||
|
||
We hope you found this workshop educational, and that it will help you adopt Spot Instances into your Spark applications running on Amazon EMR, in order to optimize your costs. | ||
If you have any feedback or questions, click the "**Feedback / Questions?**" link in the left pane to reach out to the authors of the workshop. | ||
|
||
#### Other Resources: | ||
Visit the [**Amazon EMR on EC2 Spot Instances**](https://aws.amazon.com/ec2/spot/use-case/emr/) page for more information, customer case studies and videos. | ||
Read the blog post: [**Best practices for running Apache Spark applications using Amazon EC2 Spot Instances with Amazon EMR**](https://aws.amazon.com/blogs/big-data/best-practices-for-running-apache-spark-applications-using-amazon-ec2-spot-instances-with-amazon-emr/) | ||
Watch the AWS Online Tech-Talk: [**Best Practices for Running Spark Applications Using Spot Instances on EMR - AWS Online Tech Talks**](https://www.youtube.com/watch?v=u5dFozl1fW8) | ||
--- | ||
title: "Call to Action" | ||
weight: 170 | ||
--- | ||
|
||
**Congratulations!** you have reached the end of the workshop. In this workshop, you learned about the need to be flexible with EC2 instance types when using Spot Instances, and how to size your Spark executors to allow for this flexibility. You ran a Spark application solely on Spot Instances using EMR Instance Fleets, you verified the results of the application, and saw the cost savings that you achieved by running the application on Spot Instances. | ||
|
||
#### Thank you | ||
|
||
We hope you found this workshop educational, and that it will help you adopt Spot Instances into your Spark applications running on Amazon EMR, in order to optimize your costs. | ||
If you have any feedback or questions, click the "**Feedback / Questions?**" link in the left pane to reach out to the authors of the workshop. | ||
|
||
#### Other Resources: | ||
Visit the [**Amazon EMR on EC2 Spot Instances**](https://aws.amazon.com/ec2/spot/use-case/emr/) page for more information, customer case studies and videos. | ||
|
||
Read the blog post: [**Best practices for running Apache Spark applications using Amazon EC2 Spot Instances with Amazon EMR**](https://aws.amazon.com/blogs/big-data/best-practices-for-running-apache-spark-applications-using-amazon-ec2-spot-instances-with-amazon-emr/) | ||
|
||
Watch the AWS Online Tech-Talk: | ||
|
||
{{< youtube u5dFozl1fW8 >}} |
13 changes: 13 additions & 0 deletions
13
content/running_spark_apps_with_emr_on_spot_instances/cleanup.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: "Cleanup" | ||
weight: 150 | ||
--- | ||
|
||
#### Cleanup | ||
|
||
Select the correct tab, depending on where you are running the workshop: | ||
{{< tabs name="EventorOwnAccount" >}} | ||
{{< tab name="In your own account" include="cleanup_ownaccount" />}} | ||
{{< tab name="In an AWS event" include="cleanup_event.md" />}} | ||
{{< /tabs >}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
content/running_spark_apps_with_emr_on_spot_instances/simulating_recovery.md
This file was deleted.
Oops, something went wrong.
111 changes: 111 additions & 0 deletions
111
...t/running_spark_apps_with_emr_on_spot_instances/spot_interruption_experiment.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
--- | ||
title: "Creating the Spot Interruption Experiment" | ||
weight: 97 | ||
--- | ||
|
||
In this section, you're going to start creating the experiment to [trigger the interruption of Amazon EC2 Spot Instances using AWS Fault Injection Simulator (FIS)](https://aws.amazon.com/blogs/compute/implementing-interruption-tolerance-in-amazon-ec2-spot-with-aws-fault-injection-simulator/). When using Spot Instances, you need to be prepared to be interrupted. With FIS, you can test the resiliency of your workload and validate that your application is reacting to the interruption notices that EC2 sends before terminating your instances. You can target individual Spot Instances or a subset of instances in clusters managed by services that tag your instances such as ASG, Fleet and EMR. | ||
|
||
You're going to use the CLI, so launch your terminal to run the commands included in this section. | ||
|
||
#### What do you need to get started? | ||
|
||
Before you start launching Spot interruptions with FIS, you need to create an experiment template. Here is where you define which resources you want to interrupt (targets), and when you want to interrupt the instance. | ||
|
||
You're going to use the following CloudFormation template which creates the IAM role (`FISSpotRole`) with the minimum permissions FIS needs to interrupt an instance, and the experiment template (`FISExperimentTemplate`) you're going to use to trigger a Spot interruption: | ||
|
||
``` | ||
AWSTemplateFormatVersion: 2010-09-09 | ||
Description: FIS for Spot Instances | ||
Parameters: | ||
InstancesToInterrupt: | ||
Description: Number of instances to interrupt | ||
Default: 3 | ||
Type: Number | ||
DurationBeforeInterruption: | ||
Description: Number of minutes before the interruption | ||
Default: 2 | ||
Type: Number | ||
Resources: | ||
FISSpotRole: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
AssumeRolePolicyDocument: | ||
Statement: | ||
- Effect: Allow | ||
Principal: | ||
Service: [fis.amazonaws.com] | ||
Action: ["sts:AssumeRole"] | ||
Path: / | ||
Policies: | ||
- PolicyName: root | ||
PolicyDocument: | ||
Version: "2012-10-17" | ||
Statement: | ||
- Effect: Allow | ||
Action: 'ec2:DescribeInstances' | ||
Resource: '*' | ||
- Effect: Allow | ||
Action: 'ec2:SendSpotInstanceInterruptions' | ||
Resource: 'arn:aws:ec2:*:*:instance/*' | ||
FISExperimentTemplate: | ||
Type: AWS::FIS::ExperimentTemplate | ||
Properties: | ||
Description: "Interrupt multiple random instances" | ||
Targets: | ||
SpotIntances: | ||
ResourceTags: | ||
ResourceTagKey: ResourceTagValue | ||
Filters: | ||
- Path: State.Name | ||
Values: | ||
- running | ||
ResourceType: aws:ec2:spot-instance | ||
SelectionMode: !Join ["", ["COUNT(", !Ref InstancesToInterrupt, ")"]] | ||
Actions: | ||
interrupt: | ||
ActionId: "aws:ec2:send-spot-instance-interruptions" | ||
Description: "Interrupt multiple Spot instances" | ||
Parameters: | ||
durationBeforeInterruption: !Join ["", ["PT", !Ref DurationBeforeInterruption, "M"]] | ||
Targets: | ||
SpotInstances: SpotIntances | ||
StopConditions: | ||
- Source: none | ||
RoleArn: !GetAtt FISSpotRole.Arn | ||
Tags: | ||
Name: "FIS_EXP_NAME" | ||
Outputs: | ||
FISExperimentID: | ||
Value: !GetAtt FISExperimentTemplate.Id | ||
``` | ||
|
||
Here are some important notes about the template: | ||
|
||
* You can configure how many instances you want to interrupt with the `InstancesToInterrupt` parameter. In the template it's defined that it's going to interrupt **three** instances. | ||
* You can also configure how much time you want the expriment to run with the `DurationBeforeInterruption` parameter. By default, it's going to take two minutes. This means that as soon as you launch the experiment, the instance is going to receive the two-minute notification Spot interruption warning. | ||
* The most important section is the `Targets` from the experiment template. The template has two placeholders `ResourceTagKey` and `ResourceTagValue` which are basically the key/value for the tags to use when choosing the instances to interrupt. We're going to run a `sed` command to replace them with the proper values for this workshop. | ||
* Notice that instances are **chosen randomly**, and only those who are in the `running` state. | ||
|
||
#### Create the EC2 Spot Interruption Experiment with FIS | ||
|
||
Let's continue by creating the Spot interruption experiment template using Cloudformation. You can view the CloudFormation template (**fisspotinterruption.yaml**) at GitHub [here](https://raw.githubusercontent.com/awslabs/ec2-spot-workshops/master/workshops/fis/fisspotinterruption.yaml). To download it, you can run the following command: | ||
|
||
``` | ||
wget https://raw.githubusercontent.com/awslabs/ec2-spot-workshops/master/workshops/fis/fisspotinterruption.yaml | ||
``` | ||
|
||
Now, simply run the following commands to create the FIS experiment: | ||
|
||
``` | ||
export FIS_EXP_NAME=fis-spot-interruption | ||
sed -i -e "s#ResourceTagKey#aws:elasticmapreduce:instance-group-role#g" fisspotinterruption.yaml | ||
sed -i -e "s#ResourceTagValue#TASK#g" fisspotinterruption.yaml | ||
sed -i -e "s#FIS_EXP_NAME#$FIS_EXP_NAME#g" fisspotinterruption.yaml | ||
aws cloudformation create-stack --stack-name $FIS_EXP_NAME --template-body file://fisspotinterruption.yaml --capabilities CAPABILITY_NAMED_IAM | ||
aws cloudformation wait stack-create-complete --stack-name $FIS_EXP_NAME | ||
``` |
Oops, something went wrong.