0
0
Nginxdevops~10 mins

Canary deployments in Nginx - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Canary deployments
Start Deployment
Deploy New Version to Small %
Monitor Metrics & Logs
Increase %
Repeat
This flow shows deploying a new version to a small user portion, monitoring it, then either increasing traffic or rolling back.
Execution Sample
Nginx
upstream backend {
  server stable:80 weight=90;
  server canary:80 weight=10;
}

server {
  listen 80;
  location / {
    proxy_pass http://backend;
  }
}
This NGINX config snippet routes 10% of traffic to the canary backend.
Process Table
StepActionTraffic % to CanaryTraffic % to StableResult
1Start deployment0%100%All traffic to stable version
2Deploy canary with 10% traffic10%90%10% users see new version
3Monitor metrics10%90%No errors detected
4Increase canary to 30%30%70%More users see new version
5Monitor metrics30%70%No errors detected
6Increase canary to 50%50%50%Half users see new version
7Monitor metrics50%50%Errors detected
8Rollback to stable0%100%All traffic back to stable
9End deployment0%100%Deployment stopped due to errors
💡 Deployment stops after errors detected at 50% canary traffic and rollback occurs
Status Tracker
VariableStartAfter Step 2After Step 4After Step 6After Step 8Final
canary_traffic_percent0%10%30%50%0%0%
stable_traffic_percent100%90%70%50%100%100%
deployment_statusstablecanary startedcanary increasedcanary increasedrolled backstable
Key Moments - 3 Insights
Why does traffic to canary start at a low percentage like 10%?
Starting with low traffic limits risk. As shown in execution_table step 2, only 10% users see the new version to catch issues early.
What happens if errors are detected during canary deployment?
As in step 7 and 8, if errors appear, traffic is rolled back to 0% canary and 100% stable to protect users.
Why do we increase canary traffic gradually?
Gradual increase (steps 4 and 6) helps verify stability before full rollout, reducing impact of bugs.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the canary traffic percentage at step 4?
A50%
B10%
C30%
D0%
💡 Hint
Check the 'Traffic % to Canary' column at step 4 in the execution_table.
At which step does the deployment rollback happen according to the execution_table?
AStep 8
BStep 7
CStep 6
DStep 9
💡 Hint
Look for the row where 'Rollback to stable' is the action.
If no errors were detected at step 7, what would likely happen next?
ARollback to stable
BIncrease canary traffic further
CStop deployment
DDecrease canary traffic
💡 Hint
Refer to the pattern of increasing traffic after successful monitoring in the execution_table.
Concept Snapshot
Canary deployments gradually route a small % of traffic to a new version.
Monitor for errors before increasing traffic.
Rollback immediately if errors occur.
Use NGINX weighted routing to control traffic split.
This reduces risk of full rollout failures.
Full Transcript
Canary deployments start by sending a small portion of user traffic to a new version of an application. This is done to test the new version in real conditions with limited impact. Using NGINX, we can set weights to control how much traffic goes to the new version versus the stable one. We monitor metrics and logs carefully. If no problems appear, we increase the traffic gradually. If errors are detected, we rollback to the stable version immediately. This process helps keep users safe while deploying new features.