Skip to content

Health Checks & Probes

Production liveness, readiness, and monitoring probes for container orchestrators (Kubernetes, Docker, Cloud Run) and uptime monitoring.


Overview

Ktor-E-Commerce provides dedicated health check endpoints outside the /api/v1 version prefix. These are designed for load balancers, orchestrator readiness probes, and synthetic monitoring without incurring authentication overhead.


Health Check Endpoints

Method Endpoint Purpose Upstream Checks Typical HTTP Status
GET /health Basic application ping Application runtime 200 OK
GET /health/live Kubernetes Liveness probe Application process active 200 OK
GET /health/ready Kubernetes Readiness probe Database connection pool (SELECT 1) 200 OK or 503 Service Unavailable

Endpoint Details

1. Application Liveness

GET /health/live Public / No Auth Required

Verifies the JVM process is accepting HTTP traffic. Used by orchestrators to determine whether the container needs a restart.

Request

curl -i http://localhost:8080/health/live

Response

{
  "message": "UP"
}

2. Database Readiness Probe

GET /health/ready Public / No Auth Required

Executes an active test query (SELECT 1) against the PostgreSQL database connection pool with a 3,000 ms timeout. If the database is unreachable or connection pools are exhausted, the endpoint responds with 503 Service Unavailable so the load balancer temporarily diverts traffic.

Request

curl -i http://localhost:8080/health/ready

Responses

{
  "message": "READY"
}
{
  "message": "Database unreachable",
  "code": "SERVICE_UNAVAILABLE",
  "status": 503,
  "requestId": "req-9c8f61aa-7023"
}

Kubernetes Probe Configuration Example

livenessProbe:
  httpGet:
    path: /health/live
    port: 8080
  initialDelaySeconds: 10
  periodSeconds: 15
  timeoutSeconds: 3

readinessProbe:
  httpGet:
    path: /health/ready
    port: 8080
  initialDelaySeconds: 5
  periodSeconds: 10
  timeoutSeconds: 3
  failureThreshold: 3