Blue-green deployment on a VPS: updating without interrupting service
Published on 2026-11-14 by frfrand
How to prepare two versions, check health, switch Nginx, and roll back safely.

The problem: an update should not leave the application inaccessible
Restarting an application directly on the only active instance creates a risk window: if startup fails, a dependency or a migration, all users notice it. Blue-green deployment reduces that risk by maintaining two executable versions: blue serves current requests and green receives the new code. It does not equal high availability by itself: if the VPS fails, both versions go down.
Minimum architecture on a single VPS
Organize each version in an independent container or service, for example on internal ports 8101 and 8102. Nginx listens on HTTPS and sends traffic only to the active service. Keep release directories, logs, and artifacts separate; share only services that truly need to be common, such as an external database or persistent storage designed for concurrent access.
A reasonable flow is GitHub → immutable build → green → validation → proxy change → monitoring. In GitHub Actions, the CI process must run tests and build the artifact before delivering it to the VPS. Do not build on the directory that is serving users.
Prepare the candidate without touching production
1. Download the exact commit and record its identifier. 2. Start green with its own port, appropriate variables, and resource limits. 3. Run database connection checks, health endpoint, authentication, and a critical business flow. 4. Confirm that green can work with the database schema that blue is still using.
The /health endpoint should not return 200 simply because the process is alive. Distinguish liveness from readiness: an application can run as a process and not be ready to receive requests.
Change traffic via Nginx
You can keep an upstream file controlled by the deployment process and change the active server. Then run nginx -t before reloading Nginx via systemctl reload nginx. Test this operation first in a non-production environment: syntax or permission errors can leave the proxy misconfigured.
Open connections and jobs that were running require special attention. WebSockets, long requests, local sessions, and job queues need orderly shutdown. Keep blue available during a sufficient observation interval and review latency, 5xx errors, logs, and business metrics.
The most dangerous point: data migrations
Switching Nginx to blue does not undo a destructive migration. Design forward- and backward-compatible schema changes first: add columns before requiring them, deploy tolerant readers, and remove old fields only in a later deployment. Make verified copies and document what the consequences would be of reverting code but not data.
Tested rollback, not improvised
The rollback procedure must be written and rehearsed: identify the previous release, validate that it is still healthy, restore the upstream, check Nginx, and confirm critical operations. If the problem affects shared writes, it may be necessary to stop changes and analyze consistency before restoring information.
When it is worth it
Blue-green works well for APIs, dashboards, and SaaS with constant traffic when two instances fit in the available memory. If the VPS cannot support that double consumption, consider planned maintenance or a second server. To learn more about publishing applications, see Next.js deployment on VPS and Docker Compose in production. ArduMaker's VPS management can facilitate infrastructure operation, without replacing your application testing.
Frequently asked questions
### Is zero downtime guaranteed? No. It reduces interruptions due to version changes, but does not eliminate infrastructure or compatibility issues. ### Do I need two VPS? Not necessarily; two isolated services can reside on one, if there are resources. ### What do I do with the workers? Update them with your own strategy, avoiding processing the same job twice.