Bird
0
0

How should you configure the task definition to ensure both containers run together and share CPU and memory?

hard📝 Best Practice Q15 of 15
AWS - ECS and Fargate
You want to run a web app on Fargate that needs 2 containers: one for the app and one for logging. How should you configure the task definition to ensure both containers run together and share CPU and memory?
ADefine both containers in the same task definition with combined CPU and memory settings.
BCreate two separate task definitions and run two Fargate services.
CRun one container on Fargate and the other on EC2 instances.
DUse one container and add logging as a sidecar process inside it.
Step-by-Step Solution
Solution:
  1. Step 1: Understand multi-container tasks in Fargate

    Fargate supports multiple containers in one task definition sharing CPU and memory.
  2. Step 2: Evaluate options for running two containers together

    Defining both containers in the same task definition with combined CPU and memory settings ensures they run together and share resources. Separating into different task definitions or services loses shared resource benefits and co-location. Adding logging as a sidecar process inside the app mixes concerns, which is not best practice.
  3. Final Answer:

    Define both containers in the same task definition with combined CPU and memory settings. -> Option A
  4. Quick Check:

    Multi-container task = single task definition with both containers [OK]
Quick Trick: Use one task definition for multiple containers sharing resources [OK]
Common Mistakes:
  • Splitting containers into separate tasks unnecessarily
  • Mixing logging inside app container
  • Running containers on different platforms

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes