Canary and blue-green delivery
Choose a rollout strategy
A canary exposes a small portion of authorized traffic to a candidate while the stable version continues serving. Blue/green keeps two complete versions and changes which receives traffic after validation. Both need compatible data, enough capacity, and a known-good version. A weight is a target share under normal conditions, not a promise for each small sample or each user. This HTTP-context fragment uses weighted round robin, with one backend per version; the companion lab supplies the complete configuration.
upstream versions { server 127.0.0.1:19081 weight=9; server 127.0.0.1:19082 weight=1;}Mark responses and check readiness
A version marker is a value generated by the backend, not a claim inferred from the requested route. Check readiness separately: a backend may accept TCP connections while its application cannot serve requests. In a disposable lab, the following server locations produce a marker and a readiness response; they do not model database or dependency checks. Real readiness must reflect the dependencies needed by the served endpoint. Never expose a detailed internal health report publicly.
location = /release { return 200 "green\n"; }location = /ready { return 200 "ready\n"; }Switch blue and green deliberately
This location fragment selects a fixed upstream group named green. A blue/green switch may instead use a trusted variable or an external traffic manager. Before switching, test the candidate without public exposure, ensure both pools can sustain the expected load, and keep blue ready for rollback. Existing connections and old workers can outlive a graceful configuration reload. Measure the actual version marker after a switch, and drain before removing old capacity.
location / { proxy_pass http://green; proxy_next_upstream off;}Distinguish product and control-plane capabilities
The examples use Nginx Open Source configuration. An Ingress or Gateway controller can translate its own weighted routing policy into a data-plane configuration; a service mesh may do the weighting elsewhere. NGINX Plus has licensed dynamic management and health-check capabilities depending on the release. Do not copy controller resource fields into nginx.conf or assume a Plus API exists in OSS. Assign one owner for each traffic decision to avoid multiplying weights across layers.
OSS: reviewed config -> Nginx workersController: resource -> reconciler -> proxy configService mesh: routing policy -> mesh data planePlus: verify licensed capabilities and exact releaseApply what you learned
Practice: Design a 5% candidate stage followed by a blue/green switch for a read-only catalog. State readiness checks, expected markers, capacity and rollback. The manual exercise and quiz are staged separately. Related references and the next lesson are listed in the chapter authored map.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Canary and blue-green delivery
Assess progressive delivery and rollback reasoning.
What does a 9:1 weight express?
What distinguishes blue/green from a canary?
What proves which version responded?
Why test readiness separately from TCP?
Where do controller route fields belong?