I want to find out why the CPU utilization is high on my Amazon Elastic Container Service (Amazon ECS) tasks on AWS Fargate.
Troubleshoot high CPU utilization for Fargate tasks that are part of a service
- Use Amazon CloudWatch metrics to view service-level CPU utilization.
- Check if there is an ongoing deployment in the Amazon ECS service. During a deployment, there are more tasks running and the aggregate CPU utilization of the Amazon ECS service increases. After a deployment is complete, aggregate CPU utilization should decrease.
If there isn't an ongoing deployment, then check the following:
- Check your application logs to see if your tasks are performing CPU-intensive operations. The logs are exported to various destinations, depending on your logging driver. If you're using the awslogs driver, then the logs are exported to CloudWatch. The CPU-intensive operation varies according to the application being deployed in the Fargate task.
- Check for an increase in incoming traffic to your Amazon ECS service by viewing the CloudWatch metrics of your load balancer. If there is increased traffic to your tasks, consider using Auto Scaling to increase the desired number of tasks running in the service. This allows incoming traffic to be distributed to a higher number of tasks, which can reduce the overall CPU utilization of your tasks.
Troubleshoot high CPU utilization for standalone Fargate tasks
To view task-level metrics through performance logs, you must enable CloudWatch Container Insights. For more information, see Introducing Amazon CloudWatch Container Insights for Amazon ECS.
If your application's containers must perform CPU-intensive workloads, then consider upgrading to a larger task size that includes more vCPU and memory. For more information, see AWS Fargate Pricing.