Performance: Health check endpoints
MEDIUM IMPACT
Health check endpoints impact server responsiveness and network load, affecting how quickly users or monitoring tools get status feedback.
from fastapi import FastAPI app = FastAPI() @app.get('/health') async def health_check(): # Simple lightweight check return {'status': 'ok'}
from fastapi import FastAPI app = FastAPI() @app.get('/health') async def health_check(): # Simulate heavy database query or complex logic result = await heavy_database_query() return {'status': 'ok', 'db': result}
| Pattern | Server Processing | Response Time | Network Load | Verdict |
|---|---|---|---|---|
| Heavy logic in health check | High CPU usage | 100+ ms | Increased | [X] Bad |
| Lightweight immediate response | Minimal CPU usage | <1 ms | Minimal | [OK] Good |