The Real Fullstack

The Zero-Downtime Deployment

The release notes say “no user impact”. The error dashboard says 400 failed checkouts. Who is right?

Engenheiro sênior12 minSimulador de linha do tempoLaboratório de performanceDesafio de código
kubernetesyamlpostgresqlspring-bootsql

Este desafio ainda não foi traduzido para Português (Brasil). Você está lendo a versão em inglês.

Missão:Configure the rollout so that no request fails while capacity stays at or above 75%, then order the schema migration steps so that every running version always sees a compatible schema.Contexto · Objetivos de aprendizagem ▾

Brightcart, a fictional retailer, deploys its checkout service on Kubernetes several times a week. Each release produces a short spike of 502/503 errors, and the latest one also renamed a database column. Customers retry, support tickets arrive, and the team has started deploying only at night.

Missão: Configure the rollout so that no request fails while capacity stays at or above 75%, then order the schema migration steps so that every running version always sees a compatible schema.

Objetivos de aprendizagem

  • Explain how readiness probes, maxSurge and maxUnavailable shape a rolling update.
  • Drain in-flight requests during shutdown (preStop, graceful shutdown).
  • Apply the expand → migrate → contract pattern to schema changes.
Simulação
Simulado

Execute a simulação para ver a saída.

Executar simulação
apiVersion: apps/v1kind: Deploymentmetadata: { name: checkout }spec:  replicas: 4  strategy:    type: Recreate          # all old pods stop before new ones start  template:    spec:      containers:        - name: checkout          image: registry.example/checkout:2.0.0          # no readinessProbe: traffic is sent as soon as the container starts
-- 1. expand (compatible with v1 and v2)ALTER TABLE orders ADD COLUMN shipping_address_id BIGINT NULL;-- 2. deploy v2: writes BOTH the old column and the new one, reads the new one with fallback-- 3. backfill rows written before/while v1 was runningUPDATE orders SET shipping_address_id = legacy_address_id WHERE shipping_address_id IS NULL;-- 4. contract (only when no running version reads the old column)ALTER TABLE orders DROP COLUMN legacy_address_id;

Simplificação

Time advances in discrete ticks and every pod warms up in exactly 3 ticks. The real Deployment controller, endpoint propagation delays and probe timing are more nuanced. Modelo educacional — os números ilustram comportamento, não são benchmarks.

Conceitos

Desafios relacionados

Referências