← Back to blog

Blue-Green Deployments: How They Work and When to Use Them

November 22, 2026
Blue-Green Deployments: How They Work and When to Use Them

A blue-green deployment means running two identical copies of your production environment, sending users to one while you prepare the new version on the other, then switching traffic over in one move. If the new version misbehaves, you switch back. For a founder, the practical value is simple: releases stop being a moment when your product might go down, and a bad release becomes a ten-second undo instead of a bad night.

I'm Hanad, a freelance senior software engineer in Vienna. I build first real versions of software for founders and owner-operated businesses, and release safety is one of the things I set up so the product survives real users. This guide explains the strategy in plain language, walks through the steps, and tells you honestly whether you need it yet.

Hanad Kubat
Build Software Ready for Real Users
Hanad builds working software for founders and owner-operated businesses, with fixed scope, fixed price, and code ownership from the first commit.
Visit

Key Takeaways

  • Blue is the version users are on now. Green is the new version, running next to it. You test green, move traffic to it, and keep blue around as your rollback.
  • The switch is all at once, so the strategy protects you from downtime and gives instant rollback, but it does not test the release on a small slice of users first. That is what canary releases do.
  • The hard part is rarely the servers. It is the database, which both versions usually share, so schema changes must work for old and new code at the same time.
  • Two environments cost more while both run. Spin green up only for a release, or keep it small, and the cost stays modest.
  • A prototype with no staging environment and no repeatable deploy is not ready for blue-green yet. Fix that first.

Table of Contents

What blue-green deployment is

The AWS whitepaper on blue/green deployments describes the idea as shifting traffic between two identical environments running different versions of your application. Blue is the current version serving production traffic. Green is staged with the new version. Once green is ready and tested, production traffic is redirected from blue to green. If problems appear, you roll back by pointing traffic at blue again.

The colors are only labels. After a release, green becomes the live environment, and the next release goes onto the old blue, which then plays the role of green.

The same AWS paper frames the real benefit as limiting the blast radius of a bad release. Because the old environment is still running, impaired operation lasts only from the moment you detect the problem to the moment you switch back. That is the reason founders care: you are not betting the whole business on every release.

The steps, in the order you'd do them

Every platform words this differently, but the sequence is the same. Cloud Foundry's documentation gives five steps: run the app as blue with its live route, push the update as green on a temporary route, send traffic to both so you can see green working, remove blue from the live route once green checks out, then delete the temporary route and either retire blue or keep it for rollback. Amazon ECS splits the same flow into six phases: preparation, deployment, testing, traffic shifting, monitoring during a bake time, and completion.

Here is the version I'd hand a non-technical founder.

  1. Build green next to blue. Create a second environment from the same recipe as production: same settings, same size, same kind of database connection. If you cannot create an environment from a script or a pipeline, stop here. Building it by hand is where mistakes creep in. The deployment pipeline guide covers what that repeatable process looks like.
  2. Deploy the new version to green only. Real users still see blue. Nothing they touch has changed.
  3. Test green with production-like conditions. Run smoke tests: can someone sign up, log in, pay, and complete the one workflow your product exists for? Send test traffic to green through a private address. Microsoft's guidance for blue-green on AKS adds a load test against a baseline, so you learn whether green is slower than blue before users do.
  4. Switch traffic. This is a load balancer setting, a routing rule or a DNS record. On ECS the shift is an immediate move of 100% of traffic, controlled by load balancer listener rules and target-group weights, and automatic rollback can trigger if alarms or health checks fail.
  5. Watch it. Keep an eye on error rates, payment failures and response times for a set period. This is often called the bake time.
  6. Retire or keep blue. Once green is stable, shut blue down to stop paying for it, or keep it a little longer as the fast way back.

Where each step goes wrong

The usual failures are mundane. Green was built slightly differently from blue, so a test passes in one and fails in the other. Testing stops at "the page loads" and skips payments or emails. Someone switches traffic and nobody watches the dashboards. Or blue is deleted ten minutes after the switch, so the promised rollback no longer exists.

The cheapest fix is a written checklist for steps 3 and 5 that names the exact flows to try. My one-page release checklist for staging versus production is a starting point for founders.

The database is the real problem

The servers are easy to duplicate. The data is not. Blue and green usually talk to the same database, because copying live customer data to a second database and keeping it in sync is its own project. Cloud Foundry warns that with a relational database, blue-green can create discrepancies between the two sides during an update, and recommends one database that works with both old and new versions.

In practice that means schema changes happen in stages, often called expand and contract, as this walkthrough on ECS database migrations describes. Take a rename from user_name to username:

  • Expand. Add the new column and fill it, leaving the old one in place. Both blue and green work.
  • Switch. Move traffic to green, which uses the new column. Blue can still run if you need to roll back, because the old column is still there.
  • Contract. Only after green has proven stable and blue is gone, remove the old column in a later release.

The rule behind it: never ship a release whose database change would break the previous version. If you break that rule, your rollback is a fiction, because blue can no longer read the data.

This is the single most common gap I see in prototypes built with AI app builders. They tend to have one environment, one database and changes applied directly. If that is your situation, read what changes before real users arrive on a v0 build or the Replit equivalent first. Blue-green sits on top of that groundwork.

What it costs

Two full environments cost more than one while both run. HashiCorp notes that this can raise costs, and suggests running blue/green only in production and using infrastructure-as-code to create green only when a new version is planned. The AWS whitepaper adds that green can launch with a different or smaller resource profile, and you stop paying for blue once it is decommissioned.

For an early-stage product, that makes the cost a few extra hours of a small environment per release, not a permanent doubling of your hosting bill. The bigger cost is the discipline: scripts, tests and migrations that behave.

Blue-green versus canary, rolling and A/B

Founders often hear these terms together. They answer different questions.

StrategyHow traffic movesRollbackBest when
Blue-greenAll users switch at once from blue to greenPoint traffic back at blueYou need an instant switchover and can afford a second environment
CanaryA small share first, then gradually moreSend the slice backYou want real users to find problems early, with limited exposure
RollingServers updated in batchesRevert the batches, which can be more complexYou have many servers and want to avoid duplicates
A/BTwo versions live at once for different user groupsStop the experimentYou are comparing user behavior, not releasing safely

The first three come from HashiCorp's description of zero-downtime strategies. Alibaba Cloud's comparison puts the blue-green versus canary trade-off this way: blue-green suits services needing instant switchover that can afford twice the resources, while canary suits gradual rollouts that use resources efficiently.

The honest trade-off: with blue-green, everyone moves to the new version at the same moment, so a problem that only shows up under real traffic hits everyone until you switch back. Canary limits that exposure but needs traffic-splitting machinery and a way to compare the two groups.

On A/B testing, OKD's documentation makes the difference clear. In blue-green, users stay on the stable version while the new one is tested, then are switched over. In an A/B setup both versions are live at once with different users on each. One is a release technique. The other is an experiment. Bunny.net recommends blue/green when a release must be atomic, for example a schema change where both versions must serve the same traffic safely.

If your product includes machine-learning models, there is a further technique where a new model runs silently on live traffic without affecting users. This write-up on shadow deployment for ML models shows how it differs from the strategies above. For LLM features specifically, see my phased plan for AI feature rollouts.

Feature flags are a different layer

A deployment strategy decides which version of the code runs. A feature flag decides which features inside that code are switched on, for which users, without a redeploy. They combine well: you can deploy the new version to production dark with blue-green, then reveal the feature to a few customers by turning a flag on. For a small team this is often a cheaper way to get canary-style caution than building traffic splitting.

Do you need it yet?

Blue-green earns its place when downtime costs you money or trust: a booking system, a client portal, a product with paying subscribers and logins. It is usually overkill when you have a handful of testers and can announce a five-minute maintenance window.

A realistic order of priorities for a young product:

  1. One production environment and one staging environment that are built the same way.
  2. Deploys that run from a script or pipeline, not from someone's laptop.
  3. Database migrations kept in version control and written to be backward compatible.
  4. Monitoring that tells you in minutes whether a release broke sign-ups or payments.
  5. Then blue-green, or something lighter.

Lighter options exist on modern platforms. Cloudflare Workers, which I use in my stack, keep previous versions and let you roll back to an earlier version, which sends 100% of traffic to the version you pick. For many small products, that gives most of the safety of blue-green with far less to manage. Which fits depends on your architecture, and it is a good question for a short audit rather than a guess.

For more on how release practice fits together at a small company, see the B2B SaaS product deployment process and what rapid deployment means for IT teams.

Where I come in

Where I come in

Most founders who find this topic are not choosing between deployment strategies. They have a Lovable, Bolt, Bubble or Replit prototype that works in a demo and now needs to survive real users, and nobody has told them what is missing underneath. I rebuild those prototypes as maintainable code, with the prototype as the specification, at a fixed price and with the code yours from the first commit.

The first step is a fixed-price Prototype Audit at €1,500, taking 3 to 5 days and credited against the build. Builds start from €12,000 and rescue rebuilds run €12,000 to €20,000. I can do it at that price because there is no agency overhead, no project-manager layer and no offshore markup: you talk to the senior engineer who writes the code. If you want to see what that looks like for your product, start on my main page.

My view: safe releases are part of the first version

I don't treat deployment as something you add after launch. A founder who is about to show an investor a demo, or put the first paying customers on a product, needs to know that shipping a fix on Tuesday won't break Wednesday.

That is why I keep the stack deliberately boring and widely known: TypeScript, Next.js, Node, SQL, Cloudflare Workers. The next developer can pick it up, and the release process is something a person other than me can run.

Whether that means full blue-green, a simple version rollback or feature flags depends on the product. I would rather match the release practice to your stage than sell you infrastructure you don't need yet.

Hanad Kubat

FAQ

What is the difference between blue-green and canary deployment?

Blue-green switches all users from the old version to the new one at once, and rolling back means switching them all back. Canary sends the new version to a small share of users first and increases it gradually. Blue-green gives instant rollback, while canary limits how many users a bad release can reach.

Does blue-green deployment mean zero downtime?

It is designed to, because users stay on blue until green is tested and ready. Downtime can still happen if green is misconfigured or if a database change breaks the old version. Backward-compatible migrations and a monitored bake period after the switch are what make the zero-downtime promise hold.

How long should I keep the old environment after switching?

Long enough to be confident the new version is stable, which depends on how often your users hit the riskiest flows. Platform guides such as ECS's workflow include a monitoring period before the old environment is terminated or retained. Keeping it a bit longer costs little compared with losing your rollback.

Is blue-green the same as A/B testing?

No. Blue-green is a release technique where users move from one version to the other. A/B testing keeps two versions live at once so you can compare how different groups of users behave. They can be used together, but they solve different problems.

Hanad Kubat
Discuss Your Software Build
Email Hanad about building a working software product with fixed scope and code you own from the first commit.

Sources