How would you design a zero-downtime deployment strategy for a stateless web service?
Quick Answer
Use rolling or blue-green deployment with health checks, readiness probes, and gradual traffic shift so new instances are verified before they receive traffic.
Detailed Answer
Zero-downtime deployment means users should continue to receive service while a new version is rolled out. For a stateless service, rolling updates are usually the simplest choice because old and new replicas can coexist temporarily. The deployment should add new replicas, wait for readiness, and only then remove the old ones.
Readiness gates matter because a pod that starts but cannot serve requests should not receive traffic. Health checks and service-level monitoring give the deployment system enough evidence to proceed or stop.
At scale, rollback strategy is just as important as forward deployment. If error rates rise, the system should be able to revert quickly without manual intervention.
The subtle trap is assuming the app is healthy just because the container starts. The real signal is whether requests succeed and latency stays within acceptable bounds.
Senior engineers think about both the deployment mechanism and the operational controls that make it safe under real traffic.
Code Example
# Kubernetes rolling update example
apiVersion: apps/v1
kind: Deployment
metadata:
name: payments-web
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1Interview Tip
Interviewers want to hear about readiness checks, rollback criteria, and traffic management rather than only the deployment command itself.