Blue-Green Deployment That Resulted in Split-Brain Sessions
Incomplete session store migration meant users were authenticated on green but not on blue, causing random logout loops during traffic shifting.
Overview
A blue-green deploy that also rotated the session signing key logged users out over and over as the load balancer bounced them between environments.
What happened
Blue signed session tokens with HMAC-SHA256 and a 32-byte key. Green used the same algorithm with a newly generated key, and the load balancer sent 50% of traffic to green.
The two environments differed in exactly one way that mattered. Blue ran the old version and green the new one, and both signed with HMAC-SHA256. But blue kept the existing 32-byte key, while green used a newly generated key as part of a planned rotation.
Follow one user through the 50/50 split and the loop appears.
- The user sends a request with a blue-signed token.
- The load balancer routes it to green.
- Green, which only knows the new key, answers 401, and the session is invalidated: the user is logged out.
- The user logs in again, on green, and gets a green-signed token.
- The user's next request goes back through the load balancer, which routes it to blue.
- Blue, which only knows the old key, answers 401, and the user is logged out again.
Key concepts
- Split-brain session
- Dual-read key validation
- Key rotation
Interview questions
- How do you safely rotate session signing keys in a blue-green deployment without logging users out?
Sign up free to read the full topic
More War Stories topics
- A Feature Flag Change That Triggered a Production Outage
- Accidental DELETE Without a WHERE Clause in Production
- An IAM Misconfiguration That Let a Developer Become Admin
- AWS Credentials Committed to a Public GitHub Repository
- Backups That Were Never Actually Completing
- BGP Route Leak That Rerouted Traffic Through an Unexpected AS
- Cache Stampede on a Flash-Sale Product Page
- Connection Pool Exhaustion That Brought Down 12 Microservices
- DynamoDB Hot Partition That Throttled a Flash Sale
- Failover to a Lagging Replica Lost 4 Minutes of Orders
- Internal DNS Cache Poisoning That Redirected API Traffic
- Malicious npm Package Exfiltrated Environment Variables at Build Time
Start free on Cariara · Coding problems · System design studio