11

Pouzdanost i rad sustava

Sažetak

Svaka produkcijska isporuka ide plavo-zelenim postupkom, a povratak je ponovna isporuka prethodne verzije uz shemu koja se samo proširuje. Oporavak se uvježbava tjedno: vraćanje iz sigurnosne kopije i vježba otpornosti na ispade, sporost, prelazak baze i rušenja.

Tehnička specifikacija vodi se na engleskom jeziku; naslovi i sažeci poglavlja prevedeni su na hrvatski.

Deployment

  1. A disaster-recovery gate and a release-readiness gate run first.
  2. The live service definition is rendered from the repository and applied as a whole, so configuration drift between deploys is visible in review; a scheduled workflow reports drift that appears in between.
  3. The new revision is deployed under a tag with no traffic and smoke-tested on its health endpoint.
  4. Traffic moves to it; the previous revision stays available for immediate rollback.

Schema changes

300+ forward-only migrations are tracked in their own ledger, each declaring its phase: expand, migrate, verify or contract (ADR 0012). Contract runs only after two successful full-traffic releases, and a destructive statement needs an explicit approval with evidence. Deploys take a fresh backup and rehearse migrations on a production clone first. There is no generated down-SQL: rolling back means deploying the previous build against the expanded schema (ADR 0013).

Recovery targets

  • Unhealthy revision
    Recovery time
    < 30 s
    Data loss
    None
    Mechanism
    Blue-green rollback
  • Database primary failure
    Recovery time
    < 5 min
    Data loss
    < 5 min
    Mechanism
    Cloud SQL high-availability failover; 7 days of point-in-time recovery
  • Data corruption
    Recovery time
    < 1 h
    Data loss
    Last good backup
    Mechanism
    Restore, then replay erasure tombstones
  • Signing-key compromise
    Recovery time
    < 1 h
    Data loss
    None
    Mechanism
    Key-version rotation with JWKS overlap
  • Stolen refresh token
    Recovery time
    Immediate
    Data loss
    None
    Mechanism
    Family revocation on replay
  • Lost device
    Recovery time
    Minutes
    Data loss
    Unsynced draft only
    Mechanism
    Owner revokes the device from any other device
  • Speech-recognition outage
    Recovery time
    Automatic
    Data loss
    None
    Mechanism
    Circuit breaker fails over to the secondary engine

Drills

  • Restore drill
    Cadence
    Weekly (Sunday)
    What it proves
    A backup restores and passes verification
  • Resilience drill
    Cadence
    Weekly (Monday)
    What it proves
    Behaviour under provider outage, slow dependency, database failover, revision termination, worker crash and retry storm
  • Load test
    Cadence
    On demand
    What it proves
    k6 scenarios for health, CRUD, AI streaming, server-sent-event limits and the rate limiter

Capacity envelope

  • Application instances
    Value
    1 – 5
  • Concurrency per instance
    Value
    15 requests
  • Database pool
    Value
    50 per instance, 250 total
  • Database connection limit required
    Value
    300

Observability

  • Structured logs with PII masking to Cloud Logging; request ids correlate logs, traces and audit rows.
  • OpenTelemetry traces to Cloud Trace, sampled at 10 % in production.
  • Errors recorded with scrubbing; every scheduled job writes a run log.
  • Alerts for SLO burn rate, unhandled errors, cron failures, routing failures, upload-virus detections, live-voice SLOs and audit-chain verification.
  • AI usage and cost per clinic from the decision record and token tracker.
SOURCE OF TRUTH
  • .github/workflows/deploy.yml
  • scripts/render-active-cloud-run-service.mjs
  • docs/architecture/migration-v2.md
  • resilience/scenarios.json
  • infra/capacity-envelope.json
  • loadtest/
  • docs/runbooks/disaster-recovery.md
Svaki broj u ovoj specifikaciji generira se iz repozitorija i provjerava u CI-ju.