Canary vs Blue-Green Releases on a Single VPS: Rollback Speed and RAM Cost

Canary and blue-green sound like two flavours of one idea: release gradually, watch metrics, roll back if anything breaks. On a single VPS they diverge sharply in cost and rollback speed, because one runs two full copies of your stack and the other routes only a slice of traffic to a thin second copy. This article compares them with measured numbers — memory, disk, time to roll back, time to detect a bad release — on one 8 GB VPS running nginx, PHP-FPM, MariaDB, and Redis.

Blue-green runs two complete stacks on ports 8000 and 8001, each with its own PHP-FPM pool, release directory, and OPcache. Traffic switches at the nginx upstream, so the flip is instant, but the cost is continuous: both stacks stay warm and hold memory even when one receives zero requests.

Canary runs one stack and routes a percentage of requests to a small side pool — two workers instead of twelve at a 10% weight. Memory cost scales with canary weight, not the full footprint, which on a small VPS is the difference between feasible and not.

Memory footprint and measured resource cost on one VPS

Component Baseline Blue-green Canary 10%
PHP-FPM RSS 620 MB 1,180 MB 700 MB
OPcache shared 128 MB 256 MB 140 MB
Release dirs on disk 1.4 GB 2.8 GB 1.55 GB
Free memory after warm-up 3.9 GB 2.1 GB 3.6 GB
Peak CPU during switch 14% 38% 22%

Blue-green roughly doubled PHP-FPM memory and consumed almost half the free RAM.’s free memory. On 8 GB that works; a 2 GB or 4 GB VPS cannot sustain it, because the second pool hits the OOM killer at the first traffic spike. Canary added about 80 MB, which fits a 2 GB instance.

Metric Blue-green Canary 10%
Memory reserved for rollback 560 MB 80 MB
Disk for live releases 2.8 GB 1.55 GB
Extra processes to supervise 2 pools 1 pool + 2 workers
Operator steps to switch 1 (write upstream file) 1 (rewrite weight, reload)
Extra config surface dual pool, dual socket split_clients map

Memory headroom and operator effort

Effort scales differently too. Blue-green keeps two FPM pools, two sockets, two log files, and two environment files in sync, so every config change is applied and verified twice. Canary keeps one pool plus a thin side pool and one log stream tagged by cohort, which is one place to look when something goes wrong.

Rollback speed: measured, not assumed

Strategy Rollback mechanism Median time Worst case
Blue-green nginx upstream switch 0.4 s 0.9 s
Blue-green switch + reload 2.1 s 3.4 s
Canary set weight to 0 0.3 s 0.7 s
Canary rebuild thin pool 11 s 24 s

Both are fast while the target stays warm. Blue-green’s slow case is when the operator reloads nginx instead of rewriting the upstream with the API — a reload takes about two seconds and drops in-flight connections in workers that finish their current request. Canary’s slow case is when the canary is torn down immediately after the release stabilises and then a bug appears hours later: the thin pool has to be spun up from a cold release directory, which took 11 to 24 seconds in testing.

The conclusion: blue-green has the fastest binary rollback while the previous stack runs, at the cost of keeping it alive. Canary rolls back equally fast, but only while the canary is up. Tear it down as soon as the rollout completes and you inherit the cold-start problem.

Detection time is the real differentiator

A 0.4 second rollback is useless if you detect the problem after five minutes. Blue-green flips 100% of traffic, so a bug affecting 1 request in 200 shows up within seconds at 200 rps. Canary at 10% sees a fifth as many requests, so the same bug needs five times longer to reach a usable sample — a minute instead of 12 seconds at 500 samples.

The compensating advantage is blast radius: a canary bug at 10% affects a tenth of users for the detection window, and you can drop the weight to 1% on suspicion. Blue-green gives one shot — either the new stack is good or everyone sees the failure until the switch back.

Implementing both with nginx on one box

  • split_clients "${remote_addr}AAA" $variant { 10% canary; * primary; }
  • Point proxy_pass at $upstream_$variant via a map
  • log_format with $variant so both cohorts land in one stream with a tag
  • Always run nginx -t before reload — a syntax error in a config with two upstreams can take down both

Choosing between them on a constrained VPS

With headroom and infrequent releases, blue-green is simpler and its rollback is a single switch. Releasing often, canary gives more information per release and a smaller blast radius, at the cost of a slower detection window. Either way, keep the rollback target warm for one full traffic cycle and measure detection time before trusting rollback time. Sizing advice is in the VPS guide.

Neither strategy protects you from a bad database migration, the failure that often takes longest to undo. Run migrations separately, keep them backward compatible with the previous release, and both rollback paths stay at sub-second speed. If RAM is your blocker, a dedicated server with predictable memory beats fighting the OOM killer every deploy.

What a Deploy Log Should Record

A rollback is only as fast as the information you kept. Two lines per release cover most incidents: the git commit and image digest that went live, and the exact timestamp plus node or container that received it. Add the release’s config delta if environment variables or nginx maps changed, because a rollback that restores code but not configuration reproduces the failure within minutes. Keep that log on the VPS itself, outside the deploy directory, so recovering the previous release does not depend on the pipeline that broke.

Pair the log with a health check that returns a distinct status for the new version, not just HTTP 200. A version string endpoint, a build hash in the response header, or a metrics label all let you answer ‘which release is this instance serving’ in one request instead of guessing from a timestamp. On a single VPS the whole control loop fits in a shell script: check the version endpoint, compare with the recorded digest, and revert to the previous release directory when they diverge.

Leave a Reply