Course contentsShow
← System Design
Lesson 101 of 1,9193. Load BalancingFree lesson

Health Check Endpoints

Dedicated health endpoints return service status, checking dependencies like databases to ensure the server can truly handle requests.

Health Check Endpoints

What you'll learn: How to implement dedicated endpoints that accurately report whether your service can truly handle requests.

The Problem with Simple Checks

You've learned that load balancers use health checks to decide which servers can receive traffic. But what exactly should those health checks verify? Simply checking if the server responds to a network request isn't enough—your web server might be running fine, but if its database connection is broken, it can't actually serve users.

What Are Health Check Endpoints?

A health check endpoint is a dedicated URL (like /health or /status) specifically designed to return your service's readiness. Unlike your application's normal endpoints, this one exists solely to answer: "Can this server handle real requests right now?"

Think of it like a pilot's pre-flight checklist. The plane's engine might start (server responds to ping), but the pilot verifies fuel levels, hydraulics, instruments, and communication systems before declaring the plane ready to fly. Similarly, your health endpoint checks all critical dependencies.

What to Check

A good health endpoint verifies:

  • Database connectivity: Can we read/write?
  • Required external services: Can we reach the payment API, authentication service, etc.?
  • Critical resources: Do we have disk space, memory?
  • Application logic: Are worker threads responsive?

The endpoint typically returns HTTP 200 (healthy) or 503 (unhealthy), often with a JSON body describing which checks passed or failed.

Keep It Fast

Health checks run frequently (every few seconds), so your endpoint must respond quickly—usually under 1 second. Don't perform expensive operations; just verify connectivity and basic functionality.

Key Takeaway: Health check endpoints go beyond "is the server running?" to verify "can the server actually fulfill requests?" by checking dependencies like databases, making them essential for accurate load balancing decisions.