0
0
AWScloud~10 mins

Services and tasks in AWS - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Services and tasks
Create Task Definition
Register Task Definition
Create Service
Service Launches Tasks
Tasks Run Containers
Monitor & Scale Tasks
Update Service
Replace Tasks
This flow shows how you define a task, register it, create a service to run tasks, and how the service manages running and updating tasks.
Execution Sample
AWS
1. Define task with container info
2. Register task definition
3. Create service with task definition
4. Service launches tasks
5. Tasks run containers
This sequence shows how AWS ECS runs containers by defining tasks and services.
Process Table
StepActionInputResultNotes
1Define TaskContainer image: nginxTask Definition createdDefines container and resources
2Register TaskTask Definition JSONTask Definition ARNTask is saved and versioned
3Create ServiceTask Definition ARN, desired count=2Service createdService manages tasks
4Service Launches TasksDesired count=22 Tasks startedTasks run containers
5Tasks RunningContainer image nginxContainers runningContainers serve traffic
6Monitor & ScaleCPU usage highService scales to 3 tasksMore tasks launched
7Update ServiceNew Task Definition versionService updates tasksOld tasks replaced
8Tasks ReplacedOld tasks stoppedNew tasks runningService stable with new version
9ExitDesired count metStable serviceNo further action needed
💡 Service reaches desired count and tasks run containers successfully
Status Tracker
VariableStartAfter Step 3After Step 4After Step 6After Step 8Final
Task DefinitionNoneRegistered v1Registered v1Registered v1Registered v2Registered v2
Service Desired Count022333
Running Tasks002333
Task VersionNonev1v1v1v2v2
Key Moments - 3 Insights
Why does the service launch multiple tasks instead of just one?
Because the service's desired count is set to more than one (2 in step 3), so it launches that many tasks to run containers (see execution_table step 4).
What happens when the service updates to a new task definition version?
The service replaces old tasks with new tasks running the updated version (see execution_table steps 7 and 8). This ensures smooth updates without downtime.
How does the service decide to scale up the number of tasks?
It monitors metrics like CPU usage and scales tasks up or down to meet demand (see execution_table step 6).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, how many tasks does the service launch initially?
A1
B2
C3
D0
💡 Hint
Check step 4 in the execution_table where the service launches tasks.
At which step does the service update to a new task definition version?
AStep 5
BStep 6
CStep 7
DStep 8
💡 Hint
Look for the step labeled 'Update Service' in the execution_table.
If the desired count changes from 2 to 3, what happens in the execution table?
AService scales to 3 tasks
BService deletes task definitions
CService stops tasks
DNo change
💡 Hint
See step 6 where the service scales tasks based on CPU usage.
Concept Snapshot
AWS ECS runs containers using tasks and services.
Define a task with container info.
Register task definition to save it.
Create a service to run tasks.
Service launches and manages tasks.
Update service to replace tasks with new versions.
Full Transcript
This visual execution shows how AWS ECS uses tasks and services to run containers. First, you define a task with container details like the image. Then you register this task definition, which saves it with a version. Next, you create a service that uses this task definition and sets how many tasks to run. The service launches the tasks, which run containers. The service monitors the tasks and can scale them up or down based on demand. When you update the task definition, the service replaces old tasks with new ones running the updated version. This process ensures your containers run reliably and can be updated smoothly.