# EC2

Sedai intelligently recommends optimizations for your EC2 instances. These recommendations are made for individual virtual machines (VMs), as well as VMs grouped by load balancers or tags.

## Cost Optimization for Individual VMs

Sedai helps reduce your costs for individual VMs by generating recommendations to switch **instance types**. Proposed changes will reduce your average monthly spend and on-demand costs, as well as optimize CPU and memory usage.

While autonomous mode is not supported for Individual EC2 instance recommendations, you can review optimization opportunities in the **Opportunities** page and submit recommendations for execution. You can also make instance configuration changes in the AWS console by taking the following steps:&#x20;

1. Sign in to the **AWS Management Console** using your AWS account credentials.
2. Open the **EC2 Console** by searching for "EC2" in the search bar and selecting it.
3. On the left-hand sidebar in the EC2 console, click on **Instances**.
4. Locate the instance you want to change, and stop the instance if it's currently running. You can do this by clicking the checkbox next to the instance name then selecting the **Instance State** dropdown menu and choosing **Instance Settings > Stop Instance**.
5. After stopping the instance, select it again and click the **Actions** dropdown. Select **Instance Settings > Change Instance Type.**
6. In the **Change Instance Type** dialog box, you will see a dropdown with a list of available instance types. Choose the instance type Sedai has recommended.
7. Once you've selected the new instance type, click **Apply**.
8. Go back to the list of instances and select the one you modified. Click the **Instance State** dropdown, where you can choose **Start Instance** to restart your EC2 instance with the new instance type.

## Cost Optimization for Grouped VMs

Sedai detects VMs grouped together by either load balancers or cloud provider tags and generates recommendations to decrease costs. This is achieved by:

1. &#x20;**Changing the total number of instances:** Sedai may recommend changing the total number of instances in a VM group to help optimize resource allocation and costs.
2. **Switching Instance Types:** Sedai may suggest changing instance types within a VM group based on workload and utilization patterns.

Autonomous execution is not currently supported for VM groups but will be available soon. Until then, you can make changes in the AWS console.

{% hint style="info" %}
To view optimization opportunities for EC2 instances, go to Optimization > Opportunities and select the Virtual Machines tab.
{% endhint %}

## Enabling Memory Metrics

While memory metrics are not available by default for EC2, Sedai recommends enabling these metrics for improved EC2 optimizations. You can do this by installing the CloudWatch agent using the[ command line](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/installing-cloudwatch-agent-commandline.html) or the[ AWS Systems Manager](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/installing-cloudwatch-agent-ssm.html). You can also install the agent on new instances using a[ CloudFormation template](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent-New-Instances-CloudFormation.html).

Once you've installed the agent, Sedai will use memory metrics to generate optimal configurations you can apply to your instances for cost savings or performance improvements. You can view collected memory metrics from the Metrics page of your CloudWatch console.&#x20;

To learn more about using the CloudWatch agent for memory metrics, visit[ CloudWatch Agent docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html).

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sedai.io/get-started/platform/optimization/aws/ec2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
