Health Check Endpoint
Fuwafuwa Framework includes a built-in health check endpoint for monitoring application status, making it easy to integrate with monitoring tools and load balancers.
In production environments, it's critical to know whether your application is running and healthy. Health checks provide a standardized way for monitoring systems, load balancers, and orchestration platforms to query application status. The health check endpoint responds with simple success/failure indicators or detailed diagnostic information.
The framework supports both basic liveness probes (is the app running?) and detailed readiness probes (is the app ready to serve traffic?). Liveness probes are lightweight and return immediately, while readiness probes check dependencies like database connectivity, disk space, and memory usage. This separation allows your infrastructure to make intelligent routing decisions.
- Quick Liveness Probe - Returns HTTP 200 when the application is running
- Detailed Readiness Probe - Checks dependencies and system resources
- Database Verification - Tests database connectivity and response time
- Resource Monitoring - Reports disk space, memory usage, and cache status
- Standardized Format - JSON responses for automated parsing by monitoring tools
Basic Health Check
The simplest health check endpoint returns HTTP 200 when the application is running:
# Basic health check
GET /health
# Response
HTTP/1.1 200 OK
Content-Type: text/plain
OK
This is useful for simple load balancer health checks and Kubernetes liveness probes.
Health Check Response
The health check endpoint returns JSON with the current status of key system components. This allows monitoring systems and load balancers to programmatically determine application health.
The response includes overall status, timestamp, application version, and individual check results for database and cache. Monitoring systems can parse this JSON to trigger alerts when components fail.
Sample Response
{
"status": "healthy",
"timestamp": "2024-01-15T10:30:00+00:00",
"version": "2.1.0",
"checks": {
"database": "healthy",
"cache": "healthy"
}
}
The response includes a top-level status field—healthy, degraded,
or unhealthy—that monitoring systems can use for alerting. Each check component reports its
individual status, making it easy to pinpoint the source of problems. Response times help track
performance trends over time.
Status Codes
The health check uses HTTP status codes to communicate application state. A 200 status indicates the application is running and all checks passed. A 503 status indicates there's a problem with one or more checks.
| Status Code | Meaning |
|---|---|
200 OK |
Application is healthy, all checks passed |
503 Service Unavailable |
Application has issues with one or more checks |
Kubernetes Integration
Kubernetes uses health checks to manage container lifecycle. Liveness probes determine if a container needs to be restarted, while readiness probes indicate whether a container should receive traffic. Proper health check configuration prevents Kubernetes from routing traffic to containers that aren't ready to handle it.
Use the health endpoint for Kubernetes probes:
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: fuwafuwa-app
spec:
template:
spec:
containers:
- name: app
image: fuwafuwa/app:latest
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
Probe Types
| Probe | Endpoint | Purpose |
|---|---|---|
| Liveness | /health | Restart container if app is dead |
| Readiness | /health | Remove from service if not ready |
| Startup | /health | Wait for slow-starting containers |