← Back to Workspace Case Study
Cloud Infrastructure & High-Density Systems

Zero-Downtime Blue/Green Deployments Explained Simply

Key Impact Verified
Zero Downtime β€’ 100% Traffic Cutover β€’ Instant Rollback Safety
Date: 2026-10-07 | AWS Laravel Octane FrankenPHP ElastiCache Reverb DevOps

01. The Idea in 30 Seconds

Deploying new features or bug fixes to production used to be scary: What if something breaks and the whole site goes down while users are in the middle of something important?

Blue/Green Deployment removes that headache completely. Instead of touching or updating code on your live servers, you spin up a fresh copy of your servers right beside them:

The traffic router only switches users over to Green once every single check is 100% healthy. If anything smells wrong, the deployment stops, the new servers turn off, and users never see an error or downtime.

02. How It Works (Visual Flow)

// How Traffic Switches Over Safely
flowchart TD
    Users["πŸ‘₯ Active Users & Clinics (100% Traffic)"] --> ALB["βš–οΈ Application Load Balancer (ALB)"]

    subgraph BlueFleet["πŸ”΅ Blue Fleet (Current Live App - v1.0)"]
        B1["Server A (Octane / FrankenPHP)"]
        B2["Server B (Octane / FrankenPHP)"]
    end

    subgraph GreenFleet["🟒 Green Fleet (New Version - v2.0)"]
        G1["Server C (Octane / FrankenPHP)"]
        G2["Server D (Octane / FrankenPHP)"]
    end

    subgraph CentralState["⚑ Shared Memory (No Disruption)"]
        Redis["AWS ElastiCache Redis / ValKey
β€’ User Logins & Sessions
β€’ Real-time Alerts (Laravel Reverb)
β€’ Background Jobs"] end ALB -->|"Step 1: Normal Live Traffic"| BlueFleet BlueFleet <--> CentralState GreenFleet -.->|"Step 2: Auto Health Check /up (200 OK)"| ALB GreenFleet <--> CentralState ALB ==>|"Step 3: Instant Cutover (0 Downtime)"| GreenFleet BlueFleet -.->|"Step 4: Shut Down Cleanly"| Teardown["πŸ›‘ Turn Off Old Servers"] classDef alb fill:#d97706,stroke:#b45309,color:#fff; classDef blue fill:#2563eb,stroke:#1d4ed8,color:#fff; classDef green fill:#16a34a,stroke:#15803d,color:#fff; classDef redis fill:#b91c1c,stroke:#991b1b,color:#fff; classDef term fill:#475569,stroke:#334155,color:#fff; class ALB alb; class B1,B2 blue; class G1,G2 green; class Redis redis; class Teardown term;

03. Why Users Don't Get Logged Out

A natural question most managers and non-tech folks ask is: "When the traffic switches over, will users get kicked out of their accounts or lose what they were typing?"

The answer is no. The secret is keeping user data separate from the servers running the code:

04. 4 Simple Steps of the Deployment Pipeline

// Automated Release Steps
sequenceDiagram
    autonumber
    actor Team as πŸ‘¨β€πŸ’» Developer / Team
    participant CI as GitHub Actions (Build Bot)
    participant Cloud as AWS Cloud (CodeDeploy & S3)
    participant Green as Green Servers (New Version)
    participant Router as Load Balancer (Traffic Router)

    Team->>CI: Push Release Tag (e.g. v2.0)
    CI->>Cloud: Send verified code package
    Cloud->>Green: 1. Start new servers in the background
    Green->>Green: 2. Boot app, load caches & check database
    Router->>Green: 3. Ping health check endpoint (/up)
    Router->>Green: 4. All good? Flip traffic instantly!
  

05. 3 Real-World Lessons from Production

1. Keep Server & File Regions Together

AWS requires your code package to be in the same geographic region as your servers. If your servers are in Singapore or London, keep your storage bucket in the same place too. This prevents lag and keeps server spin-up times fast.

2. Watch Out for Login Redirects on Health Checks

A lot of web apps automatically bounce visitors to a /login page if they hit the home address. If the load balancer is strictly waiting for a normal welcome page, it might wrongly assume the server is broken and cancel the deploy.

The Fix: Point the health check to a dedicated check URL like /up so it always gets a clear thumbs-up.

3. Safe Database Changes (Expand & Contract)

Because the new code gets ready before traffic switches over, never delete or rename database columns all at once. Always add new columns first, let both versions work peacefully, and only delete old columns in a later release after everything has settled.

06. The Real Benefit

Blue/Green deployment turns releases from stressful, late-night panic sessions into routine, non-events during normal working hours. You can release updates whenever you need to, without worrying about waking up to downtime complaints or frustrated users.

← Back to Workspace Ameerul Arif β€’ Senior Systems Architect & DevOps