Where Does the Convention of Using /healthz for Application Health Checks Come From?
Introduction
The /healthz endpoint is a widely used convention for application health checks. It provides a simple way for systems to verify the health of an application or service. But where does this convention come from, and why has it become so popular?
In this guide, you'll learn about the origins of /healthz, its purpose, and how it fits into modern software development practices.
The Origins of /healthz
The /healthz convention originated in the Kubernetes ecosystem. Kubernetes uses /healthz endpoints to check the health of system components like the API server. Over time, this convention was adopted by developers for their own applications.
Why /healthz?
- Simplicity: The
/healthzendpoint is easy to implement and understand. - Standardization: Using a common endpoint name makes it easier for tools and systems to integrate.
- Backward Compatibility: The
zin/healthzwas added to avoid conflicts with existing/healthendpoints.
+-------------------+
| Application |
| |
| +---------------+ |
| | /healthz | |
| +---------------+ |
| +---------------+ |
| | Monitoring | |
| +---------------+ |
| +---------------+ |
| | Alerts | |
| +---------------+ |
+-------------------+
Implementing /healthz in Your Application
Example in Node.js
const express = require('express');
const app = express();
app.get('/healthz', (req, res) => {
res.status(200).send('OK');
});
app.listen(3000, () => {
console.log('Server is running on port 3000');
});
This code creates a simple /healthz endpoint that returns a 200 status code and an OK message.
Example in Python
from flask import Flask
app = Flask(__name__)
@app.route('/healthz')
def healthz():
return "OK", 200
if __name__ == '__main__':
app.run(port=3000)
This Python example achieves the same functionality using Flask.
Best Practices for Health Checks
- Keep It Lightweight: Ensure the
/healthzendpoint responds quickly and doesn't perform heavy operations. - Use HTTP Status Codes: Return
200for healthy and500for unhealthy states. - Monitor Regularly: Integrate
/healthzchecks into your monitoring tools.
Conclusion
The /healthz convention has become a standard for application health checks due to its simplicity and effectiveness. By implementing /healthz in your applications, you can provide a reliable way for systems to monitor and ensure the health of your services.
We earn commissions when you shop through the links below.
DigitalOcean
Cloud infrastructure for developers
Simple, reliable cloud computing designed for developers
DevDojo
Developer community & tools
Join a community of developers sharing knowledge and tools
SMTPfast
Developer-first email API
Send transactional and marketing email through a clean REST API. Detailed logs, webhooks, and embeddable signup forms in one dashboard.
QuizAPI
Developer-first quiz platform
Build, generate, and embed quizzes with a powerful REST API. AI-powered question generation and live multiplayer.
Want to support DevOps Daily and reach thousands of developers?
Become a SponsorFound an issue?
Related Posts
Also worth your time on this topic
The 3 Infrastructure Decisions That Determine Your Engineering Velocity
Provisioning model, environment strategy, and deployment surface. Everything else is optimization. Here's how to make these foundational choices without killing your team's momentum.
CI/CD Pipeline Setup Checklist
Step-by-step checklist for a production-ready CI/CD pipeline: source control, builds, tests, security scans, deploy gates, secrets, and rollback paths.
1-2 hours
Helm Charts and Kubernetes Package Management
Learn Kubernetes application deployment and management using Helm charts with templates, values, and lifecycle management.
90 minutes