# EC2

This page describes the Optimization Pack for AWS EC2.

## Metrics <a href="#metrics" id="metrics"></a>

### CPU and Networking

| Name                         | Unit    | Description                                                                                                     |
| ---------------------------- | ------- | --------------------------------------------------------------------------------------------------------------- |
| cpu\_util                    | percent | The average CPU utilization % across all the CPUs (i.e., how much time on average the CPUs are busy doing work) |
| network\_in\_bytes\_details  | bytes/s | The number of inbound network packets in bytes per second broken down by network device (e.g., wlp4s0)          |
| network\_out\_bytes\_details | bytes/s | The number of outbound network packets in bytes per second broken down by network device (e.g., eth01)          |

### Disks

| Name                         | Unit    | Description                                                                           |
| ---------------------------- | ------- | ------------------------------------------------------------------------------------- |
| disk\_read\_bytes            | bytes/s | The number of bytes per second read across all disks                                  |
| disk\_write\_bytes           | bytes/s | The number of bytes per second written across all disks                               |
| aws\_ec2\_disk\_iops\_reads  | ops/s   | The per second average number of EBS IO disk-read operations summed across all disks  |
| aws\_ec2\_disk\_iops\_writes | ops/s   | The per second average number of EBS IO disk-write operations summed across all disks |
| aws\_ec2\_disk\_iops         | ops/s   | The per second average number of EBS IO disk operations summed across all disks       |

### CPU Credits

| Name                              | Unit    | Description                                                                                                                                                                                                              |
| --------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| aws\_ec2\_credits\_cpu\_available | credits | The number of earned CPU credits that an instance has accrued since it was launched or started. Credits are accrued in the credit balance after they are earned, and removed from the credit balance when they are spent |
| aws\_ec2\_credits\_cpu\_used      | credits | The number of CPU credits spent by the instance for CPU utilization                                                                                                                                                      |

### Disk Credits

| Name                                | Unit    | Description                                                        |
| ----------------------------------- | ------- | ------------------------------------------------------------------ |
| aws\_ec2\_ebs\_credits\_io\_util    | percent | The percentage of I/O credits remaining in the burst bucket        |
| aws\_ec2\_ebs\_credits\_bytes\_util | percent | The percentage of throughput credits remaining in the burst bucket |

### Pricing

| Name            | Unit    | Description                               |
| --------------- | ------- | ----------------------------------------- |
| aws\_ec2\_price | dollars | AWS EC2 hourly instance price (on-demand) |

## Parameters

Notice: for the following parameters to take effect, the instance needs to be stopped and changes need to be applied before restarting the instance.

| Name                     | Unit | Type        | Default Value | Domain                                                                                                                                                                                                                                                                                                                                                                                                        | Restart | Description                                                                                                                         |
| ------------------------ | ---- | ----------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| aws\_ec2\_instance\_type |      | Categorical | `m5`          | <p><code>c5</code>,<code>c5d</code>,<code>c5a</code>,<code>c6g</code>,<code>c6gd</code>,<code>c6gd</code>,<br><code>r5</code>,<code>r5d</code>,<code>r5a</code>,<code>r5ad</code>,<code>r6g</code>,<code>r6gd</code>,<br><code>m5</code>,<code>m5d</code>,<code>m5a</code>,<code>m5ad</code>,<code>m6g</code>,<code>m6gd</code>,<br><code>t3</code>,<code>t3a</code>,<br><code>a1</code>,<code>z1d</code></p> | yes     | Instance types comprise varying combinations of CPU, memory, storage, and networking capacity, optimized to fit different use cases |
| aws\_ec2\_instance\_size |      | Ordinal     | `large`       | <p><code>nano</code>, <code>micro</code>,<code>small</code>,<code>medium</code>,<code>large</code>,<br><code>xlarge</code>,<code>2xlarge</code>,<code>4xlarge</code>,<code>8xlarge</code>,<br><code>9xlarge</code>,<code>12xlarge</code>,<code>16xlarge</code>, <code>18xlarge</code>,<code>24xlarge</code></p>                                                                                               | yes     |                                                                                                                                     |

## Constraints

The following table shows a sample of constraints that are required in the definition of the study, depending on the tuned parameters.

Notice that AWS does not support all combinations of instance types and sizes, so it is better to specify them beforehand in your constraints to avoid unnecessary experiment failures.

### Instance size

Instance size is an ordinal parameter, this means you constraint it by using a 0-based index, as in this example:

| `aws.aws_ec2_instance_type === "c5" && (aws.aws_ec2_instance_size === 0 \|\| aws.aws_ec2_instance_size === 2) \|\| aws.aws_ec2_instance_size === "m5" && (aws.aws_ec2_instance_size === 0 \|\| aws.aws_ec2_instance_size === 1)` | <p>Domain of aws\_ec2\_instance\_size here is: \[4xlarge, 8xlarge, 9xlarge].<br>Since "c5" instance type does not support 8xlarge instance size, and "m5" instance family does not support the 9xlarge one, this option is enforced with a constraint that allows only c5.4xlarge, c5.9xlarge, m5.4xlarge, and m5.8xlarge configurations</p> |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
