Best Way to Modify EC2 Instance Type for Improved Application Performance | AWS DevOps Exam

Improve Application Performance by Modifying EC2 Instance Type

Prev Question Next Question

Question

You are developing a Java application that is deployed in AWS by an Auto Scaling Group.

The EC2 instances belong to the m5.large type.

Recently, due to several newly added features, the response time of the application increased because of the high CPU usage rate.

You need to modify the EC2 instance type to c5.large to remedy this issue.

What is the best way to implement this?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer - B.

One main feature for Auto Scaling configuration is that it cannot be modified after being created.

To change the launch configuration, the best practice is to use an existing one as the basis for a new configuration and then update the ASG to use the new one.

Option A is incorrect: Because the instance type belongs to the domain of launch configuration rather than Auto Scaling Group itself.

Option B is CORRECT: Because the user can select the existing configuration, copy it to a new one, and then modify the instance type.

With this approach, the user does not need to configure everything from scratch.

Refer to https://docs.aws.amazon.com/autoscaling/ec2/userguide/change-launch-config.html for more details.

Option C is incorrect: Because this approach only works temporarily.

After the instance is terminated, ASG still uses the m5.large instance type for any new instances.

Option D is incorrect: Because existing Auto Scaling launch configurations cannot be modified.

Resources:

GetHelloWorld:
Type: AWS: :Serverless: : Function
Properties:
Handler: index.get
Runtime: nodejs8.10
Role:
Fn::GetAtt:
- LambdaExecutionRole
- Arn
Events:
GetEvent:
Type: Api
Properties:
Path: /
Method: get
LambdaExecutionRole:
Description: Creating service role in IAM for AWS Lambda
Type: AWS: :IAM::Role
Properties:
RoleName: !Sub 'CodeStar-${ProjectId}-Execution${Stage}'

The best way to modify the EC2 instance type for an Auto Scaling Group would be option D - "Select the Auto Scaling launch configuration and choose “Actions -> Change Instance Type”. Modify the instance type to c5.large accordingly." Here's a detailed explanation of why:

Auto Scaling Groups are used to automatically scale the number of EC2 instances in response to changes in demand for your application. The group maintains a specified number of instances (the minimum, maximum, and desired capacity) and automatically increases or decreases this number in response to changes in demand. The instances launched by the Auto Scaling Group are based on a launch configuration, which defines the settings for the instances, including the instance type.

Option A - "In AWS console, edit the Auto Scaling Group by modifying the instance type from m5.large to c5.large" - is not the best way to implement the change because it involves manually editing the Auto Scaling Group, which could lead to errors and is not scalable or repeatable. In addition, editing the Auto Scaling Group directly could result in downtime for your application as it may terminate existing instances and launch new ones with the new instance type.

Option B - "Select the relevant launch configuration and choose “Actions -> Copy launch configuration”. Modify the instance type accordingly in the new configuration. Select the new launch configuration for the Auto Scaling Group" - is a better option than Option A, as it involves creating a new launch configuration with the desired instance type and then selecting it for the Auto Scaling Group. However, it still involves manual steps and could lead to errors or downtime.

Option C - "In AWS EC2 console, stop the EC2 instances, modify the instance type to c5.large in “Instance Settings -> Change Instance Type” and then start the instances" - is not a good option because it involves manually stopping and starting the instances, which could result in downtime for your application. In addition, it only changes the instance type for the specific instances, not for the entire Auto Scaling Group.

Option D - "Select the Auto Scaling launch configuration and choose “Actions -> Change Instance Type”. Modify the instance type to c5.large accordingly" - is the best option because it involves modifying the launch configuration directly, which is a repeatable and scalable process. The change will automatically apply to all new instances launched by the Auto Scaling Group, and existing instances will not be terminated, so there will be no downtime.

To summarize, Option D is the best option for modifying the EC2 instance type for an Auto Scaling Group because it is repeatable, scalable, and does not result in downtime for your application.