Back to Blog
team@tinypod.app

Health Checks: Making Sure Your Self-Hosted Apps Stay Alive

Health checks detect when an app is broken and trigger automatic recovery. Essential for reliable self-hosted infrastructure.

monitoringreliabilitydevops

What Are Health Checks?


A health check is a periodic test that verifies an application is working correctly. If the check fails, automated systems can restart the application or remove it from load balancing.


Types of Health Checks


Liveness Check

"Is the process alive?" The most basic check — is the container running? If not, restart it.


Readiness Check

"Can the app handle requests?" The app might be running but not ready — still loading data, waiting for database connection, etc. Don't send traffic until it's ready.


Startup Check

"Has the app finished starting?" Some apps take a while to start. The startup check prevents premature liveness failures during initialization.


Deep Health Check

"Are all dependencies working?" Check database connectivity, cache availability, external API reachability.


Implementing Health Checks


HTTP Endpoint

The most common approach. Add a /health or /healthz endpoint that returns:

  • 200 OK: Everything is healthy
  • 503 Service Unavailable: Something is broken

  • A good health response includes:

    {

    "status": "healthy",

    "database": "connected",

    "cache": "connected",

    "uptime": "3d 4h 12m"

    }


    TCP Check

    For non-HTTP services (databases, Redis), check if the port accepts connections.


    Command Check

    Run a command inside the container. Exit code 0 = healthy, non-zero = unhealthy.


    Container Health Checks


    Docker and Podman support HEALTHCHECK in Dockerfiles:


    HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD curl -f http://localhost:8080/health || exit 1


    If the health check fails 3 times, the container is marked unhealthy and can be automatically restarted.


    Best Practices


    Check Intervals

  • Liveness: Every 10-30 seconds
  • Readiness: Every 5-10 seconds
  • Deep health: Every 60 seconds

  • Timeout

    Health checks should be fast. If a check takes more than 5 seconds, something is wrong.


    Don't Check External Dependencies in Liveness

    If your database is down, restarting the app won't fix it. Use deep health checks for dependencies, but don't trigger restarts based on them.


    Grace Period

    Give apps time to start before health checking. A 30-60 second startup grace period prevents unnecessary restarts.


    TinyPod Health Checks


    TinyPod automatically monitors container health. If a container becomes unresponsive, it's restarted automatically. You can configure custom health check endpoints in the dashboard for deeper monitoring.