What does 'cpu' parameter mean in aws container service?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
In AWS container services like Amazon ECS (Elastic Container Service), the cpu
parameter plays a crucial role in determining how resources are allocated to containers. This parameter affects container performance, cost, and scalability.
Understanding the cpu
Parameter
The cpu
parameter specifies the number of CPU units allocated to a container. In Amazon ECS, CPU units are used to allocate CPU time on the underlying hardware. The allocation ensures containers get a fair share of compute resources based on their defined needs.
Technical Specifications
- CPU Units: The basic unit of CPU allocation in ECS. Traditionally, 1 vCPU (or one virtual core) is equivalent to 1,024 CPU units.
- Soft and Hard Limits: Specifying CPU units can set either soft or hard limits. Soft limits allow for burstable performance if there are spare resources, while hard limits enforce strict adherence to specified limits.
- Shared and Dedicated Resources: Containers can share CPU resources if specified under a common service, or they can be dedicated, ensuring exclusive access.
Example Scenario
Consider a web application running in AWS ECS. You might have a service that requires low latency and high compute power. For this service, you might allocate 2 vCPUs, which translate to 2048
CPU units in ECS configuration.
- Task CPU: Total CPU available to the task is the sum of the CPU units specified for each container within the task.
- EC2 vs Fargate: In ECS, tasks can run on EC2 instances or Fargate. For EC2 instances, the CPU allocation depends on the instance type. In Fargate, you specify and pay for the CPU units directly.
- Adequate CPU allocation ensures application runs efficiently.
- Over-allocation might lead to unnecessary costs.
- Under-allocation can cause throttling and hinder performance.
- In Fargate, an over-provisioned CPU leads to higher costs.
- Right-sizing tasks can contribute to substantial cost savings.
- Proper understanding of CPU requirements aids in designing scalable applications.
- Adjusting the
cpuparameter in response to monitoring data (e.g., CloudWatch metrics) helps maintain performance and cost balance over time.

