As asked
Walk me through how you would design a blue/green deployment pipeline for a stateful API that owns a Postgres database and accepts long-lived WebSocket connections.
Sample answer outline
Stand up two identical environments behind a router (ALB, Envoy, or a service mesh). Migrate the schema in expand/contract phases so blue and green can read and write at the same time. Drain WebSockets gracefully: stop accepting new connections on blue, let clients reconnect to green via DNS or sticky-session routing. Hold the cutover with a small canary slice (1 to 5 percent) and watch SLO burn, error rates, and connection re-establishment metrics. Keep blue warm for the rollback window, then tear it down.
Expect these follow-ups
- How does this change if the schema migration is destructive and not backwards compatible?
- What if you cannot afford to double-provision the database?
- How would you handle a partial cutover failure where 30 percent of traffic is on green?