On this pageThe two strategies side by side
A good release process makes bad releases cheap. Few users notice them, they last minutes rather than hours, and undoing them is one command. Blue-green and canary releases are the two classic ways to get there. They are often presented as Kubernetes features, but both are older than Kubernetes and work fine with a reverse proxy and two copies of your app.
The two strategies side by side
| Blue-green | Canary | |
|---|---|---|
| Traffic shift | All at once | Gradual, in steps |
| Rollback | Switch back to the old color | Set the canary's share to zero |
| Extra capacity | A full second copy during the release | One or a few extra instances |
| Catches | Broken deploys, before users see them | Problems that only real traffic reveals |
| Requires | Good smoke tests | Good metrics, alerts and sticky routing |
| Blast radius of a bad release | Everyone, until you switch back | Only the canary slice |
They combine well: deploy to the idle color, send it 5% as a canary, then switch fully.
Blue-green: switch everything at once
You run two identical environments, called blue and green. One serves all traffic. You deploy the new version to the idle one, test it there with production configuration, then switch the router so all traffic moves at once. The old environment stays untouched, so rolling back is the same switch in reverse.
The cost is capacity: during a release you need room for two full copies. The hard part is shared state, because both colors usually talk to the same database.
One server, two ports, one symlink
Run the two versions side by side, for example as two Compose projects or two systemd services, on ports 8081 (blue) and 8082 (green). Define one small file per color:
upstream shop_live { server 127.0.0.1:8081; }
Save that as /etc/nginx/upstreams/shop-blue.conf, and the same line with port 8082 as shop-green.conf. The site configuration includes whichever color a symlink points to:
include /etc/nginx/shop-live.conf;
server {
listen 80;
server_name shop.example.com;
location / {
proxy_pass http://shop_live;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Before switching, test the idle color directly on its own port, with the same checks your users depend on:
curl -fsS http://127.0.0.1:8082/healthz && echo "green is healthy"
curl -fsS -o /dev/null http://127.0.0.1:8082/ && echo "home page answers"
If a check fails, nothing has happened yet: fix green, or throw it away. The switch itself is a symlink change and a reload:
sudo ln -sfn /etc/nginx/upstreams/shop-green.conf /etc/nginx/shop-live.conf
sudo nginx -t && sudo systemctl reload nginx
nginx -t refuses a broken configuration before anything changes, and a reload lets old worker processes finish their requests while new ones use the new upstream. Nobody sees an error. Rolling back means pointing the symlink at blue again.
Two servers and a floating IP
For whole-server blue-green, put each color on its own server and move a floating IP between them. The address your DNS points to never changes, so there is no waiting for record caches to expire, which is the weak spot of DNS-based switching. On CloudSat, a floating IP can be reassigned from one server to another in the console, which turns the cut-over into a single action.
Canary: move traffic in steps
You release the new version to a small slice of real traffic, say 5%, while everything else stays on the current version. You compare error rates and latency between the two groups. If the canary looks healthy, you raise its share step by step until it carries everything. If not, you set its share to zero.
The cost is observability: a canary is only as good as the metrics you watch. It also needs routing that keeps a given user on one version, or they bounce between old and new on every click.
Weighted and sticky routing in Nginx
The simplest canary is a weighted upstream:
upstream shop {
server 127.0.0.1:8081 weight=95; # stable
server 127.0.0.1:8082 weight=5; # canary
}
Weights split requests, not users. A visitor can load a page from the stable version and its scripts from the canary, which breaks when asset file names differ between releases. For user-level stickiness, let split_clients hash something stable about each client:
upstream shop_stable { server 127.0.0.1:8081; }
upstream shop_canary { server 127.0.0.1:8082; }
split_clients "$remote_addr$http_user_agent" $shop_pool {
5% shop_canary;
* shop_stable;
}
server {
listen 80;
server_name shop.example.com;
location / {
proxy_pass http://$shop_pool;
}
}
The same client always lands in the same bucket. When the variable's value matches an upstream name, Nginx uses that group. While a canary runs, adding add_header X-Served-By $upstream_addr always; to the location makes every response say which instance produced it, which settles most "was that the new version?" questions in seconds. To ramp up, change 5% to 25% and reload. Behind a CDN or another proxy, $remote_addr is the proxy's address, so hash a cookie or the real client IP instead.
Live weights with HAProxy
HAProxy can change weights live, without a reload. Declare the canary with weight 0, and make sure the global section has an admin socket (stats socket /run/haproxy/admin.sock mode 660 level admin):
backend shop
balance roundrobin
server stable 127.0.0.1:8081 check weight 100
server canary 127.0.0.1:8082 check weight 0
echo "set server shop/canary weight 10" | sudo socat stdio /run/haproxy/admin.sock
echo "show servers state shop" | sudo socat stdio /run/haproxy/admin.sock
With weights 100 and 10, the canary receives roughly 9% of the traffic. Changes through the socket are lost on the next reload, so write the final weights back into the configuration once the release settles.
Promotion rules, written before the release
Write the promotion rules down before the release starts, not while you stare at a graph:
- Error rate: the canary's share of 5xx responses stays within a small margin of the stable group.
- Latency: its 95th percentile response time does not drift above stable's.
- Saturation: CPU, memory and connection pools look like the stable instances under the same load.
- Duration: each step lasts long enough to cover your busiest request types.
Compare the canary with the stable group at the same moment, not with yesterday. Traffic changes during the day; the comparison should not.
Schema changes both versions survive
Both strategies run two versions against one database at the same time, so every schema change has to work for both. The expand and contract pattern handles it: first add new columns or tables without removing anything (expand), release code that writes to both shapes, migrate the data, and only after the old version is gone remove what it used (contract). Feature flags help in the same way: deploy code dark, then turn behavior on separately from the release.
FAQ
Which should a small team start with?
Blue-green on one server. Two ports, a symlink and a reload give you instant rollback with almost no new tooling. Add canary steps once you have per-version error and latency metrics.
Is a rolling deployment the same thing?
No. A rolling deployment replaces instances in batches until all run the new version. There is a mixed period like a canary, but no deliberate traffic split and no instant switch back.
Do I need Kubernetes for this?
No. Kubernetes and service meshes automate these patterns at scale, but the mechanics are a router and two versions. A proxy you already run covers most small and medium setups.
Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.




