AWS Compute Optimizer is a no additional charge for this service but should provide full permissions + metrics to analyze and make recommendations - help avoid over-provisioned or under-provisioned of the following 5 services:
Conclusion: within the framework of this lab, the cost optimization when using compute (EC2, Lambda, Fargate) should be done in the following order:
Note: if step 2 is complete before step 1, the optimization will be really meaningless, like how we are not sure if the machine is suitable for the workload work or not? too powerful - leading to redundancy, or too weak - resulting in not being able to handle the workload, which bought & committed to use that machine for 1 or 3 years .
AWS Compute Optimizer relies on metrics collected by CloudWatch over a period of 14 days to analyze and make recommendations, with typical metrics such as:
In addition, the following metrics are available: link and custom metrics to be placed under a namespace is: CWAgent
Note: you can set a different namespace to easily track custom metrics in CloudWatch service, however if you want to get full recommendations from AWS Compute Optimizer then namespace: CWAgent is a required condition of this service.
Besides, the Memory utilization metric is custom metric so it is not initialized by default, the lack of this metric will make the choice of EC2 virtual machine configuration useless. misleading when recommendations are based solely on metric CPU utilization! Therefore, it is necessary to install CloudWatch Agent on EC2 virtual machines to collect metric memory.
Note: Refer back to step 1 to understand CloudWatch Agent link
Example 1: The picture shows the AWS Compute Optimizer service proposal for EC2 when only the CPU utilization metric is available.
Note: monthly payment saved $85,4000
Example 2: The picture shows the AWS Compute Optimizer service proposal for EC2 when there are two important metrics: CPU utilization & Memory utilizaton
Note: monthly payment saved $163,1800 more than in example 1 -> From that, having full metric will help give the exact recommendation on actual usage, making savings most effective
AWS Compute Optimizer supports most instance types with common types such as: C5, M5, R5, T2, T3,… (reference)
AWS Compute Optimizer does not support the following instance types: G2, G3, G4ad, G4dn, G5, G5g, Mac1,…(reference)
Note: AWS Compute Optimizer is not recommended for Spot Instances
Example 3: The picture shows the AWS Compute Optimizer service proposal for Auto Scaling group = ASG, with ASG automatically generated when deploying the service AWS Elastic Beanstalk
Note: during use ASG with different demand between values eg: desired=2, minimum=1, and maximum=4 capacity, will not get optimization recommendations from AWS Compute Optimizer (learn more about Auto-Scaling-group service, link)
Recommended for EBS General Purpose SSDs (gp2 and gp3) and IOPS SSDs (io1 and io2) mounted in EC2.
EBS needs to be attached to an EC2 for at least 30 consecutive hours.
Example 4: The picture shows the AWS Compute Optimizer service proposal for EBS
Memory of lambda is less than or equal to 1792 MB (= 1.75 GB )
Lambda functions called at least 50 times in the last 14 days
Example 5: The picture shows the AWS Compute Optimizer service proposal for Lambda
Amazon ECS running on fargate with at least 24 hours of activity recorded by Cloudwatch
Have metrics of Amazon ECS utilization from the past 14 days
There are no step scaling policies assigned to Amazon ECS on fargate
There are no target scaling policies based on Amazon ECS CPU or Ram values on fargate
Fargate service has SteadyState or MoreWork status.
Note If target tracking policy is assigned to fargate service’s CPU, then AWS Compute Optimizer only makes recommendations for the size of memory and vice versa.
Example 6: The picture shows the AWS Compute Optimizer service proposal for Fargate
In this section, we will perform opt in AWS Compute Optimizer service! There won’t be any permision requirements if you are using IAM User with AdministratorAccess permision , but assuming you are 3rd and have plan to deploy the service for the production company, the customer only gives you least privilege to use the AWS Compute Optimizer service! So under the role of deployment you need to notify to your client about 2 policy below to get permission.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iam:CreateServiceLinkedRole",
"Resource": "arn:aws:iam::*:role/aws-service-role/compute-optimizer.amazonaws.com/AWSServiceRoleForComputeOptimizer*",
"Condition": {
"StringLike": {
"iam:AWSServiceName": "compute-optimizer.amazonaws.com"
}
}
},
{
"Effect": "Allow",
"Action": "iam:PutRolePolicy",
"Resource": "arn:aws:iam::*:role/aws-service-role/compute-optimizer.amazonaws.com/AWSServiceRoleForComputeOptimizer"
},
{
"Effect": "Allow",
"Action": "compute-optimizer:UpdateEnrollmentStatus",
"Resource": "*"
}
]
}
specific_service_linked_role_for_Compute_Optimizer
compute
Note: AWS has a default notice, AWS Compute Optimizer service is free, we only pay when: change the configuration of compute + volumes and monitoring activities by Cloudwatch
Note: In the framework of this lab, we will choose Only this account, but in the real business environment, when the customer splits 2 environments: Dev- Test and Production with 2 separate AWS accounts managed by AWS Organizations service (read more about AWS Organizations ). We will select All member accounts of this organization (located on the left) to get optimal recommendations for all compute and volumes included in the AWS accounts under organization
Note: