Production REST API

Operations and release

Add observability, health checks, graceful shutdown, and an evidence-based release checklist.

Operations and release

What you will learn

  • distinguish liveness, readiness, and diagnostics;
  • record useful telemetry without secrets or unbounded labels;
  • set server and dependency time budgets;
  • test shutdown and degraded dependencies;
  • define release and rollback evidence.

Health and telemetry

Liveness says the process is running; keep it independent of optional dependencies. Readiness says whether this instance should receive new traffic and may depend on critical state. Restrict rich diagnostics to operators. Do not make liveness depend on the database or a temporary outage can restart every instance.

Logs should include severity, request ID, route pattern, status, duration, and safe error class. Never record passwords, tokens, authorization headers, or sensitive bodies. Metrics use bounded route-pattern labels—not raw URLs, user IDs, or request IDs. Traces propagate context with cost-aware sampling.

Budgets, retries, and shutdown

Choose HTTP, database, and outbound-request deadlines from an overall latency budget. Retry only suitable failures with capped attempts, backoff, jitter, cancellation, and idempotency protection.

Test that shutdown stops new requests, allows an active request to finish within the deadline, cancels background workers, and still returns when a handler is stuck.

Release evidence

  • migrations passed on production-like data and have rollback or forward-fix plans;
  • required unit, integration, HTTP, race, fuzz, and vulnerability checks passed in a Go-enabled environment;
  • configuration and secrets stay outside source control and are validated at startup;
  • limits, timeouts, pools, overload behaviour, dashboards, and alerts are documented;
  • backup restoration was tested;
  • rollout is gradual with a clear rollback trigger;
  • runbooks name owners and immediate diagnostic steps.

Practice

Readiness fails because the database pool is exhausted while liveness passes. Why is that useful, and which signals come first?

Summary

  • Health endpoints have different meanings and audiences.
  • Telemetry must be useful, bounded, and safe to retain.
  • Deadlines, overload rules, and shutdown are service behaviour.
  • Release confidence requires tested evidence and rollback plans.

Ready to wrap up?

Mark this complete when you can explain the main idea and finish the practice task.

Copyright © 2026