What if you could update your website without anyone noticing a thing?
Why Zero-downtime deployment pattern in Terraform? - Purpose & Use Cases
Start learning this pattern below
Jump into concepts and practice - no test required
Imagine you have a popular website that needs an update. You try to update the server manually by stopping it, changing the code, and starting it again. During this time, visitors see errors or can't access the site at all.
Manually updating servers causes downtime because the site is offline while changes happen. It's slow, risky, and users get frustrated. If something goes wrong, fixing it takes even longer, making the problem worse.
The zero-downtime deployment pattern lets you update your service without stopping it. It uses two versions running side by side, switching traffic smoothly from the old to the new version. This keeps the site live and users happy.
stop server update code start server
deploy new version switch traffic to new version remove old version
You can update your applications anytime without interrupting users or risking downtime.
A streaming service updates its video player software while millions watch, without any interruption or buffering caused by the update.
Manual updates cause downtime and user frustration.
Zero-downtime deployment runs old and new versions together to avoid interruptions.
This pattern keeps services live and reliable during updates.
Practice
Solution
Step 1: Understand zero-downtime deployment purpose
Zero-downtime deployment means updating apps without stopping them or causing service interruptions.Step 2: Compare options with this goal
Only Update applications without stopping them or causing downtime describes updating without stopping or downtime, matching the goal.Final Answer:
Update applications without stopping them or causing downtime -> Option BQuick Check:
Zero-downtime = no stopping, no downtime [OK]
- Thinking deployment must stop all tasks
- Assuming manual traffic switch is required
- Believing updates only happen off-hours
Solution
Step 1: Identify settings related to task counts during update
Terraform uses settings like max_percent and min_healthy_percent to control task numbers during deployment.Step 2: Understand min_healthy_percent role
min_healthy_percent ensures a minimum percentage of tasks stay healthy and running during updates, preventing downtime.Final Answer:
min_healthy_percent -> Option AQuick Check:
min_healthy_percent controls running tasks during update [OK]
- Confusing max_percent with min_healthy_percent
- Using desired_count which sets total tasks, not update behavior
- Selecting task_definition which defines task specs
deployment_minimum_healthy_percent = 75
deployment_maximum_percent = 200
What does this configuration ensure during deployment?
Solution
Step 1: Interpret deployment_minimum_healthy_percent
This means at least 75% of current tasks must stay healthy and running during deployment.Step 2: Interpret deployment_maximum_percent
This allows up to 200% of the desired tasks to run temporarily, enabling new tasks to start before old ones stop.Final Answer:
At least 75% of tasks stay running; up to 200% tasks can run temporarily -> Option DQuick Check:
Min healthy 75%, max 200% = safe rolling update [OK]
- Thinking percentages mean exact task counts
- Assuming deployment stops tasks before starting new ones
- Confusing min and max percentages
deployment_minimum_healthy_percent = 100 and deployment_maximum_percent = 100 in Terraform for ECS service. What issue will this cause?Solution
Step 1: Analyze min and max percent both at 100%
Min healthy 100% means all old tasks must stay running; max 100% means no extra tasks can start.Step 2: Understand deployment impact
New tasks cannot start until old ones stop, but old ones cannot stop because min healthy is 100%, causing deployment to fail.Final Answer:
Deployment will fail because no new tasks can start before old ones stop -> Option CQuick Check:
Min 100% + Max 100% blocks rolling update [OK]
- Assuming deployment will succeed without downtime
- Thinking max 100% allows extra tasks
- Ignoring min healthy effect on stopping old tasks
Solution
Step 1: Evaluate each option for zero-downtime support
deployment_minimum_healthy_percent = 50allows only 50% healthy tasks, risking downtime.
deployment_maximum_percent = 150deployment_minimum_healthy_percent = 100blocks new tasks starting before old stop.
deployment_maximum_percent = 100deployment_minimum_healthy_percent = 0allows zero healthy tasks, risking downtime.
deployment_maximum_percent = 200deployment_minimum_healthy_percent = 75keeps 75% healthy and allows 125% max tasks, enabling smooth rolling update.
deployment_maximum_percent = 125Step 2: Choose best balance for zero-downtime
deployment_minimum_healthy_percent = 75ensures enough healthy tasks remain while allowing new tasks to start before old stop, supporting zero downtime.
deployment_maximum_percent = 125Final Answer:
deployment_minimum_healthy_percent = 75 and deployment_maximum_percent = 125 -> Option AQuick Check:
Min healthy 75% + max 125% = safe rolling update [OK]
- Choosing min healthy too low risking downtime
- Choosing min and max both 100% blocking updates
- Allowing zero healthy tasks during deployment
