Health checks на собеседовании системного аналитика
Карьерник — Duolingo для аналитиков: 10 минут в день тренируй SQL, Python, A/B, статистику, метрики и ещё 3 темы собеса. 1500+ вопросов в Telegram-боте. Бесплатно.
Содержание:
Зачем health checks
Auto-detect unhealthy instances → remove from LB / restart.
Без health checks — broken pod продолжает receive traffic, errors propagate.
Liveness vs readiness
Liveness. Is the service alive (or hung)?
GET /healthz → 200 OKIf fail многократно → restart container.
Should be lightweight. Just verify process responsive.
Readiness. Is the service ready принимать traffic?
GET /ready → 200 если can serve.If fail → remove из LB pool. Не restart.
Checks dependencies (DB, cache, downstream).
@app.get("/ready")
def ready():
if not db.is_connected():
return Response(status=503)
if not redis.ping():
return Response(status=503)
return Response(status=200)Startup probe
k8s 1.16+. Для slow-starting apps.
startupProbe:
httpGet:
path: /startup
port: 8080
failureThreshold: 30
periodSeconds: 10 # 5 min totalDisables liveness / readiness пока startup succeeds. Prevents premature kills.
Deep vs shallow
Shallow. Just service responding.
Deep. Check critical dependencies.
/health/shallow: just returns 200.
/health/deep: checks DB + Redis + downstream API.Trade-off.
- Deep — accurate readiness, но cascade failures (one slow downstream → all unhealthy).
- Shallow — может мiss real issues.
Compromise. Readiness — deep. Liveness — shallow (just process check).
Implementation patterns
Cache health for short period. Если check expensive — cache 1-5 sec.
Different ports. Health на admin port, не main API.
Don't include in main metrics. Separate health requests.
Fail fast on critical deps. No DB → not ready.
Don't fail на optional deps. Cache miss → still ready (degraded).
Связанные темы
- SLA SLO SLI для SA
- Service mesh для SA
- Service discovery для SA
- Capacity planning для SA
- Подготовка к собесу системного аналитика
FAQ
Это официальная информация?
Нет. Статья основана на k8s docs и Microsoft / Google practices.
Тренируйте системный анализ — откройте тренажёр с 1500+ вопросами для собесов.